Search code examples
pythonpython-sphinxrestructuredtext

A literal "*" in RestructuredText


I am looking at this snippet of code:

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

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

And as soon as I run Sphinx, I get the oh-so helpful error:

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

So, I tried param ``*``args, param :literal:'*' args and still get the warning.

How do I have a literal '*' in restructuredText?


Solution

  • You could use the (somewhat ugly) backslash quotation: \*

    EDIT: As an (somewhat ugly) addendum, if you are concerned about pylint warning about the backslash, you could add a r to the string literal: r""" ... docstring ... """. This was descibed in this pylint issue.

    Having different text processing systems play nicely together destroys sometimes the aesthetics.