参考¶
交叉引用¶
要交叉引用到单个文档内的任意位置,请使用 ref 角色。引用目标名称需要以一个下划线开头。例如,.. _example:。但是,引用本身不应在引用名前面带有下划线。例如,example。有关引用的更多信息,请参阅 内部超链接目标。
输入
.. _cg_titles:
Titles
~~~~~~
This is the section we want to reference to.
...
The following - :ref:`cg_titles` - generates a link to the section with
the defined label using this section heading as a link title.
A link label and a reference can be defined in separate source files,
but within one directory. Otherwise, use the external linking.
输出
…
以下 - 标题 - 会生成一个链接到具有定义标签的部分,使用此部分标题作为链接标题。
链接标签和引用可以在单独的源文件中定义,但必须位于同一个目录中。否则,请使用外部链接。
外部引用¶
要链接到一些外部位置,请按以下格式设置 RST 源代码
不要应用任何标记来指定网络链接。
如果您需要在输出中显示特定的链接标题,请将网络链接格式化为
链接 文本 <http://web-link.com>,并用反引号将其括起来。不要通过在文档的其他位置定义链接来将链接名称与链接本身分隔开。这可以防止翻译后的文档使用不同的链接,例如,对应于翻译版本的链接。
输入
Here is a link to the Image guide: https://docs.openstack.org/image-guide/.
Here is an external web link with a link title:
`Image guide <https://docs.openstack.org/image-guide/>`_.
输出
这里是 Image 指南的链接:https://docs.openstack.org/image-guide/。
这里是一个带有链接标题的外部网络链接:Image 指南。