Skip to content

Commit

Permalink
fix doxygen bug that erroneously treats keywords as part of return types
Browse files Browse the repository at this point in the history
also:
- blacklisted schema 0.7.5 because it's broken
  • Loading branch information
marzer committed Dec 12, 2021
1 parent 8fc6d48 commit a142ccd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
2 changes: 1 addition & 1 deletion poxy/data/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.2
0.5.3
34 changes: 34 additions & 0 deletions poxy/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'

This comment has been minimized.

Copy link
@marzer

marzer Apr 14, 2022

Author Owner

@mosra I forgot to ping you about this, only just remembered it re-reading the code now. The gist of it is that this code is fixing the XML in situations where Doxygen has mistakenly included some specifier/attribute as part of the type (e.g. constexpr float instead of just float), removing it and setting the corresponding XML attribute instead.

The # hack: bit deals with an edge case where m.css seemed to actually break when I did this for constexpr specifically, ignoring the doxygen XML attribute constexpr="yes", and instead assumed that doxygen always got it wrong in the XML. It didn't happen in all cases,I think maybe only when the function was also a friend or similar? My guess was that the doxygen attribute is newer and m.css wasn't aware of it (or at least wasn't in the fork I'm using)

When I spend some time with poxy this weekend I'll try to give you a proper repro/bug report.

This comment has been minimized.

Copy link
@mosra

mosra Apr 14, 2022

Yep it seems to be "new" (well, probably newer than all the nasty workarounds I made there): doxygen/doxygen@6a1b370

I don't think m.css even works with pre-1.8.16 anymore, so I guess these workarounds should be cleaned up and the XML attribute used instead. OTOH, IIRC the constexpr workaround code is still covered when running the tests which makes me think that Doxygen still has this area half-assed somehow. At least in the versions I test on, so 1.8.16+.

If you can convert this to an issue so I don't forget, that'd be great 👍

This comment has been minimized.

Copy link
@marzer

marzer Apr 14, 2022

Author Owner

Doxygen still has this area half-assed somehow.

Yeah, likely. There's definitely more to it than I can exactly remember at the moment. I vaguely recall it was only occurring in a very specific situation, like a friend function inside a member @name block.

If you can convert this to an issue so I don't forget, that'd be great 👍

Roger that red leader


# 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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ pygments
html5lib
lxml
pytomlpp
schema
schema!=0.7.5

0 comments on commit a142ccd

Please sign in to comment.