From f2ea2cd2699a9ca0e455fbd1dc81e4bb7c190c63 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 7 May 2020 21:00:38 +0200 Subject: [PATCH] documentation/doxygen: create the output dir because Doxygen is stupid. It can't create nested directories. --- documentation/doxygen.py | 17 +++++++++++------ documentation/test_doxygen/__init__.py | 6 ++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/documentation/doxygen.py b/documentation/doxygen.py index 975b15a3..a0830be4 100755 --- a/documentation/doxygen.py +++ b/documentation/doxygen.py @@ -3303,6 +3303,8 @@ def parse_index_xml(state: State, xml): return parsed def parse_doxyfile(state: State, doxyfile, config = None): + state.basedir = os.path.dirname(doxyfile) + logging.debug("Parsing configuration from {}".format(doxyfile)) comment_re = re.compile(r"""^\s*(#.*)?$""") @@ -3492,11 +3494,7 @@ default_index_pages = ['pages', 'files', 'namespaces', 'modules', 'annotated'] default_wildcard = '*.xml' default_templates = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'templates/doxygen/') -def run(doxyfile, *, templates=default_templates, wildcard=default_wildcard, index_pages=default_index_pages, search_add_lookahead_barriers=True, search_merge_subtrees=True, search_merge_prefixes=True, sort_globbed_files=False): - state = State() - state.basedir = os.path.dirname(doxyfile) - - parse_doxyfile(state, doxyfile) +def run(state: State, *, templates=default_templates, wildcard=default_wildcard, index_pages=default_index_pages, search_add_lookahead_barriers=True, search_merge_subtrees=True, search_merge_prefixes=True, sort_globbed_files=False): xml_input = os.path.join(state.basedir, state.doxyfile['OUTPUT_DIRECTORY'], state.doxyfile['XML_OUTPUT']) xml_files_metadata = [os.path.join(xml_input, f) for f in glob.glob(os.path.join(xml_input, "*.xml"))] xml_files = [os.path.join(xml_input, f) for f in glob.glob(os.path.join(xml_input, wildcard))] @@ -3691,8 +3689,15 @@ if __name__ == '__main__': # pragma: no cover # Make the Doxyfile path absolute, otherwise everything gets messed up doxyfile = os.path.abspath(args.doxyfile) + state = State() + parse_doxyfile(state, doxyfile) + + # Doxygen is stupid and can't create nested directories, create the input + # directory for it + os.makedirs(state.doxyfile['OUTPUT_DIRECTORY'], exist_ok=True) + if not args.no_doxygen: logging.debug("running Doxygen on {}".format(args.doxyfile)) subprocess.run(["doxygen", doxyfile], cwd=os.path.dirname(doxyfile)) - run(doxyfile, templates=os.path.abspath(args.templates), wildcard=args.wildcard, index_pages=args.index_pages, search_merge_subtrees=not args.search_no_subtree_merging, search_add_lookahead_barriers=not args.search_no_lookahead_barriers, search_merge_prefixes=not args.search_no_prefix_merging) + run(state, templates=os.path.abspath(args.templates), wildcard=args.wildcard, index_pages=args.index_pages, search_merge_subtrees=not args.search_no_subtree_merging, search_add_lookahead_barriers=not args.search_no_lookahead_barriers, search_merge_prefixes=not args.search_no_prefix_merging) diff --git a/documentation/test_doxygen/__init__.py b/documentation/test_doxygen/__init__.py index 24fd4948..ae2dd579 100644 --- a/documentation/test_doxygen/__init__.py +++ b/documentation/test_doxygen/__init__.py @@ -27,7 +27,7 @@ import shutil import subprocess import unittest -from doxygen import run, default_templates, default_wildcard, default_index_pages +from doxygen import State, parse_doxyfile, run, default_templates, default_wildcard, default_index_pages def doxygen_version(): return subprocess.check_output(['doxygen', '-v']).decode('utf-8').strip() @@ -45,7 +45,9 @@ class BaseTestCase(unittest.TestCase): if os.path.exists(os.path.join(self.path, 'html')): shutil.rmtree(os.path.join(self.path, 'html')) def run_doxygen(self, templates=default_templates, wildcard=default_wildcard, index_pages=default_index_pages): - run(os.path.join(self.path, 'Doxyfile'), templates=templates, wildcard=wildcard, index_pages=index_pages, sort_globbed_files=True) + state = State() + parse_doxyfile(state, os.path.join(self.path, 'Doxyfile')) + run(state, templates=templates, wildcard=wildcard, index_pages=index_pages, sort_globbed_files=True) def actual_expected_contents(self, actual, expected = None): if not expected: expected = actual -- 2.30.2