如何在rST的Note块中跨文件引用子标题?
在RST文件中跨文件引用子标题的实现方法
要实现跨RST文件引用子标题,按以下两步操作即可:
1. 给被引用的子标题添加自定义标签
编辑 /pages/architecture-deployment-guide.rst,在每个子标题上方添加唯一的引用标签(标签名建议见名知意,确保全局唯一):
.. _view-container-mac-addresses: View MAC Addresses of Each Container Interface ============================================== .. _view-bridge-mac-addresses: View MAC Addresses of Each Bridge Interface ===========================================
2. 在目标文件的Note块中使用引用指令
编辑 /pages/view-packet-captures.rst 的Note块,用RST的:ref:指令替换原有的标题文本,实现跨文件跳转引用:
.. Note:: Go to :ref:`View MAC Addresses of Each Container Interface <view-container-mac-addresses>` and :ref:`View MAC Addresses of Each Bridge Interface <view-bridge-mac-addresses>` to confirm the MAC addresses of each device when analyzing the packet capture.
补充说明
- 标签名必须全局唯一,不能和项目内其他RST文件的标签重复
- 若用Sphinx构建文档,需确保
conf.py中包含/pages目录,保证构建系统能识别跨文件引用 - 也可简化引用写法:直接使用
:ref:view-container-mac-addresses``,渲染时会自动替换为对应的标题文本
内容的提问来源于stack exchange,提问作者charles uneze
相关产品推荐
相关产品推荐

