在 Sphinx 中,我如何创建可链接的“术语”?没有大量开销的部分?
我想创建一个“术语”部分,其中包含我正在使用的术语的定义,这样每次我使用此术语部分中的术语时,都会创建一个指向该定义的链接。
目前,我能想到的最好的办法是:
.. |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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没什么不同,但您可以使用:
..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]