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

Move "Attributes" and "Methods" below "Parameters" #571

Merged
merged 5 commits into from
Jul 12, 2024

Conversation

lucascolley
Copy link
Contributor

@lucascolley lucascolley commented Jul 8, 2024

Reorder the sections in docscrape to match the style guide. As per https://numpydoc.readthedocs.io/en/latest/format.html#class-docstring, the Attributes section should be "located below the Parameters section", which I am interpreting as directly below. It seems wrong for Attributes to be below Notes, References and Examples.

x-ref scipy/scipy#21099

@larsoner
Copy link
Collaborator

larsoner commented Jul 8, 2024

@lucascolley can you look to see if there is some test that could be added or modified that would have caught this?

@lucascolley
Copy link
Contributor Author

this test

def test_class_members_doc_sphinx():
actually expects Examples to be above Attributes and Methods. So maybe the question of where they should go isn't settled. I think that we should either change the order in the code/tests (my preference - I don't see why See Also should be above Attributes, for example), or change the wording in the style guide.

@lucascolley
Copy link
Contributor Author

I opened gh-572 in case we need higher-level discussion.

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

FWIW I'm in favor of the change - class attributes and methods are typically key pieces of API, so ensuring that they render near the top of the docstring instead of being buried under the other sections seems like an improvement.

@lucascolley lucascolley requested a review from rossbar July 11, 2024 10:55
@lucascolley
Copy link
Contributor Author

could someone approve CI please? :)

@larsoner
Copy link
Collaborator

Done!

@lucascolley
Copy link
Contributor Author

apologies for the iteration, I was being lazy and not running the tests - they all pass locally for me now!

Copy link
Collaborator

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Seems like everyone is in favor so in it goes, thanks @lucascolley !

@larsoner larsoner merged commit 7716617 into numpy:main Jul 12, 2024
23 checks passed
@stefanv stefanv added this to the 1.8.0 milestone Jul 12, 2024
@lucascolley
Copy link
Contributor Author

thanks all!

@lucascolley lucascolley deleted the class-section-order branch July 12, 2024 14:55
QuLogic added a commit to QuLogic/matplotlib that referenced this pull request Aug 13, 2024
The numpydoc 1.8.0 release re-ordered some sections [1] in generated
docs, which caused our missing reference extension to no longer ignore
some entries since they are at different lines.

Fixes matplotlib#28715

[1] numpy/numpydoc#571
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.

5 participants