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

Returns and Raises switched on Google docstring template #244

Open
irenepc opened this issue Oct 3, 2022 · 2 comments
Open

Returns and Raises switched on Google docstring template #244

irenepc opened this issue Oct 3, 2022 · 2 comments
Labels

Comments

@irenepc
Copy link

irenepc commented Oct 3, 2022

According to the style guide, Returns should be outlined prior to Raises in google style docstring, yet when I generate one that has both, the Raises appear before the returns
https://google.github.io/styleguide/pyguide.html
The same can be seen in this example .mustache in the repo
https://github.com/NilsJPWerner/autoDocstring/blob/HEAD/src/docstring/templates/google.mustache

  • autoDocstring Version: 0.6.1
  • Operating System:
  • Vscode Version: 1.71.2

Thanks for a great extension!

@irenepc irenepc added the bug label Oct 3, 2022
@irenepc
Copy link
Author

irenepc commented Oct 3, 2022

I think these changes to the .mustache fix the issue.

{{! Google Docstring Template }}
{{summaryPlaceholder}}

{{extendedSummaryPlaceholder}}
{{#parametersExist}}

Args:
{{#args}}
    {{var}} ({{typePlaceholder}}): {{descriptionPlaceholder}}
{{/args}}
{{#kwargs}}
    {{var}} ({{typePlaceholder}}, optional): {{descriptionPlaceholder}}. Defaults to {{&default}}.
{{/kwargs}}
{{/parametersExist}}
{{#returnsExist}}

Returns:
{{#returns}}
    {{typePlaceholder}}: {{descriptionPlaceholder}}
{{/returns}}
{{/returnsExist}}
{{#exceptionsExist}}

Raises:
{{#exceptions}}
    {{type}}: {{descriptionPlaceholder}}
{{/exceptions}}
{{/exceptionsExist}}
{{#yieldsExist}}

Yields:
{{#yields}}
    {{typePlaceholder}}: {{descriptionPlaceholder}}
{{/yields}}
{{/yieldsExist}}

@DavidTWynn
Copy link

DavidTWynn commented Dec 25, 2022

Yes, I see the same thing. Using your template worked for me. One other thing is the style guide says a period after the summaryPlaceholder on line one. These are my first 2 lines:

{{! Google Docstring Template }}
{{summaryPlaceholder}}.

It looks like there are some other things missing from the Google style. Section 3.8 describes what to do for google python docstrings, and in 3.8.4 it says when documenting a class to use the 'Attributes:' marker for public attributes of the class. From a quick check of the template_data.ts, I did not see that attributes are being looked for.

Also, if it were to be added I see it doesn't detect the arguments/attributes currently for dataclasses or Pydantic.

Here is the google template without typing:

{{! Google Docstring Template without Types for Args, Returns or Yields }}
{{summaryPlaceholder}}.

{{extendedSummaryPlaceholder}}
{{#parametersExist}}

Args:
{{#args}}
    {{var}}: {{descriptionPlaceholder}}
{{/args}}
{{#kwargs}}
    {{var}}: {{descriptionPlaceholder}}. Defaults to {{&default}}.
{{/kwargs}}
{{/parametersExist}}
{{#returnsExist}}

Returns:
{{#returns}}
    {{descriptionPlaceholder}}
{{/returns}}
{{/returnsExist}}
{{#yieldsExist}}

Yields:
{{#yields}}
    {{descriptionPlaceholder}}
{{/yields}}
{{/yieldsExist}}
{{#exceptionsExist}}

Raises:
{{#exceptions}}
    {{type}}: {{descriptionPlaceholder}}
{{/exceptions}}
{{/exceptionsExist}}

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

No branches or pull requests

2 participants