Skip to content

Conversation

@AA-Turner
Copy link
Contributor

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

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
Contributor Author

Please can someone approve the workflows?

@codecov
Copy link

codecov bot commented Nov 4, 2025

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 5 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
Copy link
Member

pllim commented Nov 4, 2025

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
Copy link
Contributor Author

AA-Turner commented Nov 4, 2025

@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

Copy link
Member

@pllim pllim left a comment

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
Copy link
Member

pllim commented Nov 4, 2025

xref astropy/sphinx-astropy#86

@bsipocz
Copy link
Member

bsipocz commented Nov 4, 2025

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
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
Copy link
Member

bsipocz commented Nov 4, 2025

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

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