chiark / gitweb /
doxygen: generate empty index page in case nothing is supplied for it.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 29 Jan 2018 16:27:13 +0000 (17:27 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 29 Jan 2018 17:51:45 +0000 (18:51 +0100)
So the documentation has some entry point.

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

index a7b6168cfb07fa0dd024c2c4cb6069ec92e682da..f55676b782d783347576c829569e40096cb3cf2d 100755 (executable)
@@ -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 (file)
index 0000000..6458538
--- /dev/null
@@ -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 (file)
index 0000000..7593bd3
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>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>
+          My Project
+        </h1>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
diff --git a/doxygen/test/page_empty_index/input.dox b/doxygen/test/page_empty_index/input.dox
new file mode 100644 (file)
index 0000000..e69de29
index fbcb4a51811e0174b8a0681f3ceb1692e897f093..437fea555a391fc4499d1f09ca24a9510e71c5b4 100644 (file)
@@ -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'))