如何在Python 2中使用reStructuredText记录多个返回值? [英] How to document multiple return values using reStructuredText in Python 2?

查看:73
本文介绍了如何在Python 2中使用reStructuredText记录多个返回值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python文档说,用于Python文档的标记是 reStructuredText 。我的问题是:应该如何编写块注释以显示多个返回值?

The Python docs say that "the markup used for the Python documentation is reStructuredText". My question is: How is a block comment supposed to be written to show multiple return values?

def func_returning_one_value():
    """Return just one value.

    :returns: some value
    :rtype: str
    """

def func_returning_three_values():
    """Return three values.

    How do I note in reStructuredText that three values are returned?
    """

我发现了关于使用reStructuredText的Python文档的指南,但是它没有用于记录多个返回值的示例。 有关域的Sphinx文档讨论了回报 rtype ,但不讨论多个返回值。

I've found a tutorial on Python documentation using reStructuredText, but it doesn't have an example for documenting multiple return values. The Sphinx docs on domains talks about returns and rtype but doesn't talk about multiple return values.

推荐答案

如注释中提到的wwi,未严格定义要使用的详细格式。

As wwi mentioned in the comments, the detailed format to be used is not strictly defined.

对于我自己,我通常使用您在上方使用的字段列表表示法样式。它支持换行符,因此只需在您认为必要的地方中断即可。

For myself, I usually use the Field List notation style you use above. It supports line breaks, so just break where you feel is necessary

def my_func(param1, param2):
    """
    This is a sample function docstring

    :param param1: this is a first param
    :param param2: this is a second param
    :returns: tuple (result1, result2) 
        WHERE
        str result1 is .... 
        str result2 is ....        
    """

这篇关于如何在Python 2中使用reStructuredText记录多个返回值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆