python-sphinx - 可以将 Sphinx 设置为根据标题编号(而非文本)自动创建书签吗?
问题描述
我有一个很大的错误参考手册,它正在被转换以便使用 Sphinx 托管在 readthedocs 上。我希望能够使用基于节号(不是标题文本)的永久书签来推荐用户,因为这是软件错误代码中返回的内容。我有类似的东西:
This has a chapter heading automatically numbered to give 1.
============================================================
This has a section heading automatically numbered to give 1.1
-------------------------------------------------------------
- This has no section heading as it's in a list, but is ideally
where I want to send people using the number 1.1.1. If that's
too tricky, then a link to the number of the section (1.1) is fine.
我希望能够根据部分的number自动生成书签,而不是其标题文本:
You got error code 1.1.1 so you need to go to:
www.mysite.readthedocs.io/blah/blah.html#bookmark1.1
有谁知道是否/如何在不为每个部分手动创建自定义书签的情况下实现这一点?提前致谢 :)
PS - 意味着我需要知道自动编号的部分编号将不起作用的建议(例如:Anchor replace with '#id1' , '#id2' , '#id3' ... Sphinx)
解决方案
不确定我是否完全理解这些要求,但对我来说,这个:numref:
角色在这种情况下可能会有所帮助。
.. toctree::
:numbered:
.. _ping:
Ping
====
See :numref:`section "{name}" ({number}) <ping>`.
.. _pong:
Pong
====
See :numref:`section "{name}" ({number}) <pong>`.
推荐阅读
- python - 实时物体检测
- python - 如何获得 2 个不同列表的余弦相似度?
- javascript - 如何在 React js 的输入框中禁用复制粘贴
- java - 将子类型添加到通用列表
- api - Flutter:快照未显示数据
- c# - 如何使用通过运行空间参数异步构造的 PowerShell 对象创建 C# 方法
- c++ - 当 std::cout 使用箭头指针时得到不想要的输出
- android - kotlin.UninitializedPropertyAccessException:lateinit 属性 adapterPosts 尚未初始化
- c# - 如何使用 ActionFilter 一次在所有控制器上执行
- javascript - 谁能用传播运算符解释这里发生了什么