summaryrefslogtreecommitdiff
path: root/doc/preprocess.py
diff options
context:
space:
mode:
authorSayantika Banik <sayantikabanik122@gmail.com>2021-09-08 06:21:36 +0000
committerSayantika Banik <sayantikabanik122@gmail.com>2021-09-08 06:21:36 +0000
commit879b3b4798975c7c0c49cef6ece3563c5f2daaeb (patch)
treee102f2222f1557d9b4f8b1a3e9484ca59b8ad954 /doc/preprocess.py
parent9680d760cdb08cc54c18657c77269853670f17e9 (diff)
parent17c3a6b414a3e642abeb116ff71e97f9b6f2aab5 (diff)
downloadnumpy-879b3b4798975c7c0c49cef6ece3563c5f2daaeb.tar.gz
Merge branch 'main' of https://github.com/sayantikabanik/numpy
Diffstat (limited to 'doc/preprocess.py')
-rwxr-xr-xdoc/preprocess.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/doc/preprocess.py b/doc/preprocess.py
new file mode 100755
index 000000000..e88d9608e
--- /dev/null
+++ b/doc/preprocess.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+import subprocess
+import os
+import sys
+from string import Template
+
+def main():
+ doxy_gen(os.path.abspath(os.path.join('..')))
+
+def doxy_gen(root_path):
+ """
+ Generate Doxygen configration file.
+ """
+ confs = doxy_config(root_path)
+ build_path = os.path.join(root_path, "doc", "build", "doxygen")
+ gen_path = os.path.join(build_path, "Doxyfile")
+ if not os.path.exists(build_path):
+ os.makedirs(build_path)
+ with open(gen_path, 'w') as fd:
+ fd.write("#Please Don't Edit! This config file was autogenerated by ")
+ fd.write(f"doxy_gen({root_path}) in doc/preprocess.py.\n")
+ for c in confs:
+ fd.write(c)
+
+class DoxyTpl(Template):
+ delimiter = '@'
+
+def doxy_config(root_path):
+ """
+ Fetch all Doxygen sub-config files and gather it with the main config file.
+ """
+ confs = []
+ dsrc_path = os.path.join(root_path, "doc", "source")
+ sub = dict(ROOT_DIR=root_path)
+ with open(os.path.join(dsrc_path, "doxyfile"), "r") as fd:
+ conf = DoxyTpl(fd.read())
+ confs.append(conf.substitute(CUR_DIR=dsrc_path, **sub))
+
+ for dpath, _, files in os.walk(root_path):
+ if ".doxyfile" not in files:
+ continue
+ conf_path = os.path.join(dpath, ".doxyfile")
+ with open(conf_path, "r") as fd:
+ conf = DoxyTpl(fd.read())
+ confs.append(conf.substitute(CUR_DIR=dpath, **sub))
+ return confs
+
+
+if __name__ == "__main__":
+ main()
+