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

Extend Google list sections with more section types #466

Open
mensonen opened this issue Nov 17, 2022 · 2 comments
Open

Extend Google list sections with more section types #466

mensonen opened this issue Nov 17, 2022 · 2 comments

Comments

@mensonen
Copy link

The Google list sections recognises currently only "Args", "Raises" and "Attributes" as headers for sections that consist of a definition list. This could be extended to recognise more section headers, similar to what sphinx already does.

The list of sections that sphinx supports is quite extensive, but I'd suggest at least adopting "Keyword Args", "Keyword Arguments", "Yields" and "Examples". The "Yields" header is specifically mentioned by Google as an alternative to "Returns", and I have seen "Examples" mentioned in older versions of the style guide. The keyword arguments are not specified by Google as such, but are widely used.

There are also other list-type sections on the Sphinx list, so implementing as much as possible would improve Sphinx compatibility a lot.

@mhils
Copy link
Member

mhils commented Dec 3, 2022

Contributions are welcome here, the relevant code is in https://github.com/mitmproxy/pdoc/blob/main/pdoc/docstrings.py. :) That being said, my general take here is that type info should live in the type annotation, and then the sections do render fine already. I don't mind additions that come with test coverage though!

@ntamas
Copy link
Contributor

ntamas commented Jan 3, 2023

I've started addressing an issue similar to this in #489; my use-case is that I have a large codebase spanning several repositories where the docstrings are Google-styled but they use "Parameters" instead of "Args" in the headings. PR #489 could be extended to support the alternatives listed in this issue.

Note that according to my experience, "Yields" is correctly handled by pdoc because it is a section whose body is not a list; pdoc already converts the header to a Markdown header. "Keyword Args" would need special treatment, and "Keyword Arguments" could be aliases to "Keyword Args" in PR #489.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants