Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Visual Studio Code autoDocstring Configuration

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.

like image 750
syth3 Avatar asked Aug 06 '18 22:08

syth3


People also ask

What is Python Docstring generator?

Python documentation strings (or docstrings) provide a convenient way of associating documentation with Python modules, functions, classes, and methods. It's specified in source code that is used, like a comment, to document a specific segment of code.

How do I indent a Python extension?

How it works. Every time you press the Enter key in a python context, this extension will parse your python file up to the location of your cursor, and determine exactly how much the next line (or two in the case of hanging indents) should be indented and how much nearby lines should be un-indented.


1 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.

like image 76
Roger Veciana Avatar answered Sep 18 '22 05:09

Roger Veciana