How can I add a plural-s after a Sphinx :class: directive

爱⌒轻易说出口 提交于 2020-06-23 07:40:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!