From 4f2e7685720d825b41ab899003e78643daafa7a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 29 Jan 2018 23:46:10 +0100 Subject: [PATCH] doxygen: fix case where pages are subpages of index. Avoid the assertion, include the index page in the page tree and link to index.html instead of indexpage.html. --- doxygen/dox2html5.py | 13 +++-- doxygen/test/page_subpage_of_index/Doxyfile | 11 ++++ doxygen/test/page_subpage_of_index/input.dox | 9 ++++ doxygen/test/page_subpage_of_index/page.html | 32 ++++++++++++ doxygen/test/page_subpage_of_index/pages.html | 51 +++++++++++++++++++ doxygen/test/test_page.py | 9 ++++ 6 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 doxygen/test/page_subpage_of_index/Doxyfile create mode 100644 doxygen/test/page_subpage_of_index/input.dox create mode 100644 doxygen/test/page_subpage_of_index/page.html create mode 100644 doxygen/test/page_subpage_of_index/pages.html diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index ef5d93ac..81e6d2a7 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -1346,7 +1346,8 @@ def extract_metadata(state: State, xml): # Compound name is page filename, so we have to use title there. The same # is for groups. compound.name = html.escape(compounddef.find('title').text if compound.kind in ['page', 'group'] and compounddef.findtext('title') else compounddef.find('compoundname').text) - compound.url = compound.id + '.html' + # Compound URL is ID, except for index page + compound.url = (compounddef.find('compoundname').text if compound.kind == 'page' else compound.id) + '.html' compound.brief = parse_desc(state, compounddef.find('briefdescription')) # Groups are explicitly created so they *have details*, other things need # to have at least some documentation @@ -2120,9 +2121,9 @@ def parse_index_xml(state: State, xml): top_level_files += [entry] else: assert compound.kind == 'page' - # Ignore index page in page listing - if entry.id == 'indexpage': continue - top_level_pages += [entry] + # Ignore index page in page listing, add it later only if it + # has children + if entry.id != 'indexpage': top_level_pages += [entry] # Otherwise put it into orphan map else: @@ -2172,6 +2173,10 @@ def parse_index_xml(state: State, xml): for parent, children in orphans.items(): if parent in entries: entries[parent].children += children + # Add the index page if it has children + if 'indexpage' in entries and entries['indexpage'].children: + parsed.index.pages = [entries['indexpage']] + parsed.index.pages + return parsed def parse_doxyfile(state: State, doxyfile, config = None): diff --git a/doxygen/test/page_subpage_of_index/Doxyfile b/doxygen/test/page_subpage_of_index/Doxyfile new file mode 100644 index 00000000..d572a12f --- /dev/null +++ b/doxygen/test/page_subpage_of_index/Doxyfile @@ -0,0 +1,11 @@ +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 = +M_SEARCH_DISABLED = YES diff --git a/doxygen/test/page_subpage_of_index/input.dox b/doxygen/test/page_subpage_of_index/input.dox new file mode 100644 index 00000000..8d432684 --- /dev/null +++ b/doxygen/test/page_subpage_of_index/input.dox @@ -0,0 +1,9 @@ +/** @mainpage + +- @subpage page +*/ + +/** @page page A page + +A page +*/ diff --git a/doxygen/test/page_subpage_of_index/page.html b/doxygen/test/page_subpage_of_index/page.html new file mode 100644 index 00000000..ed4c137f --- /dev/null +++ b/doxygen/test/page_subpage_of_index/page.html @@ -0,0 +1,32 @@ + + + + + My Project » A page | My Project + + + + + +
+
+
+
+
+

+ My Project » + A page +

+

A page

+
+
+
+
+ + diff --git a/doxygen/test/page_subpage_of_index/pages.html b/doxygen/test/page_subpage_of_index/pages.html new file mode 100644 index 00000000..49178acf --- /dev/null +++ b/doxygen/test/page_subpage_of_index/pages.html @@ -0,0 +1,51 @@ + + + + + My Project + + + + + +
+
+
+
+
+

Pages

+ + +
+
+
+
+ + diff --git a/doxygen/test/test_page.py b/doxygen/test/test_page.py index 1d4de89e..999041d6 100644 --- a/doxygen/test/test_page.py +++ b/doxygen/test/test_page.py @@ -91,3 +91,12 @@ class EmptyTitle(IntegrationTestCase): def test(self): self.run_dox2html5(wildcard='untitled.xml') self.assertEqual(*self.actual_expected_contents('untitled.html')) + +class SubpageOfIndex(IntegrationTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'subpage_of_index', *args, **kwargs) + + def test(self): + self.run_dox2html5(wildcard='*.xml') + self.assertEqual(*self.actual_expected_contents('page.html')) + self.assertEqual(*self.actual_expected_contents('pages.html')) -- 2.30.2