marzer / poxy

Documentation generator for C++
https://pypi.org/project/poxy
MIT License
138 stars 5 forks source link

Error on memberdef without 'name' in 0.19.1 #39

Closed tim-janik closed 1 week ago

tim-janik commented 1 week ago

Describe the bug

Building the Anklang docs failed once we switched to Ubuntu 24.04:

https://github.com/tim-janik/anklang/actions/runs/11767824810/job/32776946290

Poxy failes to sort meberdefs in postprocessing:

Post-processing XML files

*************

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/poxy/main.py", line 623, in main
    run(
  File "/usr/local/lib/python3.12/dist-packages/poxy/run.py", line 1801, in run
    postprocess_xml(context)
  File "/usr/local/lib/python3.12/dist-packages/poxy/run.py", line 770, in postprocess_xml
    group.sort(key=sort_members_by_name)
TypeError: '<' not supported between instances of 'str' and 'NoneType'

*************

You appear to have triggered an internal bug!
Please re-run poxy with --bug-report and file an issue at github.com/marzer/poxy/issues
Many thanks!

*************

Environment

The environment for this poxy run is built via the following Dockerfile: https://github.com/tim-janik/anklang/blob/trunk/misc/Dockerfile.noble

$ poxy --version 0.19.1

Additional information

For now, I am applying the following patch:

--- ./usr/local/lib/python3.12/dist-packages/poxy/run.orig  2024-11-10 19:50:41.858752777 +0000
+++ ./usr/local/lib/python3.12/dist-packages/poxy/run.py    2024-11-10 19:50:50.478776979 +0000
@@ -746,7 +746,7 @@

                     # 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
+                        sort_members_by_name = lambda tag: tag.find(r'name').text or ''
                         members = [tag for tag in section.findall(r'memberdef')]
                         for tag in members:
                             section.remove(tag)

Which works around the issue.

--bug-report

poxy_bug_report.zip

marzer commented 1 week ago

Thanks for the report! Can you show me the C or C++ code that was parsed to cause this? Or a reduced reproduction of it? I'd like to understand a bit more what is happening here before I apply your patch.

tim-janik commented 1 week ago

Thanks for the report! Can you show me the C or C++ code that was parsed to cause this? Or a reduced reproduction of it? I'd like to understand a bit more what is happening here before I apply your patch.

My patch is just a workaround for our CI, I'm not claiming that it is the proper fix... If you want to take a peak at the generated Doxygen output, you can just reporduce the steps our CI applies: doc/poxy.sh -b

It is containerized, so you can reproduce it locally with this:

git clone --recurse-submodules  git@github.com:tim-janik/anklang.git && cd anklang
docker run -ti --rm -v $PWD:/hostwd -w /hostwd ghcr.io/tim-janik/anklang-ci:noble-latest  make -j`nproc`
docker run -ti --rm -v $PWD:/hostwd -w /hostwd ghcr.io/tim-janik/anklang-ci:noble-latest  doc/poxy.sh -b
marzer commented 1 week ago

Ah, turns out there's no need. I was able to determine the cause from the logs: class Ase::Driver contains an enum Flags which (I assume) is specified using some flavour of unnamed C-style enum, e.g. enum { /*... */ };. This causes doxgen to emit the name field as simply <name></name>, which was not a scenario I was accounting for. So (a version of) your fix is actually perfectly fine, since there's not really anything else sensible to be done here 😄

marzer commented 1 week ago

Should be fixed in v0.19.3, thanks :)