Python Visual Studio Code autoDocstring Configuration

Question:

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.

Asked By: syth3

||

Answers:

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.

Answered By: Roger Veciana

This answer is almost the same as PyCharm generates on vscode with this shortcut
ctrl+sfhit+2

{
    "autoDocstring.docstringFormat": "sphinx"
}
Answered By: cita