chiark / gitweb /
doxygen: support the \htmlinclude command.
authorVladimír Vondruš <mosra@centrum.cz>
Sun, 4 Nov 2018 10:41:32 +0000 (11:41 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Sun, 4 Nov 2018 12:00:03 +0000 (13:00 +0100)
doxygen/dox2html5.py
doxygen/test/contents_htmlinclude/Doxyfile [new file with mode: 0644]
doxygen/test/contents_htmlinclude/file.html [new file with mode: 0644]
doxygen/test/contents_htmlinclude/index.html [new file with mode: 0644]
doxygen/test/contents_htmlinclude/input.dox [new file with mode: 0644]
doxygen/test/contents_htmlinclude/warnings.html [new file with mode: 0644]
doxygen/test/test_contents.py

index d572eeb19895dac8d7844c41914e37a321c6765f..8b4b32151d0e218af743e9f7354e688313d020a4 100755 (executable)
@@ -610,6 +610,7 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
         # - <mcss:div>
         # - <formula> (if block)
         # - <programlisting> (if block)
+        # - <htmlonly> (if block, which is ATM always)
         #
         # <parameterlist> and <simplesect kind="return"> 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
 
             # <simplesect> 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 += '<hr/>'
 
+        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 <div> 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 (file)
index 0000000..f402b59
--- /dev/null
@@ -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 (file)
index 0000000..08a6997
--- /dev/null
@@ -0,0 +1,2 @@
+<p class="m-text m-red">This goes from a HTML file and should not be wrapped
+twice in <code>&lt;p&gt;</code>.</p>
diff --git a/doxygen/test/contents_htmlinclude/index.html b/doxygen/test/contents_htmlinclude/index.html
new file mode 100644 (file)
index 0000000..8e2f27a
--- /dev/null
@@ -0,0 +1,32 @@
+<!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-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>
+          My Project
+        </h1>
+<p class="m-text m-red">This goes from a HTML file and should not be wrapped
+twice in <code>&lt;p&gt;</code>.</p>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
diff --git a/doxygen/test/contents_htmlinclude/input.dox b/doxygen/test/contents_htmlinclude/input.dox
new file mode 100644 (file)
index 0000000..6407b05
--- /dev/null
@@ -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 (file)
index 0000000..8046d01
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>This will produce a warning | 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-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>
+          This will produce a warning
+        </h1>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
\ No newline at end of file
index 8995678778158da077719f4a5091fc5b7d8be4bb..e8708799f0d73629d2727af77e0eb53e3466ad68 100644 (file)
@@ -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'))