RestructuredText 中的文字“*”

A literal "*" in RestructuredText

我正在查看这段代码:

def ook(*args):
    """Some silly function.

    :param *args: Optional arguments.
    """
    ...

一旦我 运行 Sphinx,我就会得到非常有用的错误:

WARNING: Inline literal start-string without end-string.

所以,我尝试了 param ``*``argsparam :literal:'*' args,但仍然收到警告。

如何在 restructuredText 中使用文字“*”?

您可以使用(有点难看的)反斜杠引号:\*

编辑:作为(有点难看的)附录,如果您担心有关反斜杠的 pylint 警告,您可以在字符串文字中添加 rr""" ... docstring ... """this pylint issue.

中对此进行了描述

让不同的文本处理系统很好地协同工作有时会破坏美感。

在重组文本中,您可以使用 .. code:: python 指令。

http://docutils.sourceforge.net/docs/ref/rst/directives.html#code

这允许您创建 python 代码的文字块,没有任何难看的 '\' 字符。

看起来像这样:

.. code:: python

    def ook(*args):
        """Some silly function.

        :param *args: Optional arguments.
        """
        ...

此处是使用您的函数的示例:

http://rst.ninjs.org/?n=c8ad07eaea190745755a6d80d37786e6&theme=basic