class Visitor(_BaseVisitor[
Known subclasses: pydoctor.test.test_visitor.DocutilsNodeVisitor
, pydoctor.visitor.PartialVisitor
"Visitor" pattern abstract superclass implementation for tree traversals.
Each class has corresponding methods, doing nothing by
default; override individual methods for specific and useful
behaviour. The visit()
method is called by
walk()
upon entering a object. walkabout()
also calls
the depart()
method before exiting a object.
The generic methods call "visit_ + objet class name" or "depart_ + objet class name", resp.
This is a base class for visitors whose visit_... & depart_... methods should be implemented for all concrete objets types encountered.
This visitor can be composed by other vistitors, see L{VisitorExt}.
Exception |
|
Do not visit any children of the current node. The current node's siblings and depart_... method are not affected. |
Exception |
|
Do not call the current node's depart_... method. The current node's children and siblings are not affected. |
Exception |
|
Do not visit the current node's children, and do not call the current node's depart_... method. |
Exception |
|
Do not visit any more siblings (to the right) of the current node. The current node's children and its depart_... method are not affected. |
Class Method | get |
Undocumented |
Method | __init__ |
Undocumented |
Method | depart |
Extend the base depart with extensions. |
Method | visit |
Extend the base visit with extensions. |
Method | walk |
Traverse a tree of objects, calling the visit() method of visitor when entering each node. (The walkabout() method is similar, except it also calls the depart() method before exiting each objects.) |
Method | walkabout |
Perform a tree traversal similarly to walk() (which see), except also call the depart() method before exiting each node. |
Instance Variable | extensions |
Undocumented |
Exception | _ |
Base class for Visitor -related tree pruning exceptions. |
Inherited from _BaseVisitor
:
Method | unknown |
Called before exiting unknown object types. |
Method | unknown |
Called when entering unknown object types. |
pydoctor.visitor._BaseVisitor.visit
Extend the base visit with extensions.
- Parameters:
- node: The node to visit.
Parameters | |
ob:T | Undocumented |
Traverse a tree of objects, calling the
visit()
method of visitor
when entering each
node. (The walkabout()
method is similar, except it also
calls the depart()
method before exiting each objects.)
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.
Parameters | |
ob:T | An object to walk. |
Perform a tree traversal similarly to walk()
(which
see), except also call the depart()
method before exiting each node.
Takes special care to handle L{_TreePruningException} the following way:
- If a L{SkipNode} or L{SkipDeparture} exception is raised inside the main visitor C{visit()} method, the C{depart_*} method on the extensions will still be called.
Parameters | |
ob:T | An object to walk. |