Sphinx 可以设置为根据标题编号(不是文本)自动创建书签吗? [英] Can Sphinx be set up to automatically create bookmarks based on the heading number (not text)?

查看:40
本文介绍了Sphinx 可以设置为根据标题编号(不是文本)自动创建书签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的错误参考手册,正在转换它以便使用 Sphinx 托管在 readthedocs 上.我希望能够使用基于节号(不是标题文本)的永久书签来推荐用户,因为这是软件错误代码中返回的内容.我有类似的东西:

I have a large error reference manual which is being converted so as to host on readthedocs using Sphinx. I'd like to be able to refer users using a permanent bookmark based on a section number (not heading text), as this is what is returned in the error code from the software. I have something like:

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.

我希望能够自动生成基于部分的编号,而不是其标题文本:

I'd like to be able to automagically produce bookmarks which are based on the section's number, not its heading text:

You got error code 1.1.1 so you need to go to:
www.mysite.readthedocs.io/blah/blah.html#bookmark1.1

有谁知道是否/如何在不为每个部分手动创建自定义书签的情况下完成此操作?提前致谢:)

Does anyone know if/how this can be accomplished without manually creating custom bookmarks for every section? Thanks in advance :)

PS - 意味着我需要知道自动编号的部分编号将不起作用的建议(例如:锚替换为 '#id1' , '#id2' , '#id3' ... Sphinx )

PS - suggestions that mean that I need to know what the automatically numbered section number will be aren't going to work (eg: Anchor replace with '#id1' , '#id2' , '#id3' ... Sphinx )

推荐答案

不确定我是否完全理解要求,但对我来说这听起来像 :numref: role 在这种情况下可能会有所帮助.

Not sure I fully understood the requirements, but to me it sounds like the :numref: role might be helpful in this case.

.. toctree::
    :numbered:

.. _ping:

Ping
====

See :numref:`section "{name}" ({number}) <ping>`.


.. _pong:

Pong
====

See :numref:`section "{name}" ({number}) <pong>`.

这篇关于Sphinx 可以设置为根据标题编号(不是文本)自动创建书签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆