module documentation

Docutils node-related utility functions for Sphinx.

Unknown Field: copyright
Copyright 2007-2022 by the Sphinx team, see AUTHORS.
Unknown Field: license
BSD, see LICENSE for details.
Constant IGNORED​_NODES Undocumented
Constant IMAGE​_TYPE​_NODES Undocumented
Constant LITERAL​_TYPE​_NODES Undocumented
Constant META​_TYPE​_NODES Undocumented
Constant NON​_SMARTQUOTABLE​_PARENT​_NODES Undocumented
Variable explicit​_title​_re Undocumented
Variable indextypes Undocumented
Variable logger Undocumented
Class ​Node​Matcher A helper class for Node.findall().
Function ​_make​_id Convert string into an identifier and return it.
Function ​_new​_copy monkey-patch Element.copy to copy the rawsource and line for docutils-0.16 or older versions.
Function apply​_source​_workaround Undocumented
Function clean​_astext Like node.astext(), but ignore images.
Function copy​_source​_info Undocumented
Function extract​_messages Extract translatable messages from a document tree.
Function find​_pending​_xref​_condition Pick matched pending_xref_condition node up from the pending_xref.
Function get​_full​_module​_name Return full module dotted path like: 'docutils.nodes.paragraph'
Function get​_node​_line Undocumented
Function get​_node​_source Undocumented
Function get​_prev​_node Undocumented
Function inline​_all​_toctrees Inline all toctrees in the tree.
Function is​_pending​_meta Undocumented
Function is​_smartquotable Check whether the node is smart-quotable or not.
Function is​_translatable Undocumented
Function make​_id Generate an appropriate node_id for given prefix and term.
Function make​_refnode Shortcut to create a reference node.
Function nested​_parse​_with​_titles Version of state.nested_parse() that allows titles and does not require titles to have the same decoration as the calling document.
Function process​_index​_entry Undocumented
Function process​_only​_nodes Filter only nodes which do not match tags.
Function repr​_domxml return DOM XML representation of the specified node like: '<paragraph translatable="False"><inline classes="versionmodified">New in version...'
Function set​_role​_source​_info Undocumented
Function set​_source​_info Undocumented
Function split​_explicit​_title Split role content into title and target, if given.
Function traverse​_parent Undocumented
Function traverse​_translatable​_index Traverse translatable index node from a document tree.
Variable ​_non​_id​_at​_ends Undocumented
Variable ​_non​_id​_chars Undocumented
Variable ​_non​_id​_translate Undocumented
Variable ​_non​_id​_translate​_digraphs Undocumented
IGNORED_NODES =

Undocumented

Value
(nodes.Invisible,
 nodes.literal_block,
 nodes.doctest_block,
 addnodes.versionmodified)
IMAGE_TYPE_NODES =

Undocumented

Value
(nodes.image)
LITERAL_TYPE_NODES =

Undocumented

Value
(nodes.literal_block, nodes.doctest_block, nodes.math_block, nodes.raw)
META_TYPE_NODES =

Undocumented

Value
(addnodes.meta)
NON_SMARTQUOTABLE_PARENT_NODES =

Undocumented

Value
(nodes.FixedTextElement,
 nodes.literal,
 nodes.math,
 nodes.image,
 nodes.raw,
 nodes.problematic,
 addnodes.not_smartquotable)
explicit_title_re =

Undocumented

indextypes: list[str] =

Undocumented

logger =

Undocumented

def _make_id(string):

Convert string into an identifier and return it.

This function is a modified version of docutils.nodes.make_id() of docutils-0.16.

Changes:

  • Allow to use capital alphabet characters
  • Allow to use dots (".") and underscores ("_") for an identifier without a leading character.

# Author: David Goodger <goodger@python.org> # Maintainer: docutils-develop@lists.sourceforge.net # Copyright: This module has been placed in the public domain.

Parameters
string:strUndocumented
Returns
strUndocumented
def _new_copy(self):

monkey-patch Element.copy to copy the rawsource and line for docutils-0.16 or older versions.

refs: https://sourceforge.net/p/docutils/patches/165/

Returns
ElementUndocumented
def apply_source_workaround(node):

Undocumented

Parameters
node:ElementUndocumented
def clean_astext(node):
Like node.astext(), but ignore images.
Parameters
node:ElementUndocumented
Returns
strUndocumented
def copy_source_info(src, dst):

Undocumented

Parameters
src:ElementUndocumented
dst:ElementUndocumented
def extract_messages(doctree):
Extract translatable messages from a document tree.
Parameters
doctree:ElementUndocumented
Returns
Iterable[Tuple[Element, str]]Undocumented
def find_pending_xref_condition(node, condition):
Pick matched pending_xref_condition node up from the pending_xref.
Parameters
node:addnodes.pending_xrefUndocumented
condition:strUndocumented
Returns
Optional[Element]Undocumented
def get_full_module_name(node):
Return full module dotted path like: 'docutils.nodes.paragraph'
Parameters
node:NodeUndocumented
nodes.​Node nodetarget node
Returns
strfull module dotted path
def get_node_line(node):

Undocumented

Parameters
node:ElementUndocumented
Returns
Optional[int]Undocumented
def get_node_source(node):

Undocumented

Parameters
node:ElementUndocumented
Returns
Optional[str]Undocumented
def get_prev_node(node):

Undocumented

Parameters
node:NodeUndocumented
Returns
Optional[Node]Undocumented
def inline_all_toctrees(builder, docnameset, docname, tree, colorfunc, traversed):

Inline all toctrees in the tree.

Record all docnames in docnameset, and output docnames with colorfunc.

Parameters
builder:BuilderUndocumented
docnameset:Set[str]Undocumented
docname:strUndocumented
tree:nodes.documentUndocumented
colorfunc:CallableUndocumented
traversed:List[str]Undocumented
Returns
nodes.documentUndocumented
def is_pending_meta(node):

Undocumented

Parameters
node:NodeUndocumented
Returns
boolUndocumented
def is_smartquotable(node):
Check whether the node is smart-quotable or not.
Parameters
node:NodeUndocumented
Returns
boolUndocumented
def is_translatable(node):

Undocumented

Parameters
node:NodeUndocumented
Returns
boolUndocumented
def make_id(env, document, prefix='', term=None):
Generate an appropriate node_id for given prefix and term.
Parameters
env:BuildEnvironmentUndocumented
document:nodes.documentUndocumented
prefix:strUndocumented
term:strUndocumented
Returns
strUndocumented
def make_refnode(builder, fromdocname, todocname, targetid, child, title=None):
Shortcut to create a reference node.
Parameters
builder:BuilderUndocumented
fromdocname:strUndocumented
todocname:strUndocumented
targetid:strUndocumented
child:Union[Node, List[Node]]Undocumented
title:strUndocumented
Returns
nodes.referenceUndocumented
def nested_parse_with_titles(state, content, node):

Version of state.nested_parse() that allows titles and does not require titles to have the same decoration as the calling document.

This is useful when the parsed content comes from a completely different context, such as docstrings.

Parameters
state:AnyUndocumented
content:StringListUndocumented
node:NodeUndocumented
Returns
strUndocumented
def process_index_entry(entry, targetid):

Undocumented

Parameters
entry:strUndocumented
targetid:strUndocumented
Returns
List[Tuple[str, str, str, str, Optional[str]]]Undocumented
def process_only_nodes(document, tags):
Filter only nodes which do not match tags.
Parameters
document:NodeUndocumented
tags:TagsUndocumented
def repr_domxml(node, length=80):
return DOM XML representation of the specified node like: '<paragraph translatable="False"><inline classes="versionmodified">New in version...'
Parameters
node:NodeUndocumented
length:intUndocumented
nodes.​Node nodetarget node
int lengthlength of return value to be striped. if false-value is specified, repr_domxml returns full of DOM XML representation.
Returns
strDOM XML representation
def set_role_source_info(inliner, lineno, node):

Undocumented

Parameters
inliner:InlinerUndocumented
lineno:intUndocumented
node:NodeUndocumented
def set_source_info(directive, node):

Undocumented

Parameters
directive:DirectiveUndocumented
node:NodeUndocumented
def split_explicit_title(text):
Split role content into title and target, if given.
Parameters
text:strUndocumented
Returns
Tuple[bool, str, str]Undocumented
def traverse_parent(node, cls=None):

Undocumented

Parameters
node:ElementUndocumented
cls:AnyUndocumented
Returns
Iterable[Element]Undocumented
def traverse_translatable_index(doctree):
Traverse translatable index node from a document tree.
Parameters
doctree:ElementUndocumented
Returns
Iterable[Tuple[Element, List[IndexEntry]]]Undocumented
_non_id_at_ends =

Undocumented

_non_id_chars =

Undocumented

_non_id_translate: dict[int, str] =

Undocumented

_non_id_translate_digraphs: dict[int, str] =

Undocumented