问题
I have this problem all the time that I want to write a docstring like this:
def foo(arg):
'''Add ``arg`` to the list of :class:`foo.bar.baz.Argument`s.'''
pass
However, that doesn't work, Sphinx will warn that
py:class reference target not found: foo.bar.baz.Argument`s
so it's treating the s
after the closing backtick as part of the class name. This does not happen with e.g. punctuation marks like the dot .
.
Is there anything to be done about this, except adding a space between the class name and the Plural-s (which looks crazy)?
回答1:
You should be able to use backslash-escaped whitespace.
def foo(arg):
'''Add ``arg`` to the list of :class:`foo.bar.baz.Argument`\ s.'''
pass
来源:https://stackoverflow.com/questions/51891619/how-can-i-add-a-plural-s-after-a-sphinx-class-directive