Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autodoc: fix ordering of class and static methods for groupwise order #13201

Merged
merged 10 commits into from
Jan 20, 2025

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Jan 1, 2025

I don't have an issue yet (but I'll create one and update the changelog once I'm done) but I've found the issue while working on #13200.

Class and static methods were meant to be ordered before regular methods when using groupwise order but this was not respected until now. The reason is that we call sort_members before calling generate (which is fine). However, generate() actually calls import_object which itself modifies member_order (because that's the first time we have the actual object and we can inspect it without relying on static analysis).

So, we need to decouple import_object from generate. To avoid breaking stuff for now, I've added a private _generate() method which is the actual implementation of generate() so that I can call it separately. Current uses of generate() remain the same.

@picnixz picnixz requested a review from AA-Turner January 1, 2025 10:06
@picnixz picnixz requested a review from AA-Turner January 19, 2025 10:01
Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

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

Looks good! As noted in the PR description, this should have some documentation (at least a CHANGES entry).

A

sphinx/ext/autodoc/__init__.py Outdated Show resolved Hide resolved
@picnixz
Copy link
Member Author

picnixz commented Jan 19, 2025

Looks good! As noted in the PR description, this should have some documentation (at least a CHANGES entry).

Yes, I planned to do that but I wanted to first hear your thoughts on this. I'll open a separate issue if you want but I'll definitely add the CHANGELOG and update the docs.

@AA-Turner
Copy link
Member

No need for a distinct issue.

@picnixz picnixz requested a review from AA-Turner January 20, 2025 10:10
@AA-Turner AA-Turner merged commit 5b9fb9e into sphinx-doc:master Jan 20, 2025
22 checks passed
@AA-Turner AA-Turner added this to the 8.2.0 milestone Jan 20, 2025
@picnixz picnixz deleted the fix/autodoc/ordering branch January 20, 2025 15:29
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.

2 participants