Skip to content

BUG: Refresh wrapping docstrings when Doxygen reruns - #7229

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
dzenanz:wrapping-docstring-citations
Nov 25, 2026
Merged

hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
dzenanz:wrapping-docstring-citations

Conversation

@dzenanz

@dzenanz dzenanz commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Python docstrings were not regenerated when Doxygen reran, so wheels kept stale text. With bibtex, citations also became bare [N] labels; docstrings now show the citation key and a References list.

Root cause and design
  • Stale docstrings. Each _doc.i command in generate_wrap_doc() depended only on the <module>Doxygen target. A target dependency orders the build but never reruns the command, and the XML files cannot be listed because Doxygen does not declare them as outputs. The command now also depends on <module>Doxygen.stamp, which doxygen_add_docs(... USE_STAMP_FILE) documents as touched on every Doxygen run, and on doxy2swig.py, which itk_doxy2swig.py imports.

  • No needless SWIG reruns. itk_doxy2swig.py leaves a docstring file untouched when its text is unchanged, and Ninja's restat then skips SWIG for it. With Makefile or Visual Studio generators such a file stays older than the stamp, so its doxy2swig command reruns on later builds; SWIG still does not.

  • Citations. With bibtex, Doxygen writes each \cite as <ref refid="citelist_1CITEREF_key">[N]</ref>; N only indexes Doxygen's own bibliography page. Without bibtex it writes the key. Docstrings now show the key in both cases and, when Doxygen produced citelist.xml, end with the cited entries:

    The marching squares algorithm is a special case of the marching cubes
    algorithm lorensen1987. ...
    
    References:
    
    lorensen1987: William E. Lorensen and Harvey E. Cline. Marching cubes:
    A high resolution 3D surface construction algorithm
    (https://doi.org/10.1145/37402.37422). Computer Graphics,
    21(4):163-169, 1987.
    

    Keys taken from the reference id are lowercase, because the wrapping Doxygen configuration sets CASE_SENSE_NAMES=NO on every platform.

Testing

Windows, CMake 4.5.1, Ninja, MSVC 14.44, Doxygen 1.13.2, bibtex from MiKTeX. Minimal build of ITKPath, Strain and IsotropicWavelets with ITK_WRAP_PYTHON=ON and ITK_WRAP_DOC=ON, together with #7230's branch:

  • 73 of 538 _doc.i files have a References list; none contain an [N] label.
  • After editing the comment of itkContourExtractor2DImageFilter.h, only itkContourExtractor2DImageFilter_doc.i was rewritten; the other six ITKPath docstring files kept their timestamps.
  • A small Doxygen project run with and without bibtex on PATH gives the same inline text; only the bibtex run adds References.
  • New PythonDoxy2SwigCitationTest converts a small Doxygen XML class with and without citelist.xml and checks the inline keys, the References list (a repeated citation is listed once), and that unchanged output keeps its timestamp. It needs neither Doxygen nor ITK_WRAP_DOC, and it fails with the converter from before this change.
  • ctest -R "Python|Strain|Wavelet|Riesz|Path": 214 of 215 pass; PythonLazyImportTime also fails with the 6.0b3 wheels.
  • help() of itk.ContourExtractor2DImageFilter shows the key and the References list.

Not tested on Linux or macOS.

AI assistance

Claude Code (Opus 5.5) traced the stale docstrings in a wheel build log to the dependency, wrote the change, and ran the builds above.

🤖 Generated with Claude Code

@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances area:Python wrapping Python bindings for a class labels Nov 23, 2026
@dzenanz
dzenanz marked this pull request as ready for review November 23, 2026 16:39
@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect Python documentation generation across ITK wrapping builds.

The PR appears safe to merge, with a non-blocking request for focused converter tests.

Findings

  1. P2 Citation changes lack tests ▶

Summary

The PR refreshes Python docstrings after Doxygen reruns and adds readable bibliography entries.

  • Doxygen updates now refresh generated Python docstrings.
  • Python docstrings show citation keys and their source entries.
  • Unchanged docstring output keeps its timestamp.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  D[Doxygen run] --> X[XML and bibliography]
  D --> T[Doxygen stamp]
  T --> C[Docstring converter]
  X --> C
  C --> Q{Text changed?}
  Q -->|Yes| I[Rewrite docstring file]
  I --> S[Rebuild SWIG output]
  Q -->|No| K[Keep file timestamp]
Loading

Reviews (1) · Last reviewed commit: "BUG: Refresh wrapping docstrings when Do..." · Reviewed by Greptile

The doxy2swig commands depended only on each module's Doxygen target,
which orders the build but does not trigger a rerun, so docstrings kept
the text of their first build. They now also depend on the target's
stamp file. A docstring file is rewritten only when its text changes,
so SWIG reruns only for those submodules.

With bibtex, Doxygen turns each \cite into an [N] label that indexes its
HTML bibliography. Docstrings show the citation key instead and end
with a References list taken from Doxygen's citelist.xml.

PythonDoxy2SwigCitationTest converts a small Doxygen XML class with and
without citelist.xml, and checks that unchanged output keeps its
timestamp. It needs neither Doxygen nor ITK_WRAP_DOC.
@dzenanz
dzenanz force-pushed the wrapping-docstring-citations branch from d9d963d to 24f0343 Compare November 23, 2026 21:32
@github-actions github-actions Bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct labels Nov 23, 2026
@hjmjohnson
hjmjohnson merged commit 6539670 into InsightSoftwareConsortium:main Nov 25, 2026
19 checks passed
@dzenanz
dzenanz deleted the wrapping-docstring-citations branch November 25, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Python wrapping Python bindings for a class type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants