chiark / gitweb /
documentation/doxygen: fixed bug with exception references.
authorYuri Edward <nicolas1.fraysse@epitech.eu>
Tue, 12 May 2020 19:53:02 +0000 (21:53 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 8 Jun 2020 17:42:29 +0000 (19:42 +0200)
documentation/doxygen.py
documentation/test_doxygen/compound_exception_reference/Doxyfile [new file with mode: 0644]
documentation/test_doxygen/compound_exception_reference/File.h [new file with mode: 0644]
documentation/test_doxygen/compound_exception_reference/File_8h.html [new file with mode: 0644]
documentation/test_doxygen/test_compound.py

index 92a4886fd614f540826e7e7d556358f07afd11f0..11f98889734a365604e26b4dff1ee29854d36a7f 100755 (executable)
@@ -977,7 +977,11 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
                     elif i.attrib['kind'] == 'retval':
                         out.return_values += [(name.text, description)]
                     elif i.attrib['kind'] == 'exception':
-                        out.exceptions += [(name.text, description)]
+                        ref = name.find('ref')
+                        if (ref != None):
+                            out.exceptions += [(parse_ref(state, ref), description)]
+                        else:
+                            out.exceptions += [(name.text, description)]
                     else:
                         assert i.attrib['kind'] == 'templateparam'
                         out.templates[name.text] = description
diff --git a/documentation/test_doxygen/compound_exception_reference/Doxyfile b/documentation/test_doxygen/compound_exception_reference/Doxyfile
new file mode 100644 (file)
index 0000000..7e9ad92
--- /dev/null
@@ -0,0 +1,14 @@
+INPUT                   = File.h
+QUIET                   = YES
+GENERATE_HTML           = NO
+GENERATE_LATEX          = NO
+GENERATE_XML            = YES
+XML_PROGRAMLISTING      = NO
+CASE_SENSE_NAMES        = YES
+
+##! M_PAGE_FINE_PRINT   =
+##! M_THEME_COLOR       =
+##! M_FAVICON           =
+##! M_LINKS_NAVBAR1     =
+##! M_LINKS_NAVBAR2     =
+##! M_SEARCH_DISABLED   = YES
diff --git a/documentation/test_doxygen/compound_exception_reference/File.h b/documentation/test_doxygen/compound_exception_reference/File.h
new file mode 100644 (file)
index 0000000..62e434d
--- /dev/null
@@ -0,0 +1,13 @@
+/** @file
+ * @brief A file
+ */
+
+/** @brief An exception */
+struct MyException {};
+
+/**
+@brief A function that throws
+@throw std::runtime_exception This one doesn't have a reference
+@throw MyException This one does
+*/
+void foo();
diff --git a/documentation/test_doxygen/compound_exception_reference/File_8h.html b/documentation/test_doxygen/compound_exception_reference/File_8h.html
new file mode 100644 (file)
index 0000000..fd72df8
--- /dev/null
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>File.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>
+          File.h <span class="m-thin">file</span>
+        </h1>
+        <p>A file.</p>
+        <div class="m-block m-default">
+          <h3>Contents</h3>
+          <ul>
+            <li>
+              Reference
+              <ul>
+                <li><a href="#nested-classes">Classes</a></li>
+                <li><a href="#func-members">Functions</a></li>
+              </ul>
+            </li>
+          </ul>
+        </div>
+        <section id="nested-classes">
+          <h2><a href="#nested-classes">Classes</a></h2>
+          <dl class="m-doc">
+            <dt>
+              struct <a href="structMyException.html" class="m-doc">MyException</a>
+            </dt>
+            <dd>An exception.</dd>
+          </dl>
+        </section>
+        <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="#ac07863d69ae41a4e395b31f73b35fbcd" class="m-doc">foo</a>(</span><span class="m-doc-wrap">)</span>
+            </dt>
+            <dd>A function that throws.</dd>
+          </dl>
+        </section>
+        <section>
+          <h2>Function documentation</h2>
+          <section class="m-doc-details" id="ac07863d69ae41a4e395b31f73b35fbcd"><div>
+            <h3>
+              <span class="m-doc-wrap-bumper">void </span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#ac07863d69ae41a4e395b31f73b35fbcd" class="m-doc-self">foo</a>(</span><span class="m-doc-wrap">)</span></span>
+            </h3>
+            <p>A function that throws.</p>
+            <table class="m-table m-fullwidth m-flat">
+              <thead>
+                <tr><th colspan="2">Exceptions</th></tr>
+              </thead>
+              <tbody>
+                <tr>
+                  <td style="width: 1%">std::runtime_exception</td>
+                  <td>This one doesn&#x27;t have a reference</td>
+                </tr>
+                <tr>
+                  <td><a href="structMyException.html" class="m-doc">MyException</a></td>
+                  <td>This one does</td>
+                </tr>
+              </tbody>
+            </table>
+          </div></section>
+        </section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
index 9450fa38b216369f47392fd6cb1f9afd141255c5..a04b9fafab3dc1f7ad182e4e5f536bc2d7187972 100644 (file)
@@ -357,3 +357,11 @@ class Since(IntegrationTestCase):
         self.assertEqual(*self.actual_expected_contents('modules.html'))
         self.assertEqual(*self.actual_expected_contents('namespaces.html'))
         self.assertEqual(*self.actual_expected_contents('pages.html'))
+
+class ExceptionReference(IntegrationTestCase):
+    def __init__(self, *args, **kwargs):
+        super().__init__(__file__, 'exception_reference', *args, **kwargs)
+
+    def test(self):
+        self.run_doxygen(wildcard='*.xml')
+        self.assertEqual(*self.actual_expected_contents('File_8h.html'))