24

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?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Sardathrion - against SE abuse
  • 17,269
  • 27
  • 101
  • 156

3 Answers3

29

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.

knitti
  • 6,817
  • 31
  • 42
  • 2
    Just wanted to add that this also happens with quotes, as in `""" a "comment """`, and can also be fixed with a backslash, like `""" a \"comment\" """"`. – jxmorris12 Jul 01 '20 at 16:17
1

In restructuredtext you can use the .. code:: python directive.

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

This allows you to create a literal block of python code without any ugly '\' characters.

It looks like this:

.. code:: python

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

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

An example using your function is here:

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

matthewrsj
  • 81
  • 1
  • 8
1
:param `*args`:

In addition to \*, the above works for me :)

Y4nhu1
  • 116
  • 11