InheritanceGraph

class documentationtools.InheritanceGraph(addresses=('abjad', ), lineage_addresses=None, lineage_prune_distance=None, recurse_into_submodules=True, root_addresses=None, use_clusters=True, use_groups=True)

Generates a graph of a class or collection of classes as a dictionary of parent-children relationships:

>>> class A(object): pass
...
>>> class B(A): pass
...
>>> class C(B): pass
...
>>> class D(B): pass
...
>>> class E(C, D): pass
...
>>> class F(A): pass
...
>>> graph = documentationtools.InheritanceGraph(addresses=(F, E))

InheritanceGraph may be instantiated from one or more instances, classes or modules. If instantiated from a module, all public classes in that module will be taken into the graph.

A root_class keyword may be defined at instantiation, which filters out all classes from the graph which do not inherit from that root_class (or are not already the root_class):

>>> graph = documentationtools.InheritanceGraph(
...     (A, B, C, D, E, F),
...     root_addresses=(B,),
...     )

The class is intended for use in documenting packages.

To document all of Abjad, use this formulation:

>>> graph = documentationtools.InheritanceGraph(
...     addresses=('abjad',),
...     )

To document only those classes descending from Container, use this formulation:

>>> graph = documentationtools.InheritanceGraph(
...     addresses=('abjad',),
...     root_addresses=(Container,),
...     )

To document only those classes whose lineage pass through scoretools, use this formulation:

>>> graph = documentationtools.InheritanceGraph(
...     addresses=('abjad',),
...     lineage_addresses=(scoretools,),
...     )

When creating the Graphviz representation, classes in the inheritance graph may be hidden, based on their distance from any defined lineage class:

>>> graph = documentationtools.InheritanceGraph(
...     addresses=('abjad',),
...     lineage_addresses=(instrumenttools.Instrument,),
...     lineage_prune_distance=1,
...     )

Returns InheritanceGraph instance.

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_documentationtools { graph [label=documentationtools]; "abjad.tools.documentationtools.InheritanceGraph.InheritanceGraph" [color=black, fontcolor=white, group=2, label=<<B>InheritanceGraph</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.documentationtools.InheritanceGraph.InheritanceGraph"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

addresses Addresses of inheritance graph.
child_parents_mapping Child / parent mapping of inheritance graph.
immediate_classes Immediate classes of inheritance graph.
lineage_addresses Lineage addresses of inheritance graph.
lineage_classes Lineage classes of inheritance graph.
lineage_distance_mapping Lineage distance mapping of inheritance graph.
lineage_prune_distance Lineage prune distance of inheritance graph.
parent_children_mapping Parent / children mapping of inheritancee graph.
recurse_into_submodules Recurse into submodules.
root_addresses Root addresses of inheritance graph.
root_classes Root classes of inheritance graph.
use_clusters Use clusters.
use_groups Use groups.
__eq__(argument) Is true when ID of argument equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__graph__(**keywords) Graphviz graph of inheritance graph.
__hash__() Hashes Abjad object.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

InheritanceGraph.addresses

Addresses of inheritance graph.

InheritanceGraph.child_parents_mapping

Child / parent mapping of inheritance graph.

InheritanceGraph.immediate_classes

Immediate classes of inheritance graph.

InheritanceGraph.lineage_addresses

Lineage addresses of inheritance graph.

InheritanceGraph.lineage_classes

Lineage classes of inheritance graph.

InheritanceGraph.lineage_distance_mapping

Lineage distance mapping of inheritance graph.

InheritanceGraph.lineage_prune_distance

Lineage prune distance of inheritance graph.

InheritanceGraph.parent_children_mapping

Parent / children mapping of inheritancee graph.

InheritanceGraph.recurse_into_submodules

Recurse into submodules.

InheritanceGraph.root_addresses

Root addresses of inheritance graph.

InheritanceGraph.root_classes

Root classes of inheritance graph.

InheritanceGraph.use_clusters

Use clusters.

InheritanceGraph.use_groups

Use groups.

Special methods

(AbjadObject).__eq__(argument)

Is true when ID of argument equals ID of Abjad object. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

InheritanceGraph.__graph__(**keywords)

Graphviz graph of inheritance graph.

(AbjadObject).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.