Sphinx,在函数docstring中引用类

时间:2017-12-15 15:33:53

标签: reference python-sphinx docstring

编辑:首先,我很抱歉,我发现这是来自here的未答复问题的副本。 我添加了完整的示例代码和html输出的图像。

我使用sphinx来记录python项目。我有一个提升多个自定义异常的函数。所以我的代码看起来像这样:

class MyException1(Exception):
    """
    My Exception 1
    """
    pass


class MyException2(Exception):
    """
    My Exception 2
    """
    pass

def process_finished(path):
    """
    Description

    :param path: Path to the finished file
    :type path: string
    :returns: None
    :raises MyException1: My first exception
    :raises MyException2: My second exception
    """
    print(path)

def process_finished2(path):
    """
    Description

    :param path: Path to the finished file
    :type path: string
    :returns: None
    :raises: :exc:`MyException1`: My first exception
    :raises: :exc:`MyException2`: My second exception
    """
    print(path)

输出为html然后如下所示: output html

我关注的是引发功能块process_finishedprocess_finished2。我希望文档在第一个函数中看起来像,但例外是process_finished2中的引用。

我认为默认情况下使用sphinx是不可能的,尽管这可以在没有任何引用返回类型的情况下工作。谢谢你的帮助。

0 个答案:

没有答案
相关问题