chiark / gitweb /
documentation/doxygen: this warning isn't related to any file.
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 16 Sep 2024 17:59:42 +0000 (19:59 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 16 Sep 2024 19:36:16 +0000 (21:36 +0200)
It may get printed when preprocessing the state from all files (building
parent/child hierarchies, etc), listing a random file for that is
extremely confusing.

Well, the whole message is extremely confusing, so let's redo it,
suggest a fix and also have a test for it, instead of excluding it from
coverage.

documentation/doxygen.py
documentation/test_doxygen/__init__.py
documentation/test_doxygen/compound_no_full_path_names/doc/Doxyfile [new file with mode: 0644]
documentation/test_doxygen/compound_no_full_path_names/files.html [new file with mode: 0644]
documentation/test_doxygen/compound_no_full_path_names/project/directory/sub.h [new file with mode: 0644]
documentation/test_doxygen/compound_no_full_path_names/project/root.h [new file with mode: 0644]
documentation/test_doxygen/test_compound.py

index 530d6db22a48eade2bb1ab2f9eda48ef4de04891..8502d5e93298ab9f851f48f86df4fe9b2acfae35 100755 (executable)
@@ -2602,8 +2602,8 @@ def postprocess_state(state: State):
             prefix = state.compounds[compound.parent].name + '/'
             if compound.name.startswith(prefix):
                 compound.leaf_name = compound.name[len(prefix):]
-            else: # pragma: no cover
-                logging.warning("{}: potential issue: directory {} parent is not a prefix: {}".format(state.current, compound.name, prefix))
+            else:
+                logging.warning("potential issue: the parent of {}/ is {} which is not a prefix, you may want to enable FULL_PATH_NAMES together with STRIP_FROM_PATH and STRIP_FROM_INC_PATH to preserve filesystem hierarchy".format(compound.name, prefix))
                 compound.leaf_name = compound.name
 
         # Other compounds are not in any index pages or breadcrumb, so leaf
index c83291a7dad4c91ee91a2d744146e206d698852c..a238d9b5abe84e3b10d512cffb7ab97092b8f6ca 100644 (file)
@@ -99,6 +99,9 @@ class BaseTestCase(unittest.TestCase):
 class IntegrationTestCase(BaseTestCase):
     def setUp(self):
         if os.path.exists(os.path.join(self.path, 'xml')): shutil.rmtree(os.path.join(self.path, 'xml'))
-        subprocess.run(['doxygen', self.doxyfile], cwd=self.path, check=True)
+        # Run Doxygen at the path where Doxyfile is, in order to interpret the
+        # paths in it relative to that file
+        subpath, doxyfile = os.path.split(self.doxyfile)
+        subprocess.run(['doxygen', doxyfile], cwd=os.path.join(self.path, subpath), check=True)
 
         if os.path.exists(os.path.join(self.path, 'html')): shutil.rmtree(os.path.join(self.path, 'html'))
diff --git a/documentation/test_doxygen/compound_no_full_path_names/doc/Doxyfile b/documentation/test_doxygen/compound_no_full_path_names/doc/Doxyfile
new file mode 100644 (file)
index 0000000..68aadcf
--- /dev/null
@@ -0,0 +1,21 @@
+INPUT                   = ../project/root.h ../project/directory/sub.h
+OUTPUT_DIRECTORY        = ..
+QUIET                   = YES
+GENERATE_HTML           = NO
+GENERATE_LATEX          = NO
+GENERATE_XML            = YES
+XML_PROGRAMLISTING      = NO
+CASE_SENSE_NAMES        = YES
+
+# If the three below would be set instead, it wouldn't warn
+FULL_PATH_NAMES         = NO
+# FULL_PATH_NAMES         = YES
+# STRIP_FROM_PATH         = ..
+# STRIP_FROM_INC_PATH     = ..
+
+##! 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_no_full_path_names/files.html b/documentation/test_doxygen/compound_no_full_path_names/files.html
new file mode 100644 (file)
index 0000000..4e07d8c
--- /dev/null
@@ -0,0 +1,58 @@
+<!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+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>Files</h1>
+        <ul class="m-doc">
+          <li class="m-doc-collapsible">
+            <a href="#" onclick="return toggle(this)">dir</a> <a href="dir_167790342fb55959539d550b874be046.html" class="m-doc">project</a> <span class="m-doc">Root directory.</span>
+            <ul class="m-doc">
+              <li class="m-doc-collapsible collapsed">
+                <a href="#" onclick="return toggle(this)">dir</a> <a href="dir_aa1d5ee656b7a8fc93f47c41696a1c9b.html" class="m-doc">directory</a> <span class="m-doc">Subdirectory.</span>
+                <ul class="m-doc">
+                  <li>file <a href="sub_8h.html" class="m-doc">sub.h</a> <span class="m-doc">Subdirectory file.</span></li>
+                </ul>
+              </li>
+              <li>file <a href="root_8h.html" class="m-doc">root.h</a> <span class="m-doc">Root file.</span></li>
+            </ul>
+          </li>
+        </ul>
+        <script>
+        function toggle(e) {
+            e.parentElement.className = e.parentElement.className == 'm-doc-collapsible' ?
+                'm-doc-expansible' : 'm-doc-collapsible';
+            return false;
+        }
+        /* Collapse all nodes marked as such. Doing it via JS instead of
+           directly in markup so disabling it doesn't harm usability. The list
+           is somehow regenerated on every iteration and shrinks as I change
+           the classes. It's not documented anywhere and I'm not sure if this
+           is the same across browsers, so I am going backwards in that list to
+           be sure. */
+        var collapsed = document.getElementsByClassName("collapsed");
+        for(var i = collapsed.length - 1; i >= 0; --i)
+            collapsed[i].className = 'm-doc-expansible';
+        </script>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
diff --git a/documentation/test_doxygen/compound_no_full_path_names/project/directory/sub.h b/documentation/test_doxygen/compound_no_full_path_names/project/directory/sub.h
new file mode 100644 (file)
index 0000000..2d98ffa
--- /dev/null
@@ -0,0 +1,3 @@
+/** @file
+ * @brief Subdirectory file
+ */
diff --git a/documentation/test_doxygen/compound_no_full_path_names/project/root.h b/documentation/test_doxygen/compound_no_full_path_names/project/root.h
new file mode 100644 (file)
index 0000000..793c3e7
--- /dev/null
@@ -0,0 +1,14 @@
+/* Sources for the test in ../compound_no_full_path_names, needs to be in a
+   directory outside of the Doxyfile to trigger the behavior */
+
+/** @dir project
+ * @brief Root directory
+ */
+
+/** @dir project/directory
+ * @brief Subdirectory
+ */
+
+/** @file
+ * @brief Root file
+ */
index 6a137e8506d500809776b00f4d09f12c206f59d8..1e239ea68988668466db2ebc4dc11b9969f37756 100644 (file)
@@ -428,3 +428,16 @@ class InlineNamespace(IntegrationTestCase):
         self.assertEqual(*self.actual_expected_contents('File_8h.html'))
         self.assertEqual(*self.actual_expected_contents('annotated.html'))
         self.assertEqual(*self.actual_expected_contents('namespaces.html'))
+
+class NoFullPathNames(IntegrationTestCase):
+    def __init__(self, *args, **kwargs):
+        Listing.__init__(self, *args, doxyfile='doc/Doxyfile', **kwargs)
+
+    def test(self):
+        with self.assertLogs() as cm:
+            self.run_doxygen(wildcard='*.xml')
+
+        self.assertEqual(*self.actual_expected_contents('files.html'))
+        self.assertEqual(cm.output, [
+            "WARNING:root:potential issue: the parent of directory/ is project/ which is not a prefix, you may want to enable FULL_PATH_NAMES together with STRIP_FROM_PATH and STRIP_FROM_INC_PATH to preserve filesystem hierarchy"
+        ])