class NodeVisitor(object): (source)
Known subclasses: docutils.nodes.GenericNodeVisitor
, docutils.nodes.SparseNodeVisitor
, docutils.writers._html_base.HTMLTranslator
, docutils.writers.latex2e.LaTeXTranslator
, docutils.writers.manpage.Translator
"Visitor" pattern [GoF95] abstract superclass implementation for document tree traversals.
Each node class has corresponding methods, doing nothing by
default; override individual methods for specific and useful
behaviour. The dispatch_visit()
method is called by
Node.walk()
upon entering a node. Node.walkabout()
also calls
the dispatch_departure()
method before exiting a node.
The dispatch methods call "visit_ + node class name" or "depart_ + node class name", resp.
This is a base class for visitors whose visit_... & depart_...
methods should be implemented for all node types encountered (such as
for docutils.writers.Writer
subclasses). Unimplemented methods will
raise exceptions.
For sparse traversals, where only certain node types are of interest, use
subclass SparseNodeVisitor
instead. When (mostly or entirely) uniform
processing is desired, subclass GenericNodeVisitor
.
[GoF95] | Gamma, Helm, Johnson, Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading, MA, USA, 1995. |
Method | __init__ |
Undocumented |
Method | dispatch_departure |
Call self."depart_ + node class name" with node as parameter. If the depart_... method does not exist, call self.unknown_departure. |
Method | dispatch_visit |
Call self."visit_ + node class name" with node as parameter. If the visit_... method does not exist, call self.unknown_visit. |
Method | unknown_departure |
Called before exiting unknown Node types. |
Method | unknown_visit |
Called when entering unknown Node types. |
Class Variable | optional |
Tuple containing node class names (as strings). |
Instance Variable | document |
Undocumented |
docutils.nodes.TreeCopyVisitor
, docutils.transforms.references.DanglingReferencesVisitor
, docutils.writers._html_base.HTMLTranslator
, docutils.writers.docutils_xml.XMLTranslator
, docutils.writers.latex2e.LaTeXTranslator
, docutils.writers.manpage.Translator
, docutils.writers.odf_odt.ODFTranslator
Undocumented
node
as
parameter. If the depart_... method does not exist, call
self.unknown_departure.docutils.writers.odf_odt.ODFTranslator
node
as
parameter. If the visit_... method does not exist, call
self.unknown_visit.docutils.transforms.peps.PEPZeroSpecial
, docutils.transforms.references.DanglingReferencesVisitor
Called when entering unknown Node
types.
Raise an exception unless overridden.
Tuple containing node class names (as strings).
No exception will be raised if writers do not implement visit or departure functions for these node classes.
Used to ensure transitional compatibility with existing 3rd-party writers.
docutils.transforms.references.DanglingReferencesVisitor
Undocumented