From: Vladimír Vondruš Date: Mon, 29 Jan 2018 18:39:17 +0000 (+0100) Subject: doxygen: don't die if a page doesn't have a title. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=721cd67e021faea8f193f771469e0407e3410827;p=blog.git doxygen: don't die if a page doesn't have a title. But use its name instead. --- diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 20bfb11d..ef5d93ac 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -1345,7 +1345,7 @@ def extract_metadata(state: State, xml): compound.kind = compounddef.attrib['kind'] # 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'] else compounddef.find('compoundname').text) + 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.brief = parse_desc(state, compounddef.find('briefdescription')) # Groups are explicitly created so they *have details*, other things need @@ -1541,7 +1541,7 @@ def parse_xml(state: State, xml: str): compound.id = compounddef.attrib['id'] # Compound name is page filename, so we have to use title there. The same # is for groups. - compound.name = compounddef.find('title').text if compound.kind in ['page', 'group'] else compounddef.find('compoundname').text + compound.name = compounddef.find('title').text if compound.kind in ['page', 'group'] and compounddef.findtext('title') else compounddef.find('compoundname').text # Compound URL is ID, except for index page compound.url = (compounddef.find('compoundname').text if compound.kind == 'page' else compound.id) + '.html' compound.has_template_details = False diff --git a/doxygen/test/page_empty_title/Doxyfile b/doxygen/test/page_empty_title/Doxyfile new file mode 100644 index 00000000..d572a12f --- /dev/null +++ b/doxygen/test/page_empty_title/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_empty_title/input.dox b/doxygen/test/page_empty_title/input.dox new file mode 100644 index 00000000..2236c91d --- /dev/null +++ b/doxygen/test/page_empty_title/input.dox @@ -0,0 +1,4 @@ +/** @page untitled + +An untitled page. +*/ diff --git a/doxygen/test/page_empty_title/untitled.html b/doxygen/test/page_empty_title/untitled.html new file mode 100644 index 00000000..74861629 --- /dev/null +++ b/doxygen/test/page_empty_title/untitled.html @@ -0,0 +1,31 @@ + + + + + untitled | My Project + + + + + +
+
+
+
+
+

+ untitled +

+

An untitled page.

+
+
+
+
+ + diff --git a/doxygen/test/test_page.py b/doxygen/test/test_page.py index 437fea55..1d4de89e 100644 --- a/doxygen/test/test_page.py +++ b/doxygen/test/test_page.py @@ -83,3 +83,11 @@ class EmptyIndex(IntegrationTestCase): def test(self): self.run_dox2html5(wildcard='indexpage.xml') self.assertEqual(*self.actual_expected_contents('index.html')) + +class EmptyTitle(IntegrationTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'empty_title', *args, **kwargs) + + def test(self): + self.run_dox2html5(wildcard='untitled.xml') + self.assertEqual(*self.actual_expected_contents('untitled.html'))