From bb212ccc7f1e660d31d290ce1bc9264407bd7cbd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 18 Jun 2018 13:30:42 +0200 Subject: [PATCH] doxygen: avoid having stale url_base when parsing defines. I *knew* something would blow up here. --- doxygen/dox2html5.py | 6 +- .../Doxyfile | 14 ++++ .../File.h | 22 ++++++ .../File_8h.html | 67 +++++++++++++++++++ doxygen/test/test_compound.py | 12 ++++ 5 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 doxygen/test/compound_namespace_members_in_file_scope_define_base_url/Doxyfile create mode 100644 doxygen/test/compound_namespace_members_in_file_scope_define_base_url/File.h create mode 100644 doxygen/test/compound_namespace_members_in_file_scope_define_base_url/File_8h.html diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 8efd03e0..3df5c408 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -1719,7 +1719,11 @@ def parse_define(state: State, element: ET.Element): assert element.tag == 'memberdef' and element.attrib['kind'] == 'define' define = Empty() - define.id = extract_id_hash(state, element) + # defines are always only defined in files, never duplicated to namespaces, + # so we don't need to have define.base_url. Can't use extract_id_hash() + # here because current_definition_url_base might be stale. See a test in + # compound_namespace_members_in_file_scope_define_base_url. + state.current_definition_url_base, _, define.id = parse_id(element) define.name = element.find('name').text define.brief = parse_desc(state, element.find('briefdescription')) define.description, params, define.return_value, search_keywords, define.is_deprecated = parse_define_desc(state, element) diff --git a/doxygen/test/compound_namespace_members_in_file_scope_define_base_url/Doxyfile b/doxygen/test/compound_namespace_members_in_file_scope_define_base_url/Doxyfile new file mode 100644 index 00000000..cd500a22 --- /dev/null +++ b/doxygen/test/compound_namespace_members_in_file_scope_define_base_url/Doxyfile @@ -0,0 +1,14 @@ +INPUT = File.h +QUIET = YES +GENERATE_HTML = NO +GENERATE_LATEX = NO +GENERATE_XML = YES +XML_PROGRAMLISTING = NO +XML_NAMESPACE_MEMBERS_IN_FILE_SCOPE = YES + +##! M_PAGE_FINE_PRINT = +##! M_THEME_COLOR = +##! M_FAVICON = +##! M_LINKS_NAVBAR1 = +##! M_LINKS_NAVBAR2 = +##! M_SEARCH_DISABLED = YES diff --git a/doxygen/test/compound_namespace_members_in_file_scope_define_base_url/File.h b/doxygen/test/compound_namespace_members_in_file_scope_define_base_url/File.h new file mode 100644 index 00000000..0247d166 --- /dev/null +++ b/doxygen/test/compound_namespace_members_in_file_scope_define_base_url/File.h @@ -0,0 +1,22 @@ +/** @file + * @brief A file + */ + +/* Preprocessor defines are usually first in the XML file, but if there is a + user-defined group, that is first. That triggers a corder case in define ID + extraction -- parsing the var will set current base url to namespaceNS, + but that shouldn't trigger any error when parsing the define after. */ + +/** @brief A namespace */ +namespace NS { + +/** @{ @name Variables */ + +int var; /**< @brief A variable */ + +/*@}*/ + +} + +/** @brief A define */ +#define A_DEFINE diff --git a/doxygen/test/compound_namespace_members_in_file_scope_define_base_url/File_8h.html b/doxygen/test/compound_namespace_members_in_file_scope_define_base_url/File_8h.html new file mode 100644 index 00000000..f266c11b --- /dev/null +++ b/doxygen/test/compound_namespace_members_in_file_scope_define_base_url/File_8h.html @@ -0,0 +1,67 @@ + + + + + File.h file | My Project + + + + + +
+
+ + diff --git a/doxygen/test/test_compound.py b/doxygen/test/test_compound.py index 8b2d2be0..aa91be98 100644 --- a/doxygen/test/test_compound.py +++ b/doxygen/test/test_compound.py @@ -207,6 +207,18 @@ class NamespaceMembersInFileScope(IntegrationTestCase): # The file should have just links to detailed docs self.assertEqual(*self.actual_expected_contents('File_8h.html')) +class NamespaceMembersInFileScopeDefineBaseUrl(IntegrationTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'namespace_members_in_file_scope_define_base_url', *args, **kwargs) + + @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.14"), + "https://github.com/doxygen/doxygen/pull/653") + def test(self): + self.run_dox2html5(wildcard='File_8h.xml') + + # The file should have just links to detailed docs + self.assertEqual(*self.actual_expected_contents('File_8h.html')) + class FilenameCase(IntegrationTestCase): def __init__(self, *args, **kwargs): super().__init__(__file__, 'filename_case', *args, **kwargs) -- 2.30.2