问题描述
我的文档在两个不同的页面上有两个重复的键-> private final Object lock = new Object();
。我需要知道如何使用以下语法链接到这两个单独的目标:
.. command:: targetName
目标:
Page-1 Click this -> :command:`targetName` # this will always open the first targetName declared in the doc
解决方法
首先介绍一些术语。您所说的targetName
在reStructuredText中称为title
。尖括号中的内容是target
。参见Cross-referencing syntax。
reStructuredText不支持嵌套的嵌入式标记,其中包括样式超链接。但是,replacement有一种解决方法。
由于reStructuredText不支持嵌套的行内标记,因此创建带有样式文本的引用的唯一方法是使用带有“ replace”指令的替换:
I recommend you try |Python|_. .. |Python| replace:: Python,*the* best language around .. _Python: http://www.python.org/
在您的情况下:
Page-1 Click this -> |myTarget|_
.. |myTarget| replace:: ``targetName``
.. _myTarget: page-1.html#targetName
要进一步自定义外观,请使用自定义样式。有关示例,请参见How do I set up custom styles for reStructuredText,Sphinx,ReadTheDocs,etc.?。