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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

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
@@ -456,7 +456,7 @@ def parse_name(self) -> bool:
self.modname = modname
self.args = args
self.retann = retann
self.fullname = '.'.join((self.modname or '', *self.objpath))
self.fullname = '.'.join([self.modname, *self.objpath])
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member Author

Choose a reason for hiding this comment

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

We have if not modname: return False just above, so when I checked the implementation of parse_name(), I've taken the liberty of cleaning up this one. Will revert tomorrow and address it in a follow-up PR (I'm quite tight on schedule for the next few days).

@picnixz picnixz requested a review from AA-Turner January 19, 2025 10:01
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