我想补充的代码格式像这样的引用:狮身人面像添加代码格式化到:REF:
:ref:`__slots__ <python:slots>`
我intersphinx_mapping
定义python
这样的:
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}
这样的链接是https://docs.python.org/3/reference/datamodel.html#slots(slots
定义在https://docs.python.org/3/objects.inv
的std:label
部分)
我的目标是格式化re以:py:attr:
或类似的样式而不是由:ref:
呈现的默认文本样式来确定链接。
无下列选项工作:
... ``:ref:`__slots__ <python:slots>``` ...
yeilds像...
:ref:`__slots__ <python:slots>`
输出...... ``:ref:`__slots__ <python:slots>` `` ...
yeilds输出像... __slots__ ...
... :ref:```__slots__`` <python:slots>` ...
yeilds像输出...:REF:```__slots__`` <蟒:槽>`...
在这种情况下,有两个单独的内部链接到
#id1
。... :ref:` ``__slots__`` <python:slots>` ...
yeilds像输出...:REF:``` __slots__`` <蟒:槽>`...
Relpacing ``...``
与:code:`...`
或:literal:`...`
:ref:
的内部或外部也没有任何帮助。事实上,似乎嵌套角色根本不被允许。
我想有导致一些与代码风格和链接使得内嵌的角色,像
...
__slots__
...
如何获得基本:ref:
(或等效)与:py:attr:
使用的代码样式格式一起出现?
我在Anaconda环境中使用Sphinx 1.6.3和Python 3.6.2。
逆问题就在这里:Sphinx remove code formatting from custom code reference
切向相关的问题:Nested/Compounded roles: apply multiple roles to overlapping text
我对你想要的有点困惑。首先,你想要这个内联而不是'代码块?其次,您是否希望将渲染输出链接到插槽的Python文档?最后,你是否想将样式应用于渲染输出? –
@StevePiercy。抱歉的混淆。 1)我希望':ref:'(或相当的)像现在一样内联。 2)我希望将输出链接到标签为'slots'的python文档。 3)我希望输出以代码字体呈现,即使':ref:'不是。在这种情况下,最好使用':py:attr:'的样式。如果这意味着应用一种风格,我会很乐意这样做。 –
我已将上面的信息更新到问题中。 –