【问题标题】:Modified sphinx style docstrings in vscode在 vscode 中修改了 sphinx 样式的文档字符串
【发布时间】:2020-05-11 17:30:17
【问题描述】:

所有, 我在 VSCode 和 Pycharm 中都在尝试这个。本质上,我想修改自动生成的文档字符串的样式。在 VSCode 中,我使用的是扩展名 - “Python Docstring Generator”。当前将其设置为 sphinx 会生成如下内容:

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 中实现这一点吗?

【问题讨论】:

  • BUMP .. 寻求帮助

标签: python-3.x pycharm vscode-settings docstring


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 2019-07-30
    • 2012-02-18
    • 2022-11-22
    相关资源
    最近更新 更多