我有两个第一个文件,例如:
doc1.rst
doc2.rst
doc1.rst
Doc 1 content
*************
Foo bar
=======
baz !
doc2.rst
Doc 2 content
*************
You can see "foo bar" `here <doc1.html#foo-bar>`.
要在doc2中链接到doc1#foo-bar,我可以对其进行硬编码。但是如何不进行硬编码呢?我可以用狮身人面像代码做到这一点吗?
为doc1.rst中要链接的部分定义标签。然后使用该:ref:
角色创建对该部分的交叉引用。
doc1.rst:
Doc 1 content
*************
.. _foobar:
Foo bar
=======
baz !
doc2.rst:
Doc 2 content
*************
You can see "foo bar" :ref:`here <foobar>`.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句