我有一个类方法,其参数以下划线from_
结尾,并且我正在使用autoclass
为该类生成文档。我希望参数from_
在Sphinx文档中显示为普通文本,但目前它显示为超链接。
以下是带有docstring的类方法的简化版本:
class Twilio:
def get_messages(to=None, from_=None):
"""
Get messages.
`Args:`
to: str
Receiver.
from_: str
Sender.
`Returns:`
Messages: dict
"""
return fetch_messages(to=to, from_=from_)
我正在为这个类生成文档,使用:
.. autoclass :: Twilio
:inherited-members:
这个问题可以在这个页面最底部的get_messages
函数中看到,你可以看到它被格式化为超链接。
使用反斜杠转义下划线。
from_: str
Sender.
参考:https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#escaping-机构