当前位置: 首页 > 文档资料 > Sphinx 中文文档 >

段落级标记

优质
小牛编辑
127浏览
2023-12-01

这些指令(标识符)创建简短的段落,可用于内部信息的单位以及普通的文本:

.. note:: toctree 指令(标识符)是描述在 TOC树 ,它生成子文件的内容表。对于本地内容表,可以用标准的reST contents directive

词汇表

.. glossary:: 特别标记是用于显示

Special markup is available for displaying the productions of a formal grammar. The markup is simple and does not attempt to model all aspects of BNF (or anyderived forms), but provides enough to allow context-free grammars to be displayed in a way that causes uses of a symbol to be rendered as hyperlinks to the definition of the symbol. There is this directive:

.. productionlist:: [name]

This directive is used to enclose a group of productions. Each production is given on a single line and consists of a name, separated by a colon from the following definition. If the definition spans multiple lines, each continuation line must begin with a colon placed at the same column as in the first line.

The argument to productionlist serves to distinguish different sets of production lists that belong to different grammars.

Blank lines are not allowed within productionlist directive arguments.

The definition can contain token names which are marked as interpreted text (e.g. sum ::= `integer` "+" `integer`) – this generates cross-references to the productions of these tokens. Outside of the production list, you can reference to token productions using token.

Note that no further reST parsing is done in the production, so that you don’t have to escape * or | characters.

下面是一个来自Python参考手册的例子:

.. productionlist::
   try_stmt: try1_stmt | try2_stmt
   try1_stmt: "try" ":" `suite`
            : ("except" [`expression` ["," `target`]] ":" `suite`)+
            : ["else" ":" `suite`]
            : ["finally" ":" `suite`]
   try2_stmt: "try" ":" `suite`
            : "finally" ":" `suite`