简体   繁体   中英

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 :

...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: .

What is the tag used for referencing a module in Sphinx ?

According to the documentation , you should use :py:mod: to cross-reference.

Generally the shorter versions of tags seem to be used to cross-reference, and longer names to document.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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