x0x*_*x0x 6 python documentation coding-style docstring pycharm
PyCharm,当我开始在docstring中输入时,Python IDE会为docstring生成一个模板.这是为简单函数生成的模板.
def add_them(x, y):
"""
:param x:
:param y:
:return:
"""
z = x + y
return z
Run Code Online (Sandbox Code Playgroud)
我没有发现它类似于Python的官方文档字符串约定.
此模板是否与readthedocs等任何文档生成器一起使用?
有人如何有效使用?
填写模板的正确方法是什么?
谢谢.
ste*_*ieb 12
我们将它与sphinx-apidoc一起使用来生成我们的HTML和PDF文档.
以下是我如何使用docstrings的示例:
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
"""
Run Code Online (Sandbox Code Playgroud)