Skip to content

Instantly share code, notes, and snippets.

@thmsklngr
Created November 19, 2020 19:50
Show Gist options
  • Save thmsklngr/e17acb43583120370fd14a89775c3b4a to your computer and use it in GitHub Desktop.
Save thmsklngr/e17acb43583120370fd14a89775c3b4a to your computer and use it in GitHub Desktop.
VSCode autodocstring template with alternative (and easy to read) syntax
{{! Template according https://dorukkilitcioglu.com/2018/08/18/python-better-docstring.html }}
{{! Doruk Docstring Template }}
{{summaryPlaceholder}}
{{extendedSummaryPlaceholder}}
{{#argsExist}}
Args:
{{#args}}
{{&var}}::{{&typePlaceholder}}
{{descriptionPlaceholder}}
{{/args}}
{{/argsExist}}
{{#kwargsExist}}
Keyword args:
{{#kwargs}}
{{var}}::{{typePlaceholder}}(={{&default}})
{{descriptionPlaceholder}}
{{/kwargs}}
{{/kwargsExist}}
{{#returnsExist}}
Returns:
{{#returns}}
{{typePlaceholder}}
{{descriptionPlaceholder}}
{{/returns}}
{{/returnsExist}}
{{#yieldsExist}}
Yields:
{{#yields}}
{{typePlaceholder}}
{{descriptionPlaceholder}}
{{/yields}}
{{/yieldsExist}}
{{#exceptionsExist}}
Raises:
{{#exceptions}}
{{type}}
{{descriptionPlaceholder}}
{{/exceptions}}
{{/exceptionsExist}}
@thmsklngr
Copy link
Author

I created this mustache template for using it with Python Docstring Generator.
Just copy it to any directory and edit your settings.json:

{
...
    "autoDocstring.customTemplatePath": "/path/to/your/project/.vscode/doruk.mustache"
}

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