Sphinx:自动标记标题?

发布于 2024-11-05 01:18:24 字数 235 浏览 6 评论 0原文

在Sphinx中,是否可以自动定义标题标签?我发现我的文档最终看起来很像这样:

.._doing stuff:

Doing Stuff
-----------

You might also want :ref:`other stuff`.

.._other stuff:

Other Stuff
-----------

No, you want :ref:`doing stuff`.

删除重复项会很好。

In Sphinx, is it possible to automatically define labels for headings? I've found that my documents end up looking a lot like this:

.._doing stuff:

Doing Stuff
-----------

You might also want :ref:`other stuff`.

.._other stuff:

Other Stuff
-----------

No, you want :ref:`doing stuff`.

And it would be nice to remove that duplication.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

多情癖 2024-11-12 01:18:24

在同一文档中,您始终可以使用传统参考:

Doing Stuff
-----------
You may want to try `Doing Stuff`_ -section again.

但如上所述,此方法不适用于跨文档文件。

Within same document, you can always use the traditional reference:

Doing Stuff
-----------
You may want to try `Doing Stuff`_ -section again.

But as mentioned, this method does not work across the document files.

空城旧梦 2024-11-12 01:18:24

Sphinx 1.4 added sphinx.ext.autosectionlabel which supports this. It includes an option that will prefix the document name to the label to avoid cross-document clashes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文