From 71906d6313c4827761f9df6e7c105bca1a96cfd9 Mon Sep 17 00:00:00 2001 From: Abigail Agoos <138502477+renesas-abigail@users.noreply.github.com> Date: Thu, 11 Dec 2025 16:28:19 -0500 Subject: [PATCH 1/7] feat: add doxyfile_prefix parameter --- doxygen/doxygen.bzl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doxygen/doxygen.bzl b/doxygen/doxygen.bzl index 060f0eb..f32b449 100644 --- a/doxygen/doxygen.bzl +++ b/doxygen/doxygen.bzl @@ -55,7 +55,8 @@ collect_files_aspect = aspect( ) def _doxygen_impl(ctx): - doxyfile = ctx.actions.declare_file("Doxyfile") + doxyfile_prefix = ctx.attr.doxyfile_prefix + doxyfile = ctx.actions.declare_file("{}/Doxyfile".format(doxyfile_prefix) if doxyfile_prefix else "Doxyfile") output_group_info = {} outs = [] @@ -143,6 +144,7 @@ doxygen( "deps": attr.label_list(aspects = [collect_files_aspect], doc = "List of dependencies targets whose files present in the 'src', 'hdrs' and 'data' attributes will be collected to generate the documentation. Transitive dependencies are also taken into account. Since we are only considering the source files and not the outputs, these targets **will not** be built"), "configurations": attr.string_list(doc = "Additional configuration parameters to append to the Doxyfile. For example, to set the project name, use `PROJECT_NAME = example`."), "outs": attr.string_list(default = ["html"], allow_empty = False, doc = """Output folders to keep. If only the html outputs is of interest, the default value will do. Otherwise, a list of folders to keep is expected (e.g. `["html", "latex"]`)."""), + "doxyfile_prefix" : attr.string(doc = "Prefix to add to doxyfile path.", default= ""), "doxyfile_template": attr.label( allow_single_file = True, default = Label(":Doxyfile.template"), @@ -213,6 +215,7 @@ def doxygen( env = {}, tools = [], outs = ["html"], + doxyfile_prefix = "", # Doxygen specific attributes doxyfile_encoding = None, project_name = None, @@ -1342,6 +1345,7 @@ def doxygen( srcs = srcs, deps = deps, outs = outs, + doxyfile_prefix = doxyfile_prefix, configurations = configurations, doxygen_extra_args = doxygen_extra_args, executable = executable, From 0ad011969372bb2448cb23f612687e9049627068 Mon Sep 17 00:00:00 2001 From: Abigail Agoos <138502477+renesas-abigail@users.noreply.github.com> Date: Thu, 11 Dec 2025 16:28:44 -0500 Subject: [PATCH 2/7] docs: update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07dc83a..ac9df11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.6.1] + +### Added + +- Add `doxyfile_prefix` parameter to optionally allow configuring the directory into which the `Doxyfile` is emitted. Addresses [#35](https://github.com/TendTo/rules_doxygen/issues/35). + ## [2.6.0] ### Changed From 2a342ead5144ea6ce7b84c09e0344dd7ccee0d22 Mon Sep 17 00:00:00 2001 From: Ernesto Casablanca Date: Thu, 11 Dec 2025 23:10:23 +0000 Subject: [PATCH 3/7] chore: consistent string formatting --- doxygen/doxygen.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doxygen/doxygen.bzl b/doxygen/doxygen.bzl index f32b449..0de93fe 100644 --- a/doxygen/doxygen.bzl +++ b/doxygen/doxygen.bzl @@ -56,7 +56,7 @@ collect_files_aspect = aspect( def _doxygen_impl(ctx): doxyfile_prefix = ctx.attr.doxyfile_prefix - doxyfile = ctx.actions.declare_file("{}/Doxyfile".format(doxyfile_prefix) if doxyfile_prefix else "Doxyfile") + doxyfile = ctx.actions.declare_file("%s/Doxyfile" % doxyfile_prefix if doxyfile_prefix else "Doxyfile") output_group_info = {} outs = [] @@ -144,7 +144,7 @@ doxygen( "deps": attr.label_list(aspects = [collect_files_aspect], doc = "List of dependencies targets whose files present in the 'src', 'hdrs' and 'data' attributes will be collected to generate the documentation. Transitive dependencies are also taken into account. Since we are only considering the source files and not the outputs, these targets **will not** be built"), "configurations": attr.string_list(doc = "Additional configuration parameters to append to the Doxyfile. For example, to set the project name, use `PROJECT_NAME = example`."), "outs": attr.string_list(default = ["html"], allow_empty = False, doc = """Output folders to keep. If only the html outputs is of interest, the default value will do. Otherwise, a list of folders to keep is expected (e.g. `["html", "latex"]`)."""), - "doxyfile_prefix" : attr.string(doc = "Prefix to add to doxyfile path.", default= ""), + "doxyfile_prefix" : attr.string(doc = "Prefix to add to Doxyfile path.", default= ""), "doxyfile_template": attr.label( allow_single_file = True, default = Label(":Doxyfile.template"), From bce965e5b49383014c112eb4e0549866874b563b Mon Sep 17 00:00:00 2001 From: Ernesto Casablanca Date: Thu, 11 Dec 2025 23:25:35 +0000 Subject: [PATCH 4/7] docs: update documentation --- docs/doxygen_doc.md | 11 ++++++----- doxygen/doxygen.bzl | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/doxygen_doc.md b/docs/doxygen_doc.md index 26f999d..bf1ca76 100755 --- a/docs/doxygen_doc.md +++ b/docs/doxygen_doc.md @@ -28,11 +28,11 @@ A provider to collect source files transitively from the target and its dependen
 load("@doxygen//:doxygen.bzl", "doxygen")
 
-doxygen(name, srcs, deps, executable, dot_executable, configurations, doxyfile_template,
-        doxygen_extra_args, use_default_shell_env, env, tools, outs, doxyfile_encoding, project_name,
-        project_number, project_brief, project_logo, project_icon, create_subdirs,
-        create_subdirs_level, allow_unicode_names, output_language, brief_member_desc, repeat_brief,
-        abbreviate_brief, always_detailed_sec, inline_inherited_memb, full_path_names,
+doxygen(name, srcs, deps, executable, dot_executable, configurations, doxyfile_prefix,
+        doxyfile_template, doxygen_extra_args, use_default_shell_env, env, tools, outs,
+        doxyfile_encoding, project_name, project_number, project_brief, project_logo, project_icon,
+        create_subdirs, create_subdirs_level, allow_unicode_names, output_language, brief_member_desc,
+        repeat_brief, abbreviate_brief, always_detailed_sec, inline_inherited_memb, full_path_names,
         strip_from_path, strip_from_inc_path, short_names, javadoc_autobrief, javadoc_banner,
         qt_autobrief, multiline_cpp_is_brief, python_docstring, inherit_docs, separate_member_pages,
         tab_size, aliases, optimize_output_for_c, optimize_output_java, optimize_for_fortran,
@@ -270,6 +270,7 @@ doxygen(
 | executable |  Label of the doxygen executable.   |  `None` |
 | dot_executable |  Label of the doxygen executable. Make sure it is also added to the `srcs` of the macro   |  `None` |
 | configurations |  List of additional configuration parameters to pass to Doxygen.   |  `None` |
+| doxyfile_prefix |  Prefix to add to the Doxyfile path.   |  `""` |
 | doxyfile_template |  The template file to use to generate the Doxyfile. The following substitutions are available:
- `# {{INPUT}}`: Subpackage directory in the sandbox.
- `# {{ADDITIONAL PARAMETERS}}`: Additional parameters given in the `configurations` attribute.
- `# {{OUTPUT DIRECTORY}}`: The directory provided in the `outs` attribute.
- `{{OUTDIR}}`: The output directory where the generated documentation will be placed. Can be used anywhere in the Doxyfile, usually to generate additional output files, like tag files. | `None` | | doxygen_extra_args | Extra arguments to pass to the doxygen executable. | `[]` | | use_default_shell_env | Whether to use the default shell environment when running doxygen. | `False` | diff --git a/doxygen/doxygen.bzl b/doxygen/doxygen.bzl index 0de93fe..253e7ce 100644 --- a/doxygen/doxygen.bzl +++ b/doxygen/doxygen.bzl @@ -144,7 +144,7 @@ doxygen( "deps": attr.label_list(aspects = [collect_files_aspect], doc = "List of dependencies targets whose files present in the 'src', 'hdrs' and 'data' attributes will be collected to generate the documentation. Transitive dependencies are also taken into account. Since we are only considering the source files and not the outputs, these targets **will not** be built"), "configurations": attr.string_list(doc = "Additional configuration parameters to append to the Doxyfile. For example, to set the project name, use `PROJECT_NAME = example`."), "outs": attr.string_list(default = ["html"], allow_empty = False, doc = """Output folders to keep. If only the html outputs is of interest, the default value will do. Otherwise, a list of folders to keep is expected (e.g. `["html", "latex"]`)."""), - "doxyfile_prefix" : attr.string(doc = "Prefix to add to Doxyfile path.", default= ""), + "doxyfile_prefix" : attr.string(doc = "Prefix to add to the Doxyfile path.", default= ""), "doxyfile_template": attr.label( allow_single_file = True, default = Label(":Doxyfile.template"), @@ -209,13 +209,13 @@ def doxygen( executable = None, dot_executable = None, configurations = None, + doxyfile_prefix = "", doxyfile_template = None, doxygen_extra_args = [], use_default_shell_env = False, env = {}, tools = [], outs = ["html"], - doxyfile_prefix = "", # Doxygen specific attributes doxyfile_encoding = None, project_name = None, @@ -700,6 +700,7 @@ def doxygen( executable: Label of the doxygen executable. dot_executable: Label of the doxygen executable. Make sure it is also added to the `srcs` of the macro configurations: List of additional configuration parameters to pass to Doxygen. + doxyfile_prefix: Prefix to add to the Doxyfile path. doxyfile_template: The template file to use to generate the Doxyfile. The following substitutions are available:
- `# {{INPUT}}`: Subpackage directory in the sandbox.
From b541fce3a2eb8f5ef632079a1182e49cd81a0589 Mon Sep 17 00:00:00 2001 From: Ernesto Casablanca Date: Thu, 11 Dec 2025 23:42:25 +0000 Subject: [PATCH 5/7] feat: add example with multiple rules in the same folder --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++----- examples/nested/BUILD.bazel | 29 ++++++++++++++++++++++++++++ examples/nested/README.md | 38 +++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf3e899..e38174e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Create .bazelversion file working-directory: examples run: echo "${{ matrix.bazel }}" > .bazelversion @@ -72,7 +72,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Install doxygen uses: ssciwr/doxygen-install@v1 with: @@ -103,7 +103,7 @@ jobs: subdir: [base] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Create .bazelversion file working-directory: examples run: echo "${{ matrix.bazel }}" > .bazelversion @@ -157,7 +157,7 @@ jobs: subdir: [base] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Create .bazelversion file working-directory: examples run: echo "${{ matrix.bazel }}" > .bazelversion @@ -225,7 +225,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Create .bazelversion file working-directory: examples run: echo "${{ matrix.bazel }}" > .bazelversion @@ -241,3 +241,31 @@ jobs: - name: Check doxygen version in produced index.html run: grep "Doxygen $DEFAULT_DOXYGEN_VERSION" examples/submodules/${{ matrix.subdir }}/bazel-bin/html/index.html shell: bash + + nested: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + bazel: [7.0.0, 8.0.0, rolling] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v6 + - name: Create .bazelversion file + working-directory: examples + run: echo "${{ matrix.bazel }}" > .bazelversion + shell: bash + - name: Build nested + run: bazel build //nested:doxygen_a //nested:doxygen_b + working-directory: examples/nested + - name: Check output + uses: andstor/file-existence-action@v3 + with: + files: examples/bazel-bin/nested/html/index.html + fail: true + - name: Check doxygen version in produced index.html + run: grep "Doxygen $DEFAULT_DOXYGEN_VERSION" examples/bazel-bin/nested/nested/a/html/index.html + shell: bash + - name: Check doxygen version in produced index.html + run: grep "Doxygen $DEFAULT_DOXYGEN_VERSION" examples/bazel-bin/nested/nested/b/html/index.html + shell: bash diff --git a/examples/nested/BUILD.bazel b/examples/nested/BUILD.bazel index 0d17a54..028f11b 100644 --- a/examples/nested/BUILD.bazel +++ b/examples/nested/BUILD.bazel @@ -16,3 +16,32 @@ doxygen( project_brief = "Example project for doxygen", project_name = "nested", ) + +doxygen( + name = "doxygen_a", + srcs = ["//nested/lib_a:sources"], + outs = [ + "a/html", + "a/tags", + ], + doxyfile_prefix = "a", + project_brief = "Example project for doxygen, library A", + project_name = "nested", + generate_tagfile = "$(OUTDIR)/tags/tagfile.xml", +) + +doxygen( + name = "doxygen_b", + srcs = glob([ + "lib_b/*.h", + "lib_b/*.cpp", + ]), + outs = [ + "b/html", + "b/tags", + ], + doxyfile_prefix = "b", + project_brief = "Example project for doxygen, library B", + project_name = "nested", + generate_tagfile = "$(OUTDIR)/tags/tagfile.xml", +) diff --git a/examples/nested/README.md b/examples/nested/README.md index 3c80a3a..4d61df6 100644 --- a/examples/nested/README.md +++ b/examples/nested/README.md @@ -77,3 +77,41 @@ doxygen( project_name = "nested", ) ``` + +## Handling multiple doxygen rules in the same folder + +Having multiple `doxygen` rules in the same folder is supported, but requires some extra configuration. +By default, all rules would create a `Doxyfile` in the same location, causing a conflict. +The same applies to the output `html` folder. +To avoid this, remember to specify different `doxyfile_prefix` and `outs` for each rule: + +```bzl +doxygen( + name = "doxygen_a", + srcs = ["//nested/lib_a:sources"], + outs = [ + "a/html", + "a/tags", + ], + doxyfile_prefix = "a", + project_brief = "Example project for doxygen, library A", + project_name = "nested", + generate_tagfile = "$(OUTDIR)/tags/tagfile.xml", +) + +doxygen( + name = "doxygen_b", + srcs = glob([ + "lib_b/*.h", + "lib_b/*.cpp", + ]), + outs = [ + "b/html", + "b/tags", + ], + doxyfile_prefix = "b", + project_brief = "Example project for doxygen, library B", + project_name = "nested", + generate_tagfile = "$(OUTDIR)/tags/tagfile.xml", +) +``` From f30d8f18eab3f29113dd7ff5856357137c1f1266 Mon Sep 17 00:00:00 2001 From: Ernesto Casablanca Date: Thu, 11 Dec 2025 23:54:54 +0000 Subject: [PATCH 6/7] docs: update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac9df11..0148d83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Add `doxyfile_prefix` parameter to optionally allow configuring the directory into which the `Doxyfile` is emitted. Addresses [#35](https://github.com/TendTo/rules_doxygen/issues/35). +- `doxyfile_prefix` parameter to optionally allow configuring the directory into which the `Doxyfile` is emitted [#35](https://github.com/TendTo/rules_doxygen/issues/35) (thanks to @renesas-abigail) ## [2.6.0] From e72b850f50a75ade1a557a8c755a78220b9f4a38 Mon Sep 17 00:00:00 2001 From: Ernesto Casablanca Date: Thu, 11 Dec 2025 23:56:38 +0000 Subject: [PATCH 7/7] ci: fix path --- .github/workflows/ci.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e38174e..237e073 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -258,14 +258,19 @@ jobs: - name: Build nested run: bazel build //nested:doxygen_a //nested:doxygen_b working-directory: examples/nested - - name: Check output + - name: Check output (a) uses: andstor/file-existence-action@v3 with: - files: examples/bazel-bin/nested/html/index.html + files: examples/bazel-bin/nested/a/html/index.html fail: true - - name: Check doxygen version in produced index.html - run: grep "Doxygen $DEFAULT_DOXYGEN_VERSION" examples/bazel-bin/nested/nested/a/html/index.html + - name: Check output (b) + uses: andstor/file-existence-action@v3 + with: + files: examples/bazel-bin/nested/b/html/index.html + fail: true + - name: Check doxygen version in produced index.html (a) + run: grep "Doxygen $DEFAULT_DOXYGEN_VERSION" examples/bazel-bin/nested/a/html/index.html shell: bash - - name: Check doxygen version in produced index.html - run: grep "Doxygen $DEFAULT_DOXYGEN_VERSION" examples/bazel-bin/nested/nested/b/html/index.html + - name: Check doxygen version in produced index.html (b) + run: grep "Doxygen $DEFAULT_DOXYGEN_VERSION" examples/bazel-bin/nested/b/html/index.html shell: bash