|
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 |
@@ -194,7 +196,7 @@ def process_doxyfile( |
194 | 196 | return content |
195 | 197 |
|
196 | 198 |
|
197 | | -def doxygen_input_has_changed(env: BuildEnvironment, doxyfile: str) -> bool: |
| 199 | +def doxygen_input_has_changed(env: BuildEnvironment, name, doxyfile: str) -> bool: |
198 | 200 | """Check if Doxygen input files have changed. |
199 | 201 |
|
200 | 202 | Args: |
@@ -225,12 +227,15 @@ def doxygen_input_has_changed(env: BuildEnvironment, doxyfile: str) -> bool: |
225 | 227 | for p_file in path.glob("**/" + pattern): |
226 | 228 | cache.add(hash_file(p_file)) |
227 | 229 |
|
| 230 | + if not hasattr(env, "doxyrunner_cache"): |
| 231 | + env.doxyrunner_cache = dict() |
| 232 | + |
228 | 233 | # check if any file has changed |
229 | | - if hasattr(env, "doxyrunner_cache") and env.doxyrunner_cache == cache: |
| 234 | + if env.doxyrunner_cache.get(name) == cache: |
230 | 235 | return False |
231 | 236 |
|
232 | 237 | # store current state |
233 | | - env.doxyrunner_cache = cache |
| 238 | + env.doxyrunner_cache[name] = cache |
234 | 239 |
|
235 | 240 | return True |
236 | 241 |
|
@@ -342,53 +347,52 @@ def doxygen_build(app: Sphinx) -> None: |
342 | 347 | app: Sphinx application instance. |
343 | 348 | """ |
344 | 349 |
|
345 | | - if app.config.doxyrunner_outdir: |
346 | | - outdir = Path(app.config.doxyrunner_outdir) |
347 | | - else: |
348 | | - outdir = Path(app.outdir) / "_doxygen" |
349 | | - |
350 | | - outdir.mkdir(exist_ok=True) |
351 | | - tmp_outdir = outdir / "tmp" |
352 | | - |
353 | | - logger.info("Preparing Doxyfile...") |
354 | | - doxyfile = process_doxyfile( |
355 | | - app.config.doxyrunner_doxyfile, |
356 | | - tmp_outdir, |
357 | | - app.config.doxyrunner_silent, |
358 | | - app.config.doxyrunner_fmt, |
359 | | - app.config.doxyrunner_fmt_pattern, |
360 | | - app.config.doxyrunner_fmt_vars, |
361 | | - app.config.doxyrunner_outdir_var, |
362 | | - ) |
| 350 | + for name, config in app.config.doxyrunner_projects.items(): |
| 351 | + if config.get("outdir"): |
| 352 | + outdir = Path(config["outdir"]) |
| 353 | + else: |
| 354 | + outdir = Path(app.outdir) / "_doxygen" / name |
363 | 355 |
|
364 | | - logger.info("Checking if Doxygen needs to be run...") |
365 | | - app.env.doxygen_input_changed = doxygen_input_has_changed(app.env, doxyfile) |
366 | | - if not app.env.doxygen_input_changed: |
367 | | - logger.info("Doxygen build will be skipped (no changes)!") |
368 | | - return |
369 | | - |
370 | | - logger.info("Running Doxygen...") |
371 | | - run_doxygen( |
372 | | - app.config.doxyrunner_doxygen, |
373 | | - doxyfile, |
374 | | - app.config.doxyrunner_silent, |
375 | | - ) |
| 356 | + outdir.mkdir(exist_ok=True) |
| 357 | + tmp_outdir = outdir / "tmp" |
| 358 | + |
| 359 | + logger.info("Preparing Doxyfile...") |
| 360 | + doxyfile = process_doxyfile( |
| 361 | + config["doxyfile"], |
| 362 | + tmp_outdir, |
| 363 | + app.config.doxyrunner_silent, |
| 364 | + config.get("fmt", False), |
| 365 | + config.get("fmt_pattern", "@{}@"), |
| 366 | + config.get("fmt_vars", {}), |
| 367 | + config.get("outdir_var"), |
| 368 | + ) |
| 369 | + |
| 370 | + logger.info(f"Checking if Doxygen needs to be run for {name}...") |
| 371 | + if not hasattr(app.env, "doxygen_input_changed"): |
| 372 | + app.env.doxygen_input_changed = dict() |
| 373 | + |
| 374 | + app.env.doxygen_input_changed[name] = doxygen_input_has_changed(app.env, name, doxyfile) |
| 375 | + if not app.env.doxygen_input_changed[name]: |
| 376 | + logger.info(f"Doxygen build for {name} will be skipped (no changes)!") |
| 377 | + return |
| 378 | + |
| 379 | + logger.info(f"Running Doxygen for {name}...") |
| 380 | + run_doxygen( |
| 381 | + app.config.doxyrunner_doxygen, |
| 382 | + doxyfile, |
| 383 | + app.config.doxyrunner_silent, |
| 384 | + ) |
376 | 385 |
|
377 | | - logger.info("Syncing Doxygen output...") |
378 | | - sync_doxygen(doxyfile, tmp_outdir, outdir) |
| 386 | + logger.info(f"Syncing Doxygen output for {name}...") |
| 387 | + sync_doxygen(doxyfile, tmp_outdir, outdir) |
379 | 388 |
|
380 | | - shutil.rmtree(tmp_outdir) |
| 389 | + shutil.rmtree(tmp_outdir) |
381 | 390 |
|
382 | 391 |
|
383 | 392 | def setup(app: Sphinx) -> Dict[str, Any]: |
384 | 393 | app.add_config_value("doxyrunner_doxygen", "doxygen", "env") |
385 | | - app.add_config_value("doxyrunner_doxyfile", None, "env") |
386 | | - app.add_config_value("doxyrunner_outdir", None, "env") |
387 | | - app.add_config_value("doxyrunner_outdir_var", None, "env") |
388 | | - app.add_config_value("doxyrunner_fmt", False, "env") |
389 | | - app.add_config_value("doxyrunner_fmt_vars", {}, "env") |
390 | | - app.add_config_value("doxyrunner_fmt_pattern", "@{}@", "env") |
391 | 394 | app.add_config_value("doxyrunner_silent", True, "") |
| 395 | + app.add_config_value("doxyrunner_projects", {}, "") |
392 | 396 |
|
393 | 397 | app.connect("builder-inited", doxygen_build) |
394 | 398 |
|
|
0 commit comments