我有以下课程:
class A:
def x():
""" Do the thing. """
class B(A):
def x():
"""
Do the thing, but better than the :py:meth:`parent <A.x>`
"""
整个模块是autodoc
编辑。我想要一个指向父实现的链接x
呈现为“父级”,而不是“parent
"。如何从自定义方法引用中删除代码格式?
根据第一条规则,链接本身被正确解释交叉引用格式 http://www.sphinx-doc.org/en/stable/markup/inline.html#cross-referencing-syntax.
以下是为链接生成的 HTML:
<a class="reference internal" href="#my_module.A.x" title="my_module.A.x">
<code class="xref py py-meth docutils literal">
<span class="pre">parent</span>
</code>
</a>
[为了便于阅读,我插入了换行符。原始 HTML 标签之间没有中断或空格。]
我在 Anaconda 环境中使用 Sphinx 1.6.3 和 Python 3.6.2。
反题在这里:Sphinx 将代码格式添加到 :ref: https://stackoverflow.com/q/45741961/2988730
我面临着同样的问题。我找到的唯一解决方案是写:
"""
Do the thing, but better than the `parent <#my_module.A.x>`_
"""
这会创建一个常规的超链接A.x
生成的 HTML 页面上的条目。然而,这仅适用于 HTML 输出;其他格式(例如 LaTeX)的链接会损坏。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)