From 85e3cb1b1d95ddb2a3077f83c8f720ae3c290d7b Mon Sep 17 00:00:00 2001
From: Campbell Barton <ideasman42@gmail.com>
Date: Wed, 12 Dec 2018 08:20:09 +1100
Subject: [PATCH] doxygen_single_file: utility to build doxygen for one file

Building all doxygen docs takes a long time,
while this will miss inter-file references, it's useful to check basic
formatting is correct.
---
 utils_docs/doxygen_single_file | 43 ++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100755 utils_docs/doxygen_single_file

diff --git a/utils_docs/doxygen_single_file b/utils_docs/doxygen_single_file
new file mode 100755
index 0000000..b3a4a6e
--- /dev/null
+++ b/utils_docs/doxygen_single_file
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+"""
+This script takes 2-3 args: [--browse] <Doxyfile> <sourcefile>
+
+Where Doxyfile is a path relative to source root,
+and the sourcefile as an absolute path.
+
+--browse will open the resulting docs in a web browser.
+"""
+import sys
+import os
+import subprocess
+import tempfile
+
+print(sys.argv)
+
+def find_gitroot(filepath_reference):
+    path = filepath_reference
+    path_prev = ""
+    while not os.path.exists(os.path.join(path, ".git")) and path != path_prev:
+        path_prev = path
+        path = os.path.dirname(path)
+    return path
+
+doxyfile, sourcefile = sys.argv[-2:]
+
+doxyfile = os.path.join(find_gitroot(sourcefile), doxyfile)
+os.chdir(os.path.dirname(doxyfile))
+
+tempfile = tempfile.NamedTemporaryFile(mode='w+b')
+doxyfile_tmp = tempfile.name
+tempfile.write(open(doxyfile, "r+b").read())
+tempfile.write(b'\n\n')
+tempfile.write(b'INPUT=' + os.fsencode(sourcefile) + b'\n')
+tempfile.flush()
+
+subprocess.call(("doxygen", doxyfile_tmp))
+del tempfile
+
+# Maybe handy, but also annoying?
+if "--browse" in sys.argv:
+    import webbrowser
+    webbrowser.open("html/files.html")
-- 
GitLab