Skip to content

Fix incomplete cleanup in autodoc_enhancements.py - #224

Merged
pllim merged 3 commits into
astropy:mainfrom
AA-Turner:cleanups
Nov 4, 2025
Merged

pllim merged 3 commits into
astropy:mainfrom
AA-Turner:cleanups

Conversation

@AA-Turner

@AA-Turner AA-Turner commented Nov 4, 2025 •

Copy link
Copy Markdown
Contributor

cc @pllim @bsipocz

This removes vestigal code left over from previous incomplete cleanups.

Previously, sphinx-automodapi redefined AttributeDocumenter and overwrote Sphinx's version with its own. See sphinx-doc/sphinx#1843, astropy/astropy-helpers#158.

This was removed in 412a801 (#88), but overriding Sphinx's AttributeDocumenter was retained for unclear reasons. This PR completes the cleanup.

Alternative to and would close #223. Also fix #222

A

@AA-Turner

Copy link
Copy Markdown
Contributor Author

Please can someone approve the workflows?

@codecov

codecov Bot commented Nov 4, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.42105% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.62%. Comparing base (1b47aca) to head (e15207f).
⚠️ Report is 31 commits behind head on main.

Files with missing lines Patch % Lines
sphinx_automodapi/automodsumm.py 75.00% 3 Missing ⚠️
sphinx_automodapi/utils.py 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #224      +/-   ##
==========================================
- Coverage   89.69%   89.62%   -0.08%     
==========================================
  Files          31       31              
  Lines        1262     1253       -9     
==========================================
- Hits         1132     1123       -9     
  Misses        130      130              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pllim

pllim commented Nov 4, 2025

Copy link
Copy Markdown
Member

I think this is hitting one of the errors I saw in #223 that I do not understand.

      File "sphinx/events.py", line 402, in emit
        raise ExtensionError(
        ...<4 lines>...
        ) from exc
    sphinx.errors.ExtensionError: Handler <function process_automodsumm_generation at 0x7f73f1415580>
        for event 'builder-inited' threw an exception (exception: 'class')

@AA-Turner

AA-Turner commented Nov 4, 2025 •

Copy link
Copy Markdown
Contributor Author

@pllim slightly hubristicly, I put up this PR without running tests, as I didn't want to set up a full environment for the project!

Using Sphinx's --pdb flag, we can see that the second problem is the following:

      File "...\sphinx-automodapi\sphinx_automodapi\utils.py", line 256, in get_documenter
        retval = app.registry.documenters[obj_type]
                 ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
    KeyError: 'class'

I've thus applied the suggestion I made elsewhere to change the vendored get_documenter() function to get_object_type(), which works for me locally.

A

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thank you very much! This is much cleaner than what I came up with, and appears to make all Sphinx versions under test happy. Appreciate the help.

@pllim
pllim merged commit 46c4db6 into astropy:main Nov 4, 2025
18 of 20 checks passed
@AA-Turner
AA-Turner deleted the cleanups branch November 4, 2025 20:22
@pllim

pllim commented Nov 4, 2025

Copy link
Copy Markdown
Member

xref astropy/sphinx-astropy#86

@bsipocz

bsipocz commented Nov 4, 2025

Copy link
Copy Markdown
Member

Thank you so much @AA-Turner!

Using Sphinx's --pdb flag, we can see that the second problem is the following:
And @pllim - I think we should add this to tox command; less cryptic errors would be such and improvement here :)

@AA-Turner

Copy link
Copy Markdown
Contributor Author

I'm not sure it would help, it's for interactive debugging only: https://www.sphinx-doc.org/en/master/man/sphinx-build.html#cmdoption-sphinx-build-P

@bsipocz

bsipocz commented Nov 4, 2025

Copy link
Copy Markdown
Member

I'm not sure it would help, it's for interactive debugging only: sphinx-doc.org/en/master/man/sphinx-build.html#cmdoption-sphinx-build-P

Ahh, never mind it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

COMP: sphinx-dev failure with "cannot import name 'AttributeDocumenter' from 'sphinx.ext.autodoc"

3 participants