|
28 | 28 | =====================
|
29 | 29 |
|
30 | 30 | - ``doxyrunner_doxygen``: Path to the Doxygen binary.
|
31 |
| -- ``doxyrunner_doxyfile``: Path to Doxyfile. |
32 |
| -- ``doxyrunner_outdir``: Doxygen build output directory (inserted to |
33 |
| - ``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. |
37 |
| -- ``doxyrunner_fmt``: Flag to indicate if Doxyfile should be formatted. |
38 |
| -- ``doxyrunner_fmt_vars``: Format variables dictionary (name: value). |
39 |
| -- ``doxyrunner_fmt_pattern``: Format pattern. |
40 | 31 | - ``doxyrunner_silent``: If Doxygen output should be logged or not. Note that
|
41 | 32 | this option may not have any effect if ``QUIET`` is set to ``YES``.
|
| 33 | +- ``doxyrunner_projects``: Dictionary specifying projects, keys being project |
| 34 | + name and values a dictionary with the following keys: |
| 35 | +
|
| 36 | + - ``doxyfile``: Path to Doxyfile. |
| 37 | + - ``outdir``: Doxygen build output directory (inserted to ``OUTPUT_DIRECTORY``) |
| 38 | + - ``outdir_var``: Variable representing the Doxygen build output directory, |
| 39 | + as used by ``OUTPUT_DIRECTORY``. This can be useful if other Doxygen |
| 40 | + variables reference to the output directory. |
| 41 | + - ``fmt``: Flag to indicate if Doxyfile should be formatted. |
| 42 | + - ``fmt_vars``: Format variables dictionary (name: value). |
| 43 | + - ``fmt_pattern``: Format pattern. |
42 | 44 | """
|
43 | 45 |
|
44 | 46 | import filecmp
|
@@ -193,7 +195,7 @@ def process_doxyfile(
|
193 | 195 | return content
|
194 | 196 |
|
195 | 197 |
|
196 |
| -def doxygen_input_has_changed(env: BuildEnvironment, doxyfile: str) -> bool: |
| 198 | +def doxygen_input_has_changed(env: BuildEnvironment, name, doxyfile: str) -> bool: |
197 | 199 | """Check if Doxygen input files have changed.
|
198 | 200 |
|
199 | 201 | Args:
|
@@ -224,12 +226,15 @@ def doxygen_input_has_changed(env: BuildEnvironment, doxyfile: str) -> bool:
|
224 | 226 | for p_file in path.glob("**/" + pattern):
|
225 | 227 | cache.add(hash_file(p_file))
|
226 | 228 |
|
| 229 | + if not hasattr(env, "doxyrunner_cache"): |
| 230 | + env.doxyrunner_cache = dict() |
| 231 | + |
227 | 232 | # check if any file has changed
|
228 |
| - if hasattr(env, "doxyrunner_cache") and env.doxyrunner_cache == cache: |
| 233 | + if env.doxyrunner_cache.get(name) == cache: |
229 | 234 | return False
|
230 | 235 |
|
231 | 236 | # store current state
|
232 |
| - env.doxyrunner_cache = cache |
| 237 | + env.doxyrunner_cache[name] = cache |
233 | 238 |
|
234 | 239 | return True
|
235 | 240 |
|
@@ -341,53 +346,52 @@ def doxygen_build(app: Sphinx) -> None:
|
341 | 346 | app: Sphinx application instance.
|
342 | 347 | """
|
343 | 348 |
|
344 |
| - if app.config.doxyrunner_outdir: |
345 |
| - outdir = Path(app.config.doxyrunner_outdir) |
346 |
| - else: |
347 |
| - outdir = Path(app.outdir) / "_doxygen" |
348 |
| - |
349 |
| - outdir.mkdir(exist_ok=True) |
350 |
| - tmp_outdir = outdir / "tmp" |
351 |
| - |
352 |
| - logger.info("Preparing Doxyfile...") |
353 |
| - doxyfile = process_doxyfile( |
354 |
| - app.config.doxyrunner_doxyfile, |
355 |
| - tmp_outdir, |
356 |
| - app.config.doxyrunner_silent, |
357 |
| - app.config.doxyrunner_fmt, |
358 |
| - app.config.doxyrunner_fmt_pattern, |
359 |
| - app.config.doxyrunner_fmt_vars, |
360 |
| - app.config.doxyrunner_outdir_var, |
361 |
| - ) |
| 349 | + for name, config in app.config.doxyrunner_projects.items(): |
| 350 | + if config.get("outdir"): |
| 351 | + outdir = Path(config["outdir"]) |
| 352 | + else: |
| 353 | + outdir = Path(app.outdir) / "_doxygen" / name |
362 | 354 |
|
363 |
| - logger.info("Checking if Doxygen needs to be run...") |
364 |
| - app.env.doxygen_input_changed = doxygen_input_has_changed(app.env, doxyfile) |
365 |
| - if not app.env.doxygen_input_changed: |
366 |
| - logger.info("Doxygen build will be skipped (no changes)!") |
367 |
| - return |
368 |
| - |
369 |
| - logger.info("Running Doxygen...") |
370 |
| - run_doxygen( |
371 |
| - app.config.doxyrunner_doxygen, |
372 |
| - doxyfile, |
373 |
| - app.config.doxyrunner_silent, |
374 |
| - ) |
| 355 | + outdir.mkdir(exist_ok=True) |
| 356 | + tmp_outdir = outdir / "tmp" |
| 357 | + |
| 358 | + logger.info("Preparing Doxyfile...") |
| 359 | + doxyfile = process_doxyfile( |
| 360 | + config["doxyfile"], |
| 361 | + tmp_outdir, |
| 362 | + app.config.doxyrunner_silent, |
| 363 | + config.get("fmt", False), |
| 364 | + config.get("fmt_pattern", "@{}@"), |
| 365 | + config.get("fmt_vars", {}), |
| 366 | + config.get("outdir_var"), |
| 367 | + ) |
| 368 | + |
| 369 | + logger.info(f"Checking if Doxygen needs to be run for {name}...") |
| 370 | + if not hasattr(app.env, "doxygen_input_changed"): |
| 371 | + app.env.doxygen_input_changed = dict() |
| 372 | + |
| 373 | + app.env.doxygen_input_changed[name] = doxygen_input_has_changed(app.env, name, doxyfile) |
| 374 | + if not app.env.doxygen_input_changed[name]: |
| 375 | + logger.info(f"Doxygen build for {name} will be skipped (no changes)!") |
| 376 | + return |
| 377 | + |
| 378 | + logger.info(f"Running Doxygen for {name}...") |
| 379 | + run_doxygen( |
| 380 | + app.config.doxyrunner_doxygen, |
| 381 | + doxyfile, |
| 382 | + app.config.doxyrunner_silent, |
| 383 | + ) |
375 | 384 |
|
376 |
| - logger.info("Syncing Doxygen output...") |
377 |
| - sync_doxygen(doxyfile, tmp_outdir, outdir) |
| 385 | + logger.info(f"Syncing Doxygen output for {name}...") |
| 386 | + sync_doxygen(doxyfile, tmp_outdir, outdir) |
378 | 387 |
|
379 |
| - shutil.rmtree(tmp_outdir) |
| 388 | + shutil.rmtree(tmp_outdir) |
380 | 389 |
|
381 | 390 |
|
382 | 391 | def setup(app: Sphinx) -> dict[str, Any]:
|
383 | 392 | app.add_config_value("doxyrunner_doxygen", "doxygen", "env")
|
384 |
| - app.add_config_value("doxyrunner_doxyfile", None, "env") |
385 |
| - app.add_config_value("doxyrunner_outdir", None, "env") |
386 |
| - app.add_config_value("doxyrunner_outdir_var", None, "env") |
387 |
| - app.add_config_value("doxyrunner_fmt", False, "env") |
388 |
| - app.add_config_value("doxyrunner_fmt_vars", {}, "env") |
389 |
| - app.add_config_value("doxyrunner_fmt_pattern", "@{}@", "env") |
390 | 393 | app.add_config_value("doxyrunner_silent", True, "")
|
| 394 | + app.add_config_value("doxyrunner_projects", {}, "") |
391 | 395 |
|
392 | 396 | app.connect("builder-inited", doxygen_build)
|
393 | 397 |
|
|
0 commit comments