Python PyCharm'有什么用;s文档字符串模板?我如何有效地使用它?

Python PyCharm'有什么用;s文档字符串模板?我如何有效地使用它?,python,coding-style,documentation,pycharm,docstring,Python,Coding Style,Documentation,Pycharm,Docstring,PyCharm,Python IDE在我开始键入docstring时为docstring生成一个模板。这是为简单函数生成的模板 def add_them(x, y): """ :param x: :param y: :return: """ z = x + y return z 我发现它与Python的官方文档字符串没有任何相似之处 此模板是否可用于readthedocs等文档生成器 人们如何有效地使用 填写模板的正确方法是什么 谢

PyCharm,Python IDE在我开始键入docstring时为docstring生成一个模板。这是为简单函数生成的模板

def add_them(x, y):
    """

    :param x: 
    :param y: 
    :return:
    """
    z = x + y
    return z
我发现它与Python的官方文档字符串没有任何相似之处

此模板是否可用于readthedocs等文档生成器

人们如何有效地使用

填写模板的正确方法是什么


谢谢。

我们将其与sphinx apidoc一起使用,以生成HTML和PDF文档

下面是我如何使用docstring的示例:

def add_pdr(process, userid, log):
    """ Create and perform the target account operation PDR

    If the function/method is complex, I'd put a short one-line
    summary in the first line above, and a more detailed explanation
    here.

    :param dict process: dict of process details
    :param str userid: userid to perform actions on
    :param obj log: log object to perform logging to

    :raises KeyError: if the userid doesn't exist
    :raises APIError: if process dict is invalid

    :return: True on success, False upon failure

    """

您是否也可以用
异常的示例更新答案?添加的异常/引发的示例是用户输入的参数类型还是自动生成的?很抱歉,我非常喜欢这个“模板”。但是,您是否建议同时使用
:rtype
来指定返回变量的类型?@RayKoopa Yes。我们也经常使用
:rtype