From: Vladimír Vondruš Date: Mon, 29 Jan 2018 16:27:13 +0000 (+0100) Subject: doxygen: generate empty index page in case nothing is supplied for it. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=3013648667c059610f2706003526c753f33a8a4a;p=blog.git doxygen: generate empty index page in case nothing is supplied for it. So the documentation has some entry point. --- diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index a7b6168c..f55676b7 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -2099,6 +2099,24 @@ def run(doxyfile, templates=default_templates, wildcard=default_wildcard, index_ with open(output, 'w') as f: f.write(rendered) + # Empty index page in case no mainpage documentation was provided so + # there's at least some entrypoint. Doxygen version is not set in this + # case, as this is totally without Doxygen involvement. + if not os.path.join(xml_input, 'indexpage.xml') in xml_files_metadata: + compound = Empty() + compound.kind = 'page' + compound.name = state.doxyfile['PROJECT_NAME'] + compound.description = '' + compound.breadcrumb = [(state.doxyfile['PROJECT_NAME'], 'index.html')] + template = env.get_template('page.html') + rendered = template.render(compound=compound, + DOXYGEN_VERSION='0', + FILENAME='index.html', + **state.doxyfile) + output = os.path.join(html_output, 'index.html') + with open(output, 'w') as f: + f.write(rendered) + # Copy all referenced files, skip absolute URLs for i in state.images + state.doxyfile['HTML_EXTRA_STYLESHEET'] + state.doxyfile['HTML_EXTRA_FILES']: if urllib.parse.urlparse(i).netloc: continue diff --git a/doxygen/test/page_empty_index/Doxyfile b/doxygen/test/page_empty_index/Doxyfile new file mode 100644 index 00000000..64585384 --- /dev/null +++ b/doxygen/test/page_empty_index/Doxyfile @@ -0,0 +1,10 @@ +INPUT = input.dox +QUIET = YES +GENERATE_HTML = NO +GENERATE_LATEX = NO +GENERATE_XML = YES + +M_PAGE_FINE_PRINT = +M_THEME_COLOR = +M_LINKS_NAVBAR1 = +M_LINKS_NAVBAR2 = diff --git a/doxygen/test/page_empty_index/index.html b/doxygen/test/page_empty_index/index.html new file mode 100644 index 00000000..7593bd33 --- /dev/null +++ b/doxygen/test/page_empty_index/index.html @@ -0,0 +1,30 @@ + + + + + My Project + + + + + +
+
+
+
+
+

+ My Project +

+
+
+
+
+ + diff --git a/doxygen/test/page_empty_index/input.dox b/doxygen/test/page_empty_index/input.dox new file mode 100644 index 00000000..e69de29b diff --git a/doxygen/test/test_page.py b/doxygen/test/test_page.py index fbcb4a51..437fea55 100644 --- a/doxygen/test/test_page.py +++ b/doxygen/test/test_page.py @@ -75,3 +75,11 @@ class FooterNavigation(IntegrationTestCase): self.run_dox2html5(wildcard='subpage*.xml') self.assertEqual(*self.actual_expected_contents('subpage1.html')) self.assertEqual(*self.actual_expected_contents('subpage2.html')) + +class EmptyIndex(IntegrationTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'empty_index', *args, **kwargs) + + def test(self): + self.run_dox2html5(wildcard='indexpage.xml') + self.assertEqual(*self.actual_expected_contents('index.html'))