From: Vladimír Vondruš Date: Sun, 4 Nov 2018 10:41:32 +0000 (+0100) Subject: doxygen: support the \htmlinclude command. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=4ba2915669b6ae8bf795b89ed7c5358facd26e90;p=blog.git doxygen: support the \htmlinclude command. --- diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index d572eeb1..8b4b3215 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -610,6 +610,7 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET. # - # - (if block) # - (if block) + # - (if block, which is ATM always) # # and are extracted out of # the text flow, so these are removed from this check. @@ -628,7 +629,7 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET. end_previous_paragraph = False # Straightforward elements - if i.tag in ['heading', 'blockquote', 'hruler', 'xrefsect', 'variablelist', 'verbatim', 'parblock', 'preformatted', 'itemizedlist', 'orderedlist', 'image', 'dot', 'dotfile', 'table', '{http://mcss.mosra.cz/doxygen/}div']: + if i.tag in ['heading', 'blockquote', 'hruler', 'xrefsect', 'variablelist', 'verbatim', 'parblock', 'preformatted', 'itemizedlist', 'orderedlist', 'image', 'dot', 'dotfile', 'table', '{http://mcss.mosra.cz/doxygen/}div', 'htmlonly']: end_previous_paragraph = True # describing return type is cut out of text flow, so @@ -1111,6 +1112,15 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET. assert element.tag == 'para' # is inside a paragraph :/ out.parsed += '
' + elif i.tag == 'htmlonly': + # The @htmlonly command has a block version, which is able to get + # rid of the wrapping paragraph. But @htmlonly is not exposed to + # XML. Only @htmlinclude is exposed in XML and that one is always + # wrapped in a paragraph. I need to submit another patch to make it + # less freaking insane. I guess. + assert element.tag in ['para', '{http://mcss.mosra.cz/doxygen/}div'] + if i.text: out.parsed += i.text + # Custom
with CSS classes (for making dim notes etc) elif i.tag == '{http://mcss.mosra.cz/doxygen/}div': has_block_elements = True diff --git a/doxygen/test/contents_htmlinclude/Doxyfile b/doxygen/test/contents_htmlinclude/Doxyfile new file mode 100644 index 00000000..f402b59a --- /dev/null +++ b/doxygen/test/contents_htmlinclude/Doxyfile @@ -0,0 +1,14 @@ +INPUT = input.dox +EXAMPLE_PATH = . +QUIET = YES +GENERATE_HTML = NO +GENERATE_LATEX = NO +GENERATE_XML = YES +XML_PROGRAMLISTING = NO + +##! M_PAGE_FINE_PRINT = +##! M_THEME_COLOR = +##! M_FAVICON = +##! M_LINKS_NAVBAR1 = +##! M_LINKS_NAVBAR2 = +##! M_SEARCH_DISABLED = YES diff --git a/doxygen/test/contents_htmlinclude/file.html b/doxygen/test/contents_htmlinclude/file.html new file mode 100644 index 00000000..08a69979 --- /dev/null +++ b/doxygen/test/contents_htmlinclude/file.html @@ -0,0 +1,2 @@ +

This goes from a HTML file and should not be wrapped +twice in <p>.

diff --git a/doxygen/test/contents_htmlinclude/index.html b/doxygen/test/contents_htmlinclude/index.html new file mode 100644 index 00000000..8e2f27a4 --- /dev/null +++ b/doxygen/test/contents_htmlinclude/index.html @@ -0,0 +1,32 @@ + + + + + My Project + + + + + +
+
+
+
+
+

+ My Project +

+

This goes from a HTML file and should not be wrapped +twice in <p>.

+
+
+
+
+ + diff --git a/doxygen/test/contents_htmlinclude/input.dox b/doxygen/test/contents_htmlinclude/input.dox new file mode 100644 index 00000000..6407b058 --- /dev/null +++ b/doxygen/test/contents_htmlinclude/input.dox @@ -0,0 +1,9 @@ +/** @mainpage + +@htmlinclude file.html +*/ + +/** @page warnings This will produce a warning + +@htmlinclude nonexistent.html +*/ diff --git a/doxygen/test/contents_htmlinclude/warnings.html b/doxygen/test/contents_htmlinclude/warnings.html new file mode 100644 index 00000000..8046d01f --- /dev/null +++ b/doxygen/test/contents_htmlinclude/warnings.html @@ -0,0 +1,30 @@ + + + + + This will produce a warning | My Project + + + + + +
+
+
+
+
+

+ This will produce a warning +

+
+
+
+
+ + \ No newline at end of file diff --git a/doxygen/test/test_contents.py b/doxygen/test/test_contents.py index 89956787..e8708799 100644 --- a/doxygen/test/test_contents.py +++ b/doxygen/test/test_contents.py @@ -378,3 +378,15 @@ class Dot(IntegrationTestCase): def test_warnings(self): self.run_dox2html5(wildcard='warnings.xml') self.assertEqual(*self.actual_expected_contents('warnings.html')) + +class Htmlinclude(IntegrationTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'htmlinclude', *args, **kwargs) + + def test(self): + self.run_dox2html5(wildcard='indexpage.xml') + self.assertEqual(*self.actual_expected_contents('index.html')) + + def test_warnings(self): + self.run_dox2html5(wildcard='warnings.xml') + self.assertEqual(*self.actual_expected_contents('warnings.html'))