Sphinx添加的Doctree节点类

用于特定于域的对象描述的节点

顶级节点

这些节点构成了对象描述的最顶层。

class sphinx.addnodes.desc(rawsource='', *children, **attributes)[源代码]

节点,以获取对象签名及其常见描述的列表。

包含一个或多个 desc_signature 节点,然后是单个 desc_content 节点。

此节点始终有两个类:

  • 它所属的域名,例如, pycpp

  • 域中对象类型的名称,例如, function

class sphinx.addnodes.desc_signature(*args: Any, **kwargs: Any)[源代码]

节点用于单个对象签名。

默认情况下,签名为单行签名。集 is_multiline = True 来描述多行签名。在这种情况下,所有子节点必须 desc_signature_line 节点。

此节点始终具有类 sigsig-object ,以及它所属的域。

class sphinx.addnodes.desc_signature_line(rawsource='', text='', *children, **attributes)[源代码]

多行对象签名中行的节点。

它只应用作 desc_signature 使用 is_multiline 设置为 True 。集 add_permalink = True 对于应该获得永久链接的行。

class sphinx.addnodes.desc_content(rawsource='', *children, **attributes)[源代码]

对象描述内容的节点。

中的最后一个子节点。 desc 节点。

class sphinx.addnodes.desc_inline(domain: str, *args: Any, **kwargs: Any)[源代码]

内联文本中签名片段的节点。

例如,它用于如下角色 cpp:expr

此节点始终具有类 sigsig-inline 以及它所属的域的名称。

签名中高层结构的节点

这些节点以非多行形式出现在中 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='', text='', *children, **attributes)[源代码]

返回类型或对象类型名称的节点。

class sphinx.addnodes.desc_returns(rawsource='', text='', *children, **attributes)[源代码]

节点表示“Returns”注释(在Python中为la->)。

class sphinx.addnodes.desc_parameterlist(rawsource='', text='', *children, **attributes)[源代码]

常规参数列表的节点。

默认情况下,参数列表与签名的其余部分一致编写。设置 multi_line_parameter_list = True 描述多行参数列表。在这种情况下,每个参数将被写入其自己的缩进行中。如果出现以下情况,最后一行将添加尾部逗号 multi_line_trailing_comma 是真的

class sphinx.addnodes.desc_parameter(rawsource='', text='', *children, **attributes)[源代码]

节点用于单个参数。

class sphinx.addnodes.desc_optional(rawsource='', text='', *children, **attributes)[源代码]

节点,用于标记参数列表的可选部分。

class sphinx.addnodes.desc_annotation(rawsource='', text='', *children, **attributes)[源代码]

用于签名批注(不是Python3样式批注)的节点。

签名文本元素的节点

这些节点继承 desc_sig_element 并且通常被翻译成 docutils.nodes.inline 通过 SigElementFallbackTransform

扩展可能会创建额外的 desc_sig_* - 像节点,但为了 SigElementFallbackTransform 要将它们自动转换为内联节点,必须将它们添加到 SIG_ELEMENTS 通过类关键字参数 _sig_element=Truedesc_sig_element ,例如:

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 。如果构建器的Translator类不是从SphinxTranslator继承的,则每个节点类都应该由构建器的Translator类处理。

可以通过第三方扩展或子类化来手动扩展此集合 desc_sig_element 并使用CLASS关键字参数 _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.desc_sig_literal_string(rawsource: str = '', text: str = '', *children: Element, **attributes: Any)[源代码]

签名中字符串文字的节点。

class sphinx.addnodes.desc_sig_literal_char(rawsource: str = '', text: str = '', *children: Element, **attributes: Any)[源代码]

签名中字符文字的节点。

新的警告式结构

class sphinx.addnodes.versionmodified(rawsource='', text='', *children, **attributes)[源代码]

版本更改条目的节点。

目前用于“versionadded”、“versionchanged”、“disrecated”和“versionremoved”指令。

class sphinx.addnodes.seealso(rawsource='', *children, **attributes)[源代码]

习俗“另眼相看”告诫。

其他段落级别节点

class sphinx.addnodes.compact_paragraph(rawsource='', text='', *children, **attributes)[源代码]

用于紧凑段落的节点(不会生成<p>节点)。

新的内联节点

class sphinx.addnodes.index(rawsource='', text='', *children, **attributes)[源代码]

索引项的节点。

此节点由 index 指令,并具有一个属性, entries 。它的值是由5元组组成的列表 (entrytype, entryname, target, ignored, key)

entrytype 是“单人”、“配对”、“双人”、“三人”中的一个。

key 是通用索引页面的分类字符(通常是单个字符)。有关详细信息,另请参阅: glossary 和https://github.com/sphinx-doc/sphinx/pull/2320。

class sphinx.addnodes.pending_xref(rawsource='', *children, **attributes)[源代码]

交叉引用的节点,如果没有关于所有文档的完整信息,则无法解析该节点。

在写入输出之前,在BuildEnvironment中解析这些节点。

class sphinx.addnodes.pending_xref_condition(rawsource='', text='', *children, **attributes)[源代码]

节点,表示创建交叉引用的可能方式以及应使用此方式的条件。

此节点仅允许放置在 pending_xref 节点。一个 pending_xref 节点必须包含无 pending_xref_condition 节点,否则它必须仅包含 pending_xref_condition 节点。

交叉引用冲突解决程序将替换 pending_xref 其中包含 pending_xref_condition 节点中的任何一个的内容 pending_xref_condition 节点的内容。它使用 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 AS::

<reference>
    <literal>
        StringIO

否则,如果交叉引用解析失败,它将重写 pending_xref AS::

<reference>
    <literal>
        io.StringIO

这个 pending_xref_condition 节点应具有 condition 属性。域可以将其各自的条件存储到属性中,以便在解析阶段过滤内容。作为保留的条件名称, condition="*" 用于解析失败的回退。此外,作为推荐的条件名称, condition="resolved" 表示Intersphinx模块中的解析成功。

Added in version 4.0.

class sphinx.addnodes.literal_emphasis(rawsource='', text='', *children, **attributes)[源代码]

行为类似的节点 emphasis ,但不会应用更多的文本处理器(例如,用于HTML输出的Smartyants)。

class sphinx.addnodes.download_reference(rawsource='', text='', *children, **attributes)[源代码]

用于下载引用的节点,类似于Pending_xref。

特殊节点

class sphinx.addnodes.only(rawsource='', *children, **attributes)[源代码]

“only”指令的节点(基于标记的条件包含)。

class sphinx.addnodes.highlightlang(rawsource='', *children, **attributes)[源代码]

插入以设置后续代码块的突出显示语言和行号选项。

您应该不需要在扩展中生成下面的节点。

class sphinx.addnodes.glossary(rawsource='', *children, **attributes)[源代码]

节点以插入词汇表。

class sphinx.addnodes.toctree(rawsource='', *children, **attributes)[源代码]

用于插入“TOC树”的节点。

class sphinx.addnodes.start_of_file(rawsource='', *children, **attributes)[源代码]

节点标记新文件的开始,仅在LaTeX生成器中使用。

class sphinx.addnodes.productionlist(rawsource='', *children, **attributes)[源代码]

语法产生式列表的节点。

包含 production 节点。

class sphinx.addnodes.production(rawsource='', text='', *children, **attributes)[源代码]

节点,用于单个语法生成规则。