chiark / gitweb /
doxygen: don't die if a page doesn't have a title.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 29 Jan 2018 18:39:17 +0000 (19:39 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 3 Feb 2018 09:51:55 +0000 (10:51 +0100)
But use its name instead.

doxygen/dox2html5.py
doxygen/test/page_empty_title/Doxyfile [new file with mode: 0644]
doxygen/test/page_empty_title/input.dox [new file with mode: 0644]
doxygen/test/page_empty_title/untitled.html [new file with mode: 0644]
doxygen/test/test_page.py

index 20bfb11d3a1f2010c6da7f8d8e202ad05503faa7..ef5d93acd1b21197fd573bae588e0154651bb3f5 100755 (executable)
@@ -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 (file)
index 0000000..d572a12
--- /dev/null
@@ -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 (file)
index 0000000..2236c91
--- /dev/null
@@ -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 (file)
index 0000000..7486162
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>untitled | My Project</title>
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+  <link rel="stylesheet" href="m-dark+doxygen.compiled.css" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+  <div class="m-container">
+    <div class="m-row">
+      <a href="index.html" id="m-navbar-brand" class="m-col-t-9 m-col-m-none m-left-m">My Project</a>
+    </div>
+  </div>
+</nav></header>
+<main><article>
+  <div class="m-container m-container-inflatable">
+    <div class="m-row">
+      <div class="m-col-l-10 m-push-l-1">
+        <h1>
+          untitled
+        </h1>
+<p>An untitled page.</p>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
index 437fea555a391fc4499d1f09ca24a9510e71c5b4..1d4de89e80246bec8711cd9d23c02fbbdd2fce3f 100644 (file)
@@ -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'))