UGuntupalli
UGuntupalli

Reputation: 849

Modified sphinx style docstrings in vscode

All, I am trying this both in VSCode as well as Pycharm. Essentially I want to modify the style of my auto generated docstring. In VSCode, I am using the extension - "Python Docstring Generator". Currently setting it to sphinx generates some thing like this:

def test(a, b):
    """
    :param a: 
    :type a:
    :param b:
    :type b:
    :return:
    :rtype:
    """

What I would instead like to happen is this:

def test(a, b):
    """
    :param type a: 
    :param type b:
    :return:
    :rtype:
    """

Could somebody help me achieve this either in Pycharm or VSCode ?

Upvotes: 0

Views: 825

Answers (1)

mmann1123
mmann1123

Reputation: 5295

Looks like you can specify a custom template, from the docs

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

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

Sections

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

Upvotes: 1

Related Questions