chiark / gitweb /
doxygen: fall back to the default template location from --template.
authorVladimír Vondruš <mosra@centrum.cz>
Sat, 23 Feb 2019 00:31:15 +0000 (01:31 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 23 Feb 2019 00:38:11 +0000 (01:38 +0100)
So people don't need to provide the whole copy, just the modified files.

doxygen/dox2html5.py
doxygen/test/layout_template_fallback/Doxyfile [new file with mode: 0644]
doxygen/test/layout_template_fallback/index.html [new file with mode: 0644]
doxygen/test/layout_template_fallback/indexpage.xml [new file with mode: 0644]
doxygen/test/layout_template_fallback/page.html [new file with mode: 0644]
doxygen/test/test_layout.py

index 2ec89c44b7629a95e7141b2cc17922ba7d25a513..237797a655be59db12b3d571d39167a3432375f6 100755 (executable)
@@ -3458,7 +3458,11 @@ def run(doxyfile, templates=default_templates, wildcard=default_wildcard, index_
     if not os.path.exists(html_output):
         os.makedirs(html_output)
 
-    env = Environment(loader=FileSystemLoader(templates),
+    # If custom template dir was supplied, use the default template directory
+    # as a fallback
+    template_paths = [templates]
+    if templates != default_templates: template_paths += [default_templates]
+    env = Environment(loader=FileSystemLoader(template_paths),
                       trim_blocks=True, lstrip_blocks=True, enable_async=True)
 
     # Filter to return file basename or the full URL, if absolute
diff --git a/doxygen/test/layout_template_fallback/Doxyfile b/doxygen/test/layout_template_fallback/Doxyfile
new file mode 100644 (file)
index 0000000..3d1b982
--- /dev/null
@@ -0,0 +1,8 @@
+XML_OUTPUT              =
+
+##! M_LINKS_NAVBAR1     =
+##! M_LINKS_NAVBAR2     =
+##! M_PAGE_FINE_PRINT   =
+##! M_THEME_COLOR       =
+##! M_FAVICON           =
+##! M_SEARCH_DISABLED   = YES
diff --git a/doxygen/test/layout_template_fallback/index.html b/doxygen/test/layout_template_fallback/index.html
new file mode 100644 (file)
index 0000000..e06469c
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>HELLO THIS TEMPLATE OVERRIDES THINGS</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-8 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>HELLO THIS TEMPLATE OVERRIDES THINGS</h1>
+        <p>But not all, the base.html is taken from the fallback.</p>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
diff --git a/doxygen/test/layout_template_fallback/indexpage.xml b/doxygen/test/layout_template_fallback/indexpage.xml
new file mode 100644 (file)
index 0000000..fa7a2a8
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='UTF-8' standalone='no'?>
+<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.14">
+  <compounddef id="indexpage" kind="page">
+    <compoundname>index</compoundname>
+    <title>My Project</title>
+    <briefdescription>
+    </briefdescription>
+    <detaileddescription>
+    </detaileddescription>
+  </compounddef>
+</doxygen>
diff --git a/doxygen/test/layout_template_fallback/page.html b/doxygen/test/layout_template_fallback/page.html
new file mode 100644 (file)
index 0000000..9839469
--- /dev/null
@@ -0,0 +1,14 @@
+{% extends 'base.html' %}
+
+{% block title %}HELLO THIS TEMPLATE OVERRIDES THINGS{% endblock %}
+
+{% block main %}
+        <h1>HELLO THIS TEMPLATE OVERRIDES THINGS</h1>
+        {% if compound.brief %}
+        <p>{{ compound.brief }}</p>
+        {% endif %}
+        <p>But not all, the base.html is taken from the fallback.</p>
+        {% if compound.description %}
+{{ compound.description }}
+        {% endif %}
+{% endblock %}
index a7a32b7221adf73ce97be43831e0806443c96ae9..2742df78a023fbe307377a2997496dc8bf43b6d3 100644 (file)
@@ -59,6 +59,14 @@ class Minimal(BaseTestCase):
         self.run_dox2html5(wildcard='indexpage.xml')
         self.assertEqual(*self.actual_expected_contents('index.html'))
 
+class TemplateFallback(BaseTestCase):
+    def __init__(self, *args, **kwargs):
+        super().__init__(__file__, 'template_fallback', *args, **kwargs)
+
+    def test(self):
+        self.run_dox2html5(templates=self.path, wildcard='indexpage.xml')
+        self.assertEqual(*self.actual_expected_contents('index.html'))
+
 class NavbarSingleColumn(BaseTestCase):
     def __init__(self, *args, **kwargs):
         super().__init__(__file__, 'navbar_single_column', *args, **kwargs)