From: Vladimír Vondruš Date: Sat, 23 Feb 2019 00:31:15 +0000 (+0100) Subject: doxygen: fall back to the default template location from --template. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=715a682c60a6447745cf9dd1bf014992e6765a6a;p=blog.git doxygen: fall back to the default template location from --template. So people don't need to provide the whole copy, just the modified files. --- diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 2ec89c44..237797a6 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -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 index 00000000..3d1b9822 --- /dev/null +++ b/doxygen/test/layout_template_fallback/Doxyfile @@ -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 index 00000000..e06469c4 --- /dev/null +++ b/doxygen/test/layout_template_fallback/index.html @@ -0,0 +1,29 @@ + + + + + HELLO THIS TEMPLATE OVERRIDES THINGS + + + + + +
+
+
+
+
+

HELLO THIS TEMPLATE OVERRIDES THINGS

+

But not all, the base.html is taken from the fallback.

+
+
+
+
+ + diff --git a/doxygen/test/layout_template_fallback/indexpage.xml b/doxygen/test/layout_template_fallback/indexpage.xml new file mode 100644 index 00000000..fa7a2a87 --- /dev/null +++ b/doxygen/test/layout_template_fallback/indexpage.xml @@ -0,0 +1,11 @@ + + + + index + My Project + + + + + + diff --git a/doxygen/test/layout_template_fallback/page.html b/doxygen/test/layout_template_fallback/page.html new file mode 100644 index 00000000..98394699 --- /dev/null +++ b/doxygen/test/layout_template_fallback/page.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} + +{% block title %}HELLO THIS TEMPLATE OVERRIDES THINGS{% endblock %} + +{% block main %} +

HELLO THIS TEMPLATE OVERRIDES THINGS

+ {% if compound.brief %} +

{{ compound.brief }}

+ {% endif %} +

But not all, the base.html is taken from the fallback.

+ {% if compound.description %} +{{ compound.description }} + {% endif %} +{% endblock %} diff --git a/doxygen/test/test_layout.py b/doxygen/test/test_layout.py index a7a32b72..2742df78 100644 --- a/doxygen/test/test_layout.py +++ b/doxygen/test/test_layout.py @@ -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)