Python Visual Studio Code autoDocstring Configuration

syth3 picture syth3 · Aug 7, 2018 · Viewed 7.7k times · Source

Goal: generate docstring in vscode for Python automatically and format the generated docstring to my liking.

Solution: I installed the autoDocstring extension.

Problem: I don't know how to get the generated docstring to be formatted the way I want it. In the description under the "Extension Settings" heading, it seems to suggest that you can change the default format with the "autoDocstring.docstringFormat" setting. My question is, how does one configure that setting? I've looked around and cannot find a solution.

Answer

Roger Veciana picture Roger Veciana · Sep 28, 2018

You have to go to:

File > Preferences > Settings in Windows/Linux

Code > Preferences > Settings in Mac

Then choose at the right side of the open document if you want to change the configuration for all the user sessions or only this workspace.

The workspace case would be:

{
    "autoDocstring.docstringFormat": "sphinx"
}

When moving the mouse around the option, a little pencil appears that shows all the accepted values for the option.