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

Add support for alternative section names in Google docstrings #489

Merged
merged 8 commits into from
Jan 6, 2023

Conversation

ntamas
Copy link
Contributor

@ntamas ntamas commented Jan 3, 2023

This PR adds support for specifying alternative section names in Google docstrings that are to be interpreted as sections-of-lists, similarly to the standard "Args" section. Right now the PR aliases "Parameters" and "Params" to "Args"; these names are not standard but are often seen in the wild, especially in codebases that mix NumPy and Google-style docstrings (NumPy uses "Parameters" by default).

The PR could also partially fix the issue raised in #466 if we decided to add "Keyword Arguments" and "Keyword Args" such that "Keyword Args" is handled as-is and "Keyword Arguments" is aliased to "Keyword Args". That would require an additional commit that I'm happy to do if the maintainer agrees with the general direction of this PR.

@mhils
Copy link
Member

mhils commented Jan 6, 2023

Thanks for the PR! I could see some people being surprised that their sections are renamed by pdoc. Would it make more sense to add those alternatives to GOOGLE_LIST_SECTIONS ?

@ntamas
Copy link
Contributor Author

ntamas commented Jan 6, 2023

It definitely would; I went for this approach because currently the function also remaps Args to Arguments so I was thinking that the goal is to use "Arguments" as a sort-of standard section header. If you think that leaving the headings as-is is a better approach, I can update the PR to do so instead.

@mhils
Copy link
Member

mhils commented Jan 6, 2023

That's actually a fair point. Let's use "Arguments" for everything as you suggested and see if someone complains. While we're at it, would it make sense to add Arguments as an alias as well?

(also please add a changelog entry, thanks!)

Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

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

Awesome, thanks! 🍰

@mhils mhils enabled auto-merge (squash) January 6, 2023 21:26
@mhils mhils merged commit 0980a98 into mitmproxy:main Jan 6, 2023
@ntamas ntamas deleted the feat/more-google-docstring-headers branch January 6, 2023 21:34
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.

2 participants