Skip to content

Commit 7e88a29

Browse files
gmarullnashif
authored andcommitted
doc: extensions: doxyrunner: add doxyrunner_outdir_var option
The doxyrunner_outdir_var option allows to specify which variable (if any) is used to represent the output directory (as used by OUTPUT_DIRECTORY). This makes sure that other options referencing it are processed correctly, since the output directory is not passed as a variable. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 1e74821 commit 7e88a29

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/_extensions/zephyr/doxyrunner.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
- ``doxyrunner_doxyfile``: Path to Doxyfile.
3232
- ``doxyrunner_outdir``: Doxygen build output directory (inserted to
3333
``OUTPUT_DIRECTORY``)
34+
- ``doxyrunner_outdir_var``: Variable representing the Doxygen build output
35+
directory, as used by ``OUTPUT_DIRECTORY``. This can be useful if other
36+
Doxygen variables reference to the output directory.
3437
- ``doxyrunner_fmt``: Flag to indicate if Doxyfile should be formatted.
3538
- ``doxyrunner_fmt_vars``: Format variables dictionary (name: value).
3639
- ``doxyrunner_fmt_pattern``: Format pattern.
@@ -132,6 +135,7 @@ def process_doxyfile(
132135
fmt: bool = False,
133136
fmt_pattern: Optional[str] = None,
134137
fmt_vars: Optional[Dict[str, str]] = None,
138+
outdir_var: Optional[str] = None,
135139
) -> str:
136140
"""Process Doxyfile.
137141
@@ -146,6 +150,7 @@ def process_doxyfile(
146150
fmt: If Doxyfile should be formatted.
147151
fmt_pattern: Format pattern.
148152
fmt_vars: Format variables.
153+
outdir_var: Variable representing output directory.
149154
150155
Returns:
151156
Processed Doxyfile content.
@@ -179,6 +184,9 @@ def process_doxyfile(
179184
if not fmt_pattern or not fmt_vars:
180185
raise ValueError("Invalid formatting pattern or variables")
181186

187+
if outdir_var:
188+
fmt_vars[outdir_var] = outdir.as_posix()
189+
182190
for var, value in fmt_vars.items():
183191
content = content.replace(fmt_pattern.format(var), value)
184192

@@ -349,6 +357,7 @@ def doxygen_build(app: Sphinx) -> None:
349357
app.config.doxyrunner_fmt,
350358
app.config.doxyrunner_fmt_pattern,
351359
app.config.doxyrunner_fmt_vars,
360+
app.config.doxyrunner_outdir_var,
352361
)
353362

354363
logger.info("Checking if Doxygen needs to be run...")
@@ -374,6 +383,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
374383
app.add_config_value("doxyrunner_doxygen", "doxygen", "env")
375384
app.add_config_value("doxyrunner_doxyfile", None, "env")
376385
app.add_config_value("doxyrunner_outdir", None, "env")
386+
app.add_config_value("doxyrunner_outdir_var", None, "env")
377387
app.add_config_value("doxyrunner_fmt", False, "env")
378388
app.add_config_value("doxyrunner_fmt_vars", {}, "env")
379389
app.add_config_value("doxyrunner_fmt_pattern", "@{}@", "env")

0 commit comments

Comments
 (0)