The document root element.
Do not instantiate this class directly; use docutils.utils.new_document() instead.
There are no implemented interfaces.
child_text_separator
(type:
str
)
'\n\n'
document
(type: NoneType
)
None
line
(type: NoneType
)
None
list_attributes
(type:
tuple
)
('ids', 'classes', 'names', 'dupnames', 'backrefs')
parent
(type: NoneType
)
None
source
(type: NoneType
)
None
tagname
(type: NoneType
)
None
append(item)
asdom(dom=None)
Return a DOM representation of this document.
astext()
attlist()
clear()
copy()
deepcopy()
delattr(attr)
emptytag()
endtag()
extend(item)
first_child_matching_class(childclass, start=0, end=2147483647)
Return the index of the first child whose class exactly matches.
Parameters:
first_child_not_matching_class(childclass, start=0, end=2147483647)
Return the index of the first child whose class does not match.
Parameters:
get(key, failobj=None)
get_decoration()
has_key(attr)
has_name(name)
hasattr(attr)
index(item)
insert(index, item)
is_not_default(key)
next_node(condition=None, include_self=0, descend=1, siblings=0, ascend=0)
Return the first node in the iterable returned by traverse(), or None if the iterable is empty.
Parameter list is the same as of traverse. Note that include_self defaults to 0, though.
non_default_attributes()
note_anonymous_target(target)
note_autofootnote(footnote)
note_autofootnote_ref(ref)
note_citation(citation)
note_citation_ref(ref)
note_explicit_target(target, msgnode=None)
note_footnote(footnote)
note_footnote_ref(ref)
note_implicit_target(target, msgnode=None)
note_indirect_target(target)
note_parse_message(message)
note_pending(pending, priority=None)
note_referenced_by(name=None, id=None)
Note that this Element has been referenced by its name name or id id.
note_refid(node)
note_refname(node)
note_source(source, offset)
note_substitution_def(subdef, def_name, msgnode=None)
note_substitution_ref(subref, refname)
note_symbol_footnote(footnote)
note_symbol_footnote_ref(ref)
note_transform_message(message)
pformat(indent=' ', level=0)
pop(i=-1)
remove(item)
replace(old, new)
Replace one child Node with another child or children.
replace_self(new)
Replace self node with new, where new is a node or a list of nodes.
set_class(name)
Add a new class to the "classes" attribute.
set_duplicate_name_id(node, id, name, msgnode, explicit)
set_id(node, msgnode=None)
set_name_id_map(node, id, msgnode=None, explicit=None)
self.nameids maps names to IDs, while self.nametypes maps names to booleans representing hyperlink type (True==explicit, False==implicit). This method updates the mappings.
The following state transition table shows how self.nameids ("ids") and self.nametypes ("types") change with new input (a call to this method), and what actions are performed ("implicit"-type system messages are INFO/1, and "explicit"-type system messages are ERROR/3):
Old State | Input | Action | New State | Notes | |||
---|---|---|---|---|---|---|---|
ids | types | new type | sys.msg. | dupname | ids | types | |
explicit | new | True | |||||
implicit | new | False | |||||
None | False | explicit | new | True | |||
old | False | explicit | implicit | old | new | True | |
None | True | explicit | explicit | new | None | True | |
old | True | explicit | explicit | new,old | None | True | [1] |
None | False | implicit | implicit | new | None | False | |
old | False | implicit | implicit | new,old | None | False | |
None | True | implicit | implicit | new | None | True | |
old | True | implicit | implicit | new | old | True |
[1] | Do not clear the name-to-id map or invalidate the old target if both old and new targets are external and refer to identical URIs. The new target is invalidated regardless. |
setdefault(key, failobj=None)
setup_child(child)
shortrepr()
starttag()
traverse(condition=None, include_self=1, descend=1, siblings=0, ascend=0)
Return an iterable containing
If condition is not None, the iterable contains only nodes for which condition(node) is true. If condition is a node class cls, it is equivalent to a function consisting of return isinstance(node, cls).
If ascend is true, assume siblings to be true as well.
For example, given the following tree:
<paragraph> <emphasis> <--- emphasis.traverse() and <strong> <--- strong.traverse() are called. Foo Bar <reference name="Baz" refid="baz"> Baz
Then list(emphasis.traverse()) equals
[<emphasis>, <strong>, <#text: Foo>, <#text: Bar>]
and list(strong.traverse(ascend=1)) equals
[<strong>, <#text: Foo>, <#text: Bar>, <reference>, <#text: Baz>]
update_basic_atts(dict)
Update basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') from node or dictionary dict.
walk(visitor)
Traverse a tree of Node objects, calling the dispatch_visit() method of visitor when entering each node. (The walkabout() method is similar, except it also calls the dispatch_departure() method before exiting each node.)
This tree traversal supports limited in-place tree modifications. Replacing one node with one or more nodes is OK, as is removing an element. However, if the node removed or replaced occurs after the current node, the old node will still be traversed, and any new nodes will not.
Within visit methods (and depart methods for walkabout()), TreePruningException subclasses may be raised (SkipChildren, SkipSiblings, SkipNode, SkipDeparture).
Parameter visitor: A NodeVisitor object, containing a visit implementation for each Node subclass encountered.
walkabout(visitor)
Perform a tree traversal similarly to Node.walk() (which see), except also call the dispatch_departure() method before exiting each node.
Parameter visitor: A NodeVisitor object, containing a visit and depart implementation for each Node subclass encountered.
There are no known subclasses.