Sphinx添加的Doctree节点类¶
域特定对象描述的节点¶
顶级节点¶
这些节点构成了对象描述的最顶层
- class sphinx.addnodes.desc(rawsource: str = '', *children, **attributes: Any)[源代码]¶
对象签名列表及其通用描述的节点。
包含一项或多项
desc_signature节点,然后是一个单个desc_content节点。这个节点总是有两个类:
它所属域的名称,例如
py或cpp。域中对象类型的名称,例如
function。
- class sphinx.addnodes.desc_signature(*args: Any, **kwargs: Any)[源代码]¶
单个对象签名的节点。
默认情况下,签名是单行签名。将
is_multiline = True设置为描述多行签名。 在这种情况下,所有子节点必须是desc_signature_line节点。此节点始终具有类
sig、sig-object和它所属的域。
- class sphinx.addnodes.desc_signature_line(rawsource: str = '', text: str = '', *children, **attributes: Any)[源代码]¶
多行对象签名中的一行的节点。
它只能用作
is_multiline设置为True的desc_signature的子节点。 将add_permalink = True设置为应该获得永久链接的行。
签名中高级结构的节点¶
这些节点出现在非多行 desc_signature 节点和 desc_signature_line 节点中。
- class sphinx.addnodes.desc_name(*args: Any, **kwargs: Any)[源代码]¶
主对象名称的节点。
例如,在Python类
MyModule.MyClass的声明中,主名称是MyClass。此节点始终具有
sig-name类。
- class sphinx.addnodes.desc_addname(*args: Any, **kwargs: Any)[源代码]¶
对象的其他名称部分的节点。
例如,在Python类
MyModule.MyClass的声明中,附加名称部分是MyModule.。此节点始终具有
sig-prename类。
- class sphinx.addnodes.desc_type(rawsource: str = '', text: str = '', *children, **attributes: Any)[源代码]¶
返回类型或对象类型名称的节点。
- class sphinx.addnodes.desc_returns(rawsource: str = '', text: str = '', *children, **attributes: Any)[源代码]¶
“returns”注释的节点(Python中的la->)。
- class sphinx.addnodes.desc_parameterlist(rawsource: str = '', text: str = '', *children, **attributes: Any)[源代码]¶
常规参数列表的节点。
默认情况下,参数列表与签名的其余部分在同一行中编写。将
multi_line_parameter_list = True设置为描述多行参数列表。 在这种情况下,每个参数将单独写在自己的缩进行上。 如果multi_line_trailing_comma为 True,则将在最后一行添加一个尾随逗号。
- class sphinx.addnodes.desc_parameter(rawsource: str = '', text: str = '', *children, **attributes: Any)[源代码]¶
单个参数的节点。
签名文本元素的节点¶
这些节点继承 desc_sig_element,通常由 SigElementFallbackTransform 翻译为 docutils.nodes.inline。
扩展可以创建其他类似 desc_sig_* 的节点,但为了让 SigElementFallbackTransform 自动将它们转换为内联节点,它们必须通过 desc_sig_element 的类关键字参数 _sig_element=True 添加到 SIG_ELEMENTS,例如:
class desc_custom_sig_node(desc_sig_element, _sig_element=True): ...
为了向后兼容,仍然可以使用 SIG_ELEMENTS.add(desc_custom_sig_node) 直接添加节点。
- sphinx.addnodes.SIG_ELEMENTS: set[type[desc_sig_element]]¶
继承
desc_sig_element的类集。 如果后者不继承自 SphinxTranslator,则期望构建器的翻译器类处理每个节点类。第三方扩展或通过子类化
desc_sig_element并使用类关键字参数 _sig_element=True 可以手动扩展此集。
- class sphinx.addnodes.desc_sig_element(rawsource: str = '', text: str = '', *children: Element, **attributes: Any)[源代码]¶
签名内联文本节点的通用父类。
- class sphinx.addnodes.desc_sig_space(rawsource: str = '', text: str = ' ', *children: Element, **attributes: Any)[源代码]¶
签名中的空格节点。
- class sphinx.addnodes.desc_sig_name(rawsource: str = '', text: str = '', *children: Element, **attributes: Any)[源代码]¶
签名中的标识符节点。
- class sphinx.addnodes.desc_sig_operator(rawsource: str = '', text: str = '', *children: Element, **attributes: Any)[源代码]¶
签名中运算符的节点。
- class sphinx.addnodes.desc_sig_punctuation(rawsource: str = '', text: str = '', *children: Element, **attributes: Any)[源代码]¶
签名中标点符号的节点。
- class sphinx.addnodes.desc_sig_keyword(rawsource: str = '', text: str = '', *children: Element, **attributes: Any)[源代码]¶
签名中一般关键字的节点。
- class sphinx.addnodes.desc_sig_keyword_type(rawsource: str = '', text: str = '', *children: Element, **attributes: Any)[源代码]¶
签名中作为内置类型的关键字节点。
- class sphinx.addnodes.desc_sig_literal_number(rawsource: str = '', text: str = '', *children: Element, **attributes: Any)[源代码]¶
签名中数字字面量的节点。
新的指令¶
其他段落级节点¶
新建内联节点¶
- class sphinx.addnodes.index(rawsource: str = '', text: str = '', *children, **attributes: Any)[源代码]¶
索引项的节点。
此节点由
index指令创建,有一个属性entries。它的值是5个元组的列表(entrytype, entryname, target, ignored, key)。entrytype 是 "single", "pair", "double", "triple"之一。
key 是通用索引页的分类字符(通常是单个字符)。有关这方面的详细信息,请参阅:
glossary和 https://github.com/sphinx-doc/sphinx/pull/2320。
- class sphinx.addnodes.pending_xref(rawsource: str = '', *children, **attributes: Any)[源代码]¶
节点,用于在没有有关所有文档的完整信息的情况下无法解析的交叉引用。
在中写入输出之前,将解析这些节点BuildEnvironment.resolve_references.
- class sphinx.addnodes.pending_xref_condition(rawsource: str = '', text: str = '', *children, **attributes: Any)[源代码]¶
节点,表示创建交叉引用的潜在方法以及应使用此方法的条件。
此节点仅允许放置在
pending_xref节点下。 pending_xref 节点必须包含零个 pending_xref_condition 节点,或者它只能包含 pending_xref_condition 节点。交叉引用解析器将用其中一个 pending_xref_condition 节点内容的内容替换包含 pending_xref_condition 节点的
pending_xref。 它使用 condition 属性来决定使用哪个 pending_xref_condition 节点的内容。 例如,让我们考虑交叉引用解析器如何作用于:<pending_xref refdomain="py" reftarget="io.StringIO ...> <pending_xref_condition condition="resolved"> <literal> StringIO <pending_xref_condition condition="*"> <literal> io.StringIO
如果交叉引用解析器成功解析了交叉引用,则它将 pending_xref 重写为:
<reference> <literal> StringIO
否则,如果交叉引用解析失败,它将 pending_xref 重写为:
<reference> <literal> io.StringIO
pending_xref_condition 节点应具有 condition 属性。 域可以将其各自的条件存储到该属性中,以在解析阶段过滤内容。 作为保留的条件名称,
condition="*"用于解析失败的回退。 此外,作为推荐的条件名称,condition="resolved"代表 intersphinx 模块中的解析成功。在 4.0 版本加入.
特殊节点¶
- class sphinx.addnodes.only(rawsource: str = '', *children, **attributes: Any)[源代码]¶
“only”指令的节点(基于标记的条件包含)。
- class sphinx.addnodes.highlightlang(rawsource: str = '', *children, **attributes: Any)[源代码]¶
插入以设置后续代码块的突出显示语言和行号选项。
您不需要在扩展中生成以下节点。
- class sphinx.addnodes.toctree(rawsource: str = '', *children, **attributes: Any)[源代码]¶
用于插入“目录树”的节点。
- class sphinx.addnodes.start_of_file(rawsource: str = '', *children, **attributes: Any)[源代码]¶
标记新文件开始的节点,仅在LaTeX builder中使用。