在 Sphinx 中,我如何创建可链接的“术语”?没有大量开销的部分?

发布于 2024-09-24 19:50:13 字数 353 浏览 1 评论 0原文

我想创建一个“术语”部分,其中包含我正在使用的术语的定义,这样每次我使用此术语部分中的术语时,都会创建一个指向该定义的链接。

目前,我能想到的最好的办法是:

.. |flavor| replace:: `:ref:flavor`

.. _flavor:

flavor
------
blah blah blah

然后,在其他文本中我必须做:

''' This is a usage of the word |flavor|.'''

我发现上面的语法非常麻烦。我知道我可以使用另一层脚本或 m4 来自动生成此语法,但我希望有更好的方法..

I want to create a "terminology" section with definitions for terms that I'm using such that every time I use the terms in this terminology section, a link is created that points to the definition.

Currently, the best I can think up is:

.. |flavor| replace:: `:ref:flavor`

.. _flavor:

flavor
------
blah blah blah

Then later, in the other text I have to do:

''' This is a usage of the word |flavor|.'''

I find the above syntax to be very cumbersome. I know I could use yet another layer of scripting or m4 to auto-generate this syntax, but I'm hoping there's a better way..

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

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

发布评论

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

评论(1

枯叶蝶 2024-10-01 19:50:13

没什么不同,但您可以使用:

..lossary::

该指令必须包含包含术语和定义的 reST 定义列表。然后可以使用“术语”角色引用这些定义。

:term:

引用术语表中的术语。术语表是使用包含术语和定义的定义列表的术语表指令创建的。它不必与术语标记位于同一文件中,例如,Python 文档在lossary.rst 文件中有一个全局术语表。

如果您使用术语表中未解释的术语,您将在构建过程中收到警告。

[粘贴自sphinx官方文档]

Not so different, but you can use:

.. glossary::

This directive must contain a reST definition list with terms and definitions. The definitions will then be referencable with the 'term' role.

:term:

Reference to a term in the glossary. The glossary is created using the glossary directive containing a definition list with terms and definitions. It does not have to be in the same file as the term markup, for example the Python docs have one global glossary in the glossary.rst file.

If you use a term that’s not explained in a glossary, you’ll get a warning during build.

[pasted from official sphinx documentation]

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