From cf9e109819fcb30ffd3324909c74310f74552e49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 26 Nov 2018 14:38:48 +0100 Subject: [PATCH] doxygen: add back removed spaces around &&. And test this whole thing. --- doxygen/dox2html5.py | 9 ++++++++- doxygen/test/test_utility.py | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 08dfc773..ff6dac2b 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -432,8 +432,15 @@ def extract_id_hash(state: State, element: ET.Element) -> str: assert id.startswith(state.current_definition_url_base) return id[len(state.current_definition_url_base)+2:] +and_re_src = re.compile(r'([^\s])&&([^\s])') +and_re_dst = r'\1 && \2' + def fix_type_spacing(type: str) -> str: - return type.replace('< ', '<').replace(' >', '>').replace(' &', '&').replace(' *', '*') + return and_re_src.sub(and_re_dst, type + .replace('< ', '<') + .replace(' >', '>') + .replace(' &', '&') + .replace(' *', '*')) def parse_type(state: State, type: ET.Element) -> str: # Constructors and typeless enums might not have it diff --git a/doxygen/test/test_utility.py b/doxygen/test/test_utility.py index 169826e9..7ab6b60c 100644 --- a/doxygen/test/test_utility.py +++ b/doxygen/test/test_utility.py @@ -23,8 +23,9 @@ # import unittest +import html -from dox2html5 import add_wbr +from dox2html5 import add_wbr, fix_type_spacing class Utility(unittest.TestCase): def test_add_wbr(self): @@ -32,3 +33,11 @@ class Utility(unittest.TestCase): self.assertEqual(add_wbr('CORRADE_TEST_MAIN()'), 'CORRADE_TEST_MAIN()') self.assertEqual(add_wbr('https://magnum.graphics/showcase/'), 'https://magnum.graphics/showcase/') self.assertEqual(add_wbr('a'), 'a') + + def test_fix_type_spacing(self): + def fix_escaped(str): + return html.unescape(fix_type_spacing(html.escape(str))) + + self.assertEqual(fix_escaped('Foo< T, U > *'), 'Foo*') + self.assertEqual(fix_escaped('Foo< T, U > &'), 'Foo&') + self.assertEqual(fix_escaped('Foo< T&&U >'), 'Foo') -- 2.30.2