修改了 vscode 中的狮身人面像样式文档字符串



All, 我正在VSCode和Pycharm中尝试这个。本质上,我想修改自动生成的文档字符串的样式。在VSCode中,我正在使用扩展 - "Python Docstring Generator"。目前将其设置为狮身人面像会生成类似这样的东西:

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

相反,我希望发生的是这样的:

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

有人可以帮助我在Pycharm或VSCode中实现这一目标吗?

看起来您可以从文档中指定自定义模板

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}}

最新更新