chiark / gitweb /
documentation/doxygen: Doxygen 1.12 can produce up to <sect6>.
authorVladimír Vondruš <mosra@centrum.cz>
Fri, 13 Sep 2024 21:23:25 +0000 (23:23 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 14 Sep 2024 00:46:33 +0000 (02:46 +0200)
And is slightly less broken when encountering Markdown headers where
it's not #'s at the start of the line but underneath.

documentation/doxygen.py
documentation/test_doxygen/contents_sections_headings/Warnings_8h-111.html [new file with mode: 0644]
documentation/test_doxygen/contents_sections_headings/Warnings_8h.html
documentation/test_doxygen/contents_sections_headings/warnings-111.html [new file with mode: 0644]
documentation/test_doxygen/contents_sections_headings/warnings.html
documentation/test_doxygen/test_contents.py

index 9a88dceaaa9e15b2372151edcb2fac6d09d6b4e3..c242416de8bacf5ee21da2a86b53189a71b845a6 100755 (executable)
@@ -597,8 +597,9 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
                 out.parsed += '<p>'
                 out.write_paragraph_close_tag = True
 
-        # Block elements
-        if i.tag in ['sect1', 'sect2', 'sect3', 'sect4']:
+        # Block elements. Until Doxygen 1.11 it was at most <sect4>, 1.12 seems
+        # to have up to 6: https://github.com/doxygen/doxygen/issues/11016
+        if i.tag in ['sect1', 'sect2', 'sect3', 'sect4', 'sect5', 'sect6']:
             assert element.tag != 'para' # should be top-level block element
             has_block_elements = True
 
@@ -637,6 +638,11 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
                     tag = 'h4'
                 elif element.tag == 'sect4':
                     tag = 'h5'
+                elif element.tag == 'sect5':
+                    tag = 'h6'
+                elif element.tag == 'sect6':
+                    tag = 'h6'
+                    logging.warning("{}: more than five levels of sections are not supported, stopping at <h6>".format(state.current))
                 elif not element.tag == 'simplesect': # pragma: no cover
                     assert False
 
@@ -672,7 +678,11 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
                     out.parsed += '<{0} id="{1}">{2}</{0}>'.format(tag, id, title)
 
         # Apparently, in 1.8.18, <heading> is used for Markdown headers only if
-        # we run out of sect1-4 tags. Eh, what the hell.
+        # we run out of sect1-4 tags. Which also happens when there's a heading
+        # with a ####### underline. In 1.12 it doesn't produce a <heading>, and
+        # instead just puts the #'s to the output verbatim. Which means we
+        # can't warn for that. See test_contents.SectionsHeadings for repro
+        # cases.
         elif i.tag == 'heading':
             assert element.tag == 'para' # is inside a paragraph :/
             has_block_elements = True
diff --git a/documentation/test_doxygen/contents_sections_headings/Warnings_8h-111.html b/documentation/test_doxygen/contents_sections_headings/Warnings_8h-111.html
new file mode 100644 (file)
index 0000000..51c0aef
--- /dev/null
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>Warnings.h file | 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+documentation.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>
+          Warnings.h <span class="m-thin">file</span>
+        </h1>
+        <p>A file producing warnings.</p>
+        <nav class="m-block m-default">
+          <h3>Contents</h3>
+          <ul>
+            <li>
+              Reference
+              <ul>
+                <li><a href="#func-members">Functions</a></li>
+              </ul>
+            </li>
+          </ul>
+        </nav>
+        <section id="func-members">
+          <h2><a href="#func-members">Functions</a></h2>
+          <dl class="m-doc">
+            <dt>
+              <span class="m-doc-wrap-bumper">void <a href="#ac03b94e5ed1aeeba4c9d31498e9a767a" class="m-doc">bar</a>(</span><span class="m-doc-wrap">int foo)</span>
+            </dt>
+            <dd>This produces warnings.</dd>
+          </dl>
+        </section>
+        <section>
+          <h2>Function documentation</h2>
+          <section class="m-doc-details" id="ac03b94e5ed1aeeba4c9d31498e9a767a"><div>
+            <h3>
+              <span class="m-doc-wrap-bumper">void </span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ac03b94e5ed1aeeba4c9d31498e9a767a" class="m-doc-self">bar</a>(</span><span class="m-doc-wrap">int foo)</span></span>
+            </h3>
+            <p>This produces warnings.</p>
+<h6 id="autotoc_md3">Markdown heading 4 that&#x27;s rendered the same as 3</h6><p>Markdown heading, underlined, is misparsed</p>
+          </div></section>
+        </section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
index 51c0aef4a5d263d7fa07f79138ac1aafe88ea6b9..4ec185dae3f2232b534906c44f4d81b68d30c43a 100644 (file)
@@ -50,7 +50,7 @@
               <span class="m-doc-wrap-bumper">void </span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ac03b94e5ed1aeeba4c9d31498e9a767a" class="m-doc-self">bar</a>(</span><span class="m-doc-wrap">int foo)</span></span>
             </h3>
             <p>This produces warnings.</p>
-<h6 id="autotoc_md3">Markdown heading 4 that&#x27;s rendered the same as 3</h6><p>Markdown heading, underlined, is misparsed</p>
+<h6 id="autotoc_md3">Markdown heading 4 that&#x27;s rendered the same as 3</h6><p>Markdown heading, underlined, is misparsed ##########################################</p>
           </div></section>
         </section>
       </div>
diff --git a/documentation/test_doxygen/contents_sections_headings/warnings-111.html b/documentation/test_doxygen/contents_sections_headings/warnings-111.html
new file mode 100644 (file)
index 0000000..6410f51
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>Content that produces warnings | 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+documentation.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>
+          Content that produces warnings
+        </h1>
+<section id="autotoc_md4"><h2><a href="#autotoc_md4">Markdown heading 1</a></h2><section id="autotoc_md5"><h3><a href="#autotoc_md5">Markdown heading 2</a></h3><section id="autotoc_md6"><h4><a href="#autotoc_md6">Markdown heading 3</a></h4><section id="autotoc_md7"><h5><a href="#autotoc_md7">Markdown heading 4</a></h5><p><a name="autotoc_md8"></a></p><h6>Markdown heading 5</h6><h6>Markdown heading 6 that&#x27;s rendered the same as 5</h6><p>Markdown heading, underlined, is misparsed</p></section></section></section></section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
index 6410f51b534cd50a0cc68aa26cf81e4220070b16..e03d348fc5e5b62da2b62fdc37ea562818fb1314 100644 (file)
@@ -22,7 +22,7 @@
         <h1>
           Content that produces warnings
         </h1>
-<section id="autotoc_md4"><h2><a href="#autotoc_md4">Markdown heading 1</a></h2><section id="autotoc_md5"><h3><a href="#autotoc_md5">Markdown heading 2</a></h3><section id="autotoc_md6"><h4><a href="#autotoc_md6">Markdown heading 3</a></h4><section id="autotoc_md7"><h5><a href="#autotoc_md7">Markdown heading 4</a></h5><p><a name="autotoc_md8"></a></p><h6>Markdown heading 5</h6><h6>Markdown heading 6 that&#x27;s rendered the same as 5</h6><p>Markdown heading, underlined, is misparsed</p></section></section></section></section>
+<section id="autotoc_md4"><h2><a href="#autotoc_md4">Markdown heading 1</a></h2><section id="autotoc_md5"><h3><a href="#autotoc_md5">Markdown heading 2</a></h3><section id="autotoc_md6"><h4><a href="#autotoc_md6">Markdown heading 3</a></h4><section id="autotoc_md7"><h5><a href="#autotoc_md7">Markdown heading 4</a></h5><section id="autotoc_md8"><h6><a href="#autotoc_md8">Markdown heading 5</a></h6><section id="autotoc_md9"><h6><a href="#autotoc_md9">Markdown heading 6 that&#x27;s rendered the same as 5</a></h6><p>Markdown heading, underlined, is misparsed ##########################################</p></section></section></section></section></section></section>
       </div>
     </div>
   </div>
index cf9e72754219f48af4c8bc6bce3380f5fdbd8abf..5c42767a9aac24fadf1b004363bb817e1e9ba41c 100644 (file)
@@ -407,14 +407,28 @@ class SectionsHeadings(IntegrationTestCase):
         with self.assertLogs() as cm:
             self.run_doxygen(wildcard='*arnings*.xml')
 
-        self.assertEqual(*self.actual_expected_contents('warnings.html'))
-        self.assertEqual(*self.actual_expected_contents('Warnings_8h.html'))
-        self.assertEqual(cm.output, [
-            "WARNING:root:Warnings_8h.xml: more than three levels of sections in member descriptions are not supported, stopping at <h6>",
-            "WARNING:root:Warnings_8h.xml: a Markdown heading underline was apparently misparsed by Doxygen, prefix the headings with # instead",
-            "WARNING:root:warnings.xml: more than five levels of Markdown headings for top-level docs are not supported, stopping at <h6>",
-            "WARNING:root:warnings.xml: a Markdown heading underline was apparently misparsed by Doxygen, prefix the headings with # instead",
-        ])
+        # https://github.com/doxygen/doxygen/issues/11016, merged into 1.12, is
+        # responsible I think. It got better, yes.
+        if parse_version(doxygen_version()) >= (1, 12):
+            page = 'warnings.html'
+            file = 'Warnings_8h.html'
+            output = [
+                "WARNING:root:Warnings_8h.xml: more than three levels of sections in member descriptions are not supported, stopping at <h6>",
+                "WARNING:root:warnings.xml: more than five levels of sections are not supported, stopping at <h6>",
+            ]
+        else:
+            page = 'warnings-111.html'
+            file = 'Warnings_8h-111.html'
+            output = [
+                "WARNING:root:Warnings_8h.xml: more than three levels of sections in member descriptions are not supported, stopping at <h6>",
+                "WARNING:root:Warnings_8h.xml: a Markdown heading underline was apparently misparsed by Doxygen, prefix the headings with # instead",
+                "WARNING:root:warnings.xml: more than five levels of Markdown headings for top-level docs are not supported, stopping at <h6>",
+                "WARNING:root:warnings.xml: a Markdown heading underline was apparently misparsed by Doxygen, prefix the headings with # instead",
+            ]
+
+        self.assertEqual(*self.actual_expected_contents('warnings.html', page))
+        self.assertEqual(*self.actual_expected_contents('Warnings_8h.html', file))
+        self.assertEqual(cm.output, output)
 
 class AnchorInBothGroupAndNamespace(IntegrationTestCase):
     def test(self):