JakubAndrysek / MkDoxy

📖 Automatically generates API documentation for your project based on Doxygen comments and code snippets in your markdown files.
https://mkdoxy.kubaandrysek.cz/
MIT License
60 stars 16 forks source link

Compile Database #92

Open ciscoski opened 3 months ago

ciscoski commented 3 months ago

Hello all,

How hard would it be to add an option to the plugin to injest compilation database?

I would like to use this tool to generate documentation in a repo with multiple target which are highly dependant from the compilation configuration and this would help a lot.

Thanks

Nerixyz commented 1 month ago

This could be "solved" if there was an option to specify a directory with the generated XML (and not run doxygen in that case):

diff --git a/mkdoxy/plugin.py b/mkdoxy/plugin.py
index a005b2d..37004e9 100644
--- a/mkdoxy/plugin.py
+++ b/mkdoxy/plugin.py
@@ -44,6 +44,7 @@ class MkDoxy(BasePlugin):
     # Config options for each project
     config_project = (
         ("src-dirs", config_options.Type(str)),
+        ("doxy-dir", config_options.Type(str, default="", required=False)),
         ("full-doc", config_options.Type(bool, default=True)),
         ("debug", config_options.Type(bool, default=False)),
         # ('ignore-errors', config_options.Type(bool, default=False)),
@@ -112,25 +113,30 @@ class MkDoxy(BasePlugin):
             else:
                 tempDirApi = tempDir(config["site_dir"], "assets/.doxy/", project_name)

-            # Check src changes -> run Doxygen
-            doxygenRun = DoxygenRun(
-                self.config["doxygen-bin-path"],
-                project_data.get("src-dirs"),
-                tempDirApi,
-                project_data.get("doxy-cfg", {}),
-                project_data.get("doxy-cfg-file", ""),
-            )
-            if doxygenRun.checkAndRun():
-                log.info("  -> generating Doxygen files")
+            doxyXmlDir = project_data.get("doxy-dir")
+            if doxyXmlDir:
+                doxyXmlDir = PurePath(doxyXmlDir)
             else:
-                log.info("  -> skip generating Doxygen files (nothing changes)")
+                # Check src changes -> run Doxygen
+                doxygenRun = DoxygenRun(
+                    self.config["doxygen-bin-path"],
+                    project_data.get("src-dirs"),
+                    tempDirApi,
+                    project_data.get("doxy-cfg", {}),
+                    project_data.get("doxy-cfg-file", ""),
+                )
+                if doxygenRun.checkAndRun():
+                    log.info("  -> generating Doxygen files")
+                else:
+                    log.info("  -> skip generating Doxygen files (nothing changes)")
+                doxyXmlDir = doxygenRun.getOutputFolder()

             # Parse XML to basic structure
             cache = Cache()
             parser = XmlParser(cache=cache, debug=self.debug)

             # Parse basic structure to recursive Nodes
-            self.doxygen[project_name] = Doxygen(doxygenRun.getOutputFolder(), parser=parser, cache=cache)
+            self.doxygen[project_name] = Doxygen(str(doxyXmlDir), parser=parser, cache=cache)

             # Print parsed files
             if self.debug: