Skip to content
vscode extension that generates docstrings for python files
TypeScript HTML
Branch: master
Clone or download
Pull request Compare This branch is 13 commits behind NilsJPWerner:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Build Status Installs Rating

VSCode autoDocstring

Visual Studio Code extension to quickly generate docstrings for python functions.

Auto Generate Docstrings


  • Quickly generate a docstring snippet that can be tabbed through.
  • Choose between several different types of docstring formats.
  • Infers parameter types through pep484 type hints, default values, and var names.
  • Support for args, kwargs, decorators, errors, and parameter types

Docstring Formats

  • Default (docBlockr)
  • Google
  • Numpy
  • Sphinx
  • PEP0257 (coming soon)


Cursor must be on the line directly below the definition to generate full auto-populated docstring

  • Press enter after opening docstring with triple quotes (""" or ''')
  • Keyboard shortcut: ctrl+shift+2 or cmd+shift+2 for mac
    • Can be changed in Preferences -> Keyboard Shortcuts -> extension.generateDocstring
  • Command: Generate Docstring
  • Right click menu: Generate Docstring

Extension Settings

This extension contributes the following settings:

  • autoDocstring.docstringFormat: Switch between different docstring formats
  • autoDocstring.customTemplatePath: Path to a custom docstring template (absolute or relative to the project root)
  • autoDocstring.generateDocstringOnEnter: Generate the docstring on pressing enter after opening docstring
  • autoDocstring.includeExtendedSummary: Include extended summary section in docstring
  • autoDocstring.includeName: Include function name at the start of docstring
  • autoDocstring.startOnNewLine: New line before summary placeholder
  • autoDocstring.guessTypes: Infer types from type hints, default values and variable names
  • autoDocstring.quoteStyle: The style of quotes for docstrings

Custom Docstring Templates

autoDocstring now supports custom templates. The extension uses the mustache.js templating engine. To use a custom template create a .mustache file and specify its path using the customTemplatePath configuration. View the included google docstring template for a usage example. The following tags are available for use in custom templates.


{{name}}                        - name of the function
{{summaryPlaceholder}}          - [summary] placeholder
{{extendedSummaryPlaceholder}}  - [extended_summary] placeholder


{{#args}}                       - iterate over function arguments
    {{var}}                     - variable name
    {{typePlaceholder}}         - [type] or guessed type  placeholder
    {{descriptionPlaceholder}}  - [description] placeholder

{{#kwargs}}                     - iterate over function kwargs
    {{var}}                     - variable name
    {{typePlaceholder}}         - [type] or guessed type placeholder
    {{&default}}                 - default value (& unescapes the variable)
    {{descriptionPlaceholder}}  - [description] placeholder

{{#exceptions}}                 - iterate over exceptions
    {{type}}                    - exception type
    {{descriptionPlaceholder}}  - [description] placeholder

{{#returns}}                    - iterate over returns
    {{typePlaceholder}}         - [type] placeholder
    {{descriptionPlaceholder}}  - [description] placeholder

Additional Sections

{{#argsExist}}          - display contents if args exist

{{#kwargsExist}}        - display contents if kwargs exist

{{#parametersExist}}    - display contents if args or kwargs exist

{{#exceptionsExist}}    - display contents if exceptions exist

{{#returnsExist}}       - display contents if returns exist

{{#placeholder}}        - makes contents a placeholder

Known Issues

  • *args & **kwargs not dealt with properly
  • Inserted docstrings have trailing spaces (problem with how vscode deals with snippets)
  • Doesn't include yields and decorators


Check the for any version changes.


The source code for this extension is hosted on GitHub. Contributions, pull requests, suggestions, and bug reports are greatly appreciated.

  • Post any issues and suggestions to the github issues page. Add the feature request tag to any feature requests or suggestions.
  • To contribute, fork the project and then create a pull request back to master. Please update the README if you make any noticeable feature changes.
  • There is no official contribution guide or code of conduct yet, but please follow the standard open source norms and be respectful in any comments you make.


This project is licensed under the MIT License - see the LICENSE file for details

You can’t perform that action at this time.