简体   繁体   English

Python 模块参考与 Sphinx 文档

[英]Python module reference with Sphinx documentation

Let's considere the following function :让我们考虑以下功能:

def format_send_event(self, message_identifier, payload=""):
    """
    Format a SendEvent.

    :param message_identifier: Message identifier (defined in the :py:module:`MyModule.constants` file).
    :type message_identifier: int
    :param payload: Payload of the message.
    :type payload: str
    """
    # Do something

When I compile it with sphinx-build, I have the following error :当我用 sphinx-build 编译它时,出现以下错误:

...MyModule/handlers.py:docstring of MyModule.handlers.MyClass.format_send_event:3: ERROR: Unknown interpreted text role "py:module".

It looks like the sphinx-builder is unable to understand the tag :py:module: .看起来 sphinx-builder 无法理解标签:py:module:

What is the tag used for referencing a module in Sphinx ?在 Sphinx 中用于引用模块的标签是什么?

According to the documentation , you should use :py:mod: to cross-reference.根据文档,您应该使用:py:mod:进行交叉引用。

Generally the shorter versions of tags seem to be used to cross-reference, and longer names to document.通常,较短版本的标签似乎用于交叉引用,而较长的名称用于文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM