From a142ccd77ff23feb3402d49a330ee43a4f7ad602 Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Sun, 12 Dec 2021 13:52:38 +0200 Subject: [PATCH] fix doxygen bug that erroneously treats keywords as part of return types also: - blacklisted schema 0.7.5 because it's broken --- CHANGELOG.md | 4 ++++ poxy/data/version.txt | 2 +- poxy/run.py | 34 ++++++++++++++++++++++++++++++++++ requirements.txt | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 621d054..4fa6d8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.5.3 - 2021-12-12 +- Fixed Doxygen bug that would sometimes treat keywords like `friend` as part of a function's return type +- Blacklisted schema 0.7.5 because [it's broken](https://github.com/keleshev/schema/issues/272) + ## v0.5.2 - 2021-11-02 - Fixed over-eager link-replacement for internal `#anchor` links - Added command-line options `--ppinclude` and `--ppexclude` diff --git a/poxy/data/version.txt b/poxy/data/version.txt index cb0c939..be14282 100644 --- a/poxy/data/version.txt +++ b/poxy/data/version.txt @@ -1 +1 @@ -0.5.2 +0.5.3 diff --git a/poxy/run.py b/poxy/run.py index 1fcd616..76bdd27 100644 --- a/poxy/run.py +++ b/poxy/run.py @@ -640,6 +640,40 @@ def _postprocess_xml(context): changed = True break + # fix functions where keywords like 'friend' have been erroneously included in the return type + if 1: + members = [m for m in section.findall(r'memberdef') if m.get(r'kind') in (r'friend', r'function')] + keywords_behaving_badly = ( + (r'constexpr ', r'constexpr', r'yes'), + (r'consteval ', r'constexpr', r'yes'), + (r'explicit ', r'explicit', r'yes'), + (r'static ', r'static', r'yes'), + (r'friend ', None, None), + (r'inline ', r'inline', r'yes'), + ) + for member in members: + type = member.find(r'type') + if type is None or type.text is None: + continue + matched_bad_keyword = True + removed_constexpr = False + while matched_bad_keyword: + matched_bad_keyword = False + for kw, attr, attr_value in keywords_behaving_badly: + if type.text.startswith(kw): + matched_bad_keyword = True + changed = True + type.text = type.text[len(kw):] + if attr is not None: + member.set(attr, attr_value) + elif kw == r'friend ': + member.set(r'kind', r'friend') + if kw == r'constexpr ': + removed_constexpr = True + # hack: m.css seems to need 'constexpr' to be a part of the type and ignores the xml attribute O_o + if removed_constexpr and not context.xml_only: + type.text = rf'constexpr {type.text}' + # re-sort members to override Doxygen's weird and stupid sorting 'rules' if 1: sort_members_by_name = lambda tag: tag.find(r'name').text diff --git a/requirements.txt b/requirements.txt index cf2cded..e6b5f43 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ pygments html5lib lxml pytomlpp -schema +schema!=0.7.5