ford.graphs module#
- class ford.graphs.AfferentGraph(root, data, ident=None)#
Bases:
FortranGraph
Shows the relationship between files which depend upon this one
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- exception ford.graphs.BadType(value)#
Bases:
Exception
Raised when a type is passed to GraphData.register() which is not accepted.
- class ford.graphs.BaseNode(obj, graph_data, hist=None)#
Bases:
object
Graph node representing some Fortran entity
- Parameters:
obj (
Union
[FortranContainer
,FortranBoundProcedure
,str
]) – Fortran entity instance or namegraph_data (
GraphData
) – Collection of nodes for other entitieshist (
Optional
[Dict
[Union
[FortranContainer
,FortranBoundProcedure
],BaseNode
]])
- colour = '#777777'#
- class ford.graphs.CallGraph(root, data, ident=None)#
Bases:
FortranGraph
Adds edges indicating the call-tree for the procedures listed in the nodes.
- RANKDIR = 'LR'#
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- extra_attributes()#
Add any extra attributes to the graph
- class ford.graphs.CalledByGraph(root, data, ident=None)#
Bases:
FortranGraph
Graphs procedures called by this procedure
- RANKDIR = 'LR'#
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- extra_attributes()#
Add any extra attributes to the graph
- class ford.graphs.CallsGraph(root, data, ident=None)#
Bases:
FortranGraph
Graphs procedures that this procedure calls
- RANKDIR = 'LR'#
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- extra_attributes()#
Add any extra attributes to the graph
- class ford.graphs.EfferentGraph(root, data, ident=None)#
Bases:
FortranGraph
Shows the relationship between the files which this one depends on
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- class ford.graphs.FileGraph(root, data, ident=None)#
Bases:
FortranGraph
Graphs relationships between source files
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- class ford.graphs.FortranGraph(root, data, ident=None)#
Bases:
object
Graph of some relationship for a given entity
- Parameters:
root (
Union
[FortranContainer
,Iterable
[FortranContainer
]]) – Top-level entity or entities in graphdata (
GraphData
) – Collection of nodes and graph customisation optionsident (
Optional
[str
]) – Alternative identification for graph, and used as base name for saved files. If there are multiple entities inroot
, andident
isn’t given, it is set from the first entity inroot
- hop_nodes#
Nodes of the hop which exceed the maximum
- hop_edges#
Edges of the hop which exceed the maximum
- added#
Set of nodes in graph
- max_nesting#
Maximum number of hops allowed. Set from maximum value of
graph_maxdepth
inroot.meta
- max_nodes#
Maximum number of nodes allowed. Set from maximum value of
graph_maxnodes
inroot.meta
- warn#
If true, show warnings if graphs exceed
max_nesting
ormax_nodes
- truncated#
Nesting level where the graph was truncated
- RANKDIR = 'RL'#
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- add_nodes(nodes, nesting=1)#
Add nodes and edges to this graph, based on the collection
nodes
Subclasses should implement
FortranGraph.add_node
, and optionallyFortranGraph.extra_attributes
- add_to_graph(nodes, edges, nesting)#
Adds nodes and edges to the graph as long as the maximum number of nodes is not exceeded. All edges are expected to have a reference to an entry in nodes. If the list of nodes is not added in the first hop due to graph size limitations, they are stored in hop_nodes. If the graph was extended the function returns True, otherwise the result will be False.
- create_svg(out_location)#
- extra_attributes()#
Add any extra attributes to the graph
- class ford.graphs.GraphData(parent_dir, coloured_edges, show_proc_parent)#
Bases:
object
Stores graph nodes representing Fortran entities to be displayed in a graph, as well as some customisation options for graphs
- Parameters:
- get_node(obj, hist=None)#
Returns the node corresponding to
obj
. If does not already exist then it will create it.- Parameters:
obj (
Union
[FortranContainer
,FortranBoundProcedure
]) – Some Fortran entityhist (
Optional
[Dict
[Union
[FortranContainer
,FortranBoundProcedure
],BaseNode
]]) – Collection of previously seen objects, used when registering children during node creation
- Return type:
- register(obj, hist=None)#
Create and store the graph node for
obj
, if it hasn’t already been registered- Parameters:
obj (
Union
[FortranContainer
,FortranBoundProcedure
]) – Some Fortran entityhist (
Optional
[Dict
[Union
[FortranContainer
,FortranBoundProcedure
],BaseNode
]]) – Collection of previously seen objects, used when registering children during node creation
- Return type:
- class ford.graphs.GraphManager(graphdir, parentdir, coloured_edges, show_proc_parent, save_graphs=False)#
Bases:
object
Collection of graphs of the various relationships between a set of entities
Contains graphs of module use relations, type relations, call trees, etc. It manages these, ensures that everything that is needed is added at the correct time, and produces the plots for the list pages.
- Parameters:
graphdir (
PathLike
) – The location of the graphs within the output tree.parentdir (
str
) – Location of top-level directorycoloured_edges (
bool
) – If true, arrows in graphs use different colours to help distinguish themshow_proc_parent (
bool
) – If true, show the parent of a procedure in the call graph as part of the labelsave_graphs (
bool
) – If true, save graphs as separate files, as well as embedding them in the HTML
- graph_all()#
Create all graphs
- output_graphs(njobs=0)#
Save graphs to file
- register(obj)#
Register
obj
as a node to be used in graphs
- class ford.graphs.InheritedByGraph(root, data, ident=None)#
Bases:
FortranGraph
Graphs types that inherit this type
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- class ford.graphs.InheritsGraph(root, data, ident=None)#
Bases:
FortranGraph
Graphs types that this type inherits from
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- class ford.graphs.ModuleGraph(root, data, ident=None)#
Bases:
FortranGraph
Shows the relationship between modules and submodules
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- extra_attributes()#
Add any extra attributes to the graph
- class ford.graphs.ProcNode(obj, gd, hist=None)#
Bases:
BaseNode
- COLOURS = {'boundproc': '#A7506F', 'function': '#d94e8f', 'interface': '#A7506F', 'subroutine': '#d9534f'}#
- property colour#
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- class ford.graphs.TypeGraph(root, data, ident=None)#
Bases:
FortranGraph
Graphs inheritance and composition relationships between derived types
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- extra_attributes()#
Add any extra attributes to the graph
- class ford.graphs.UsedByGraph(root, data, ident=None)#
Bases:
FortranGraph
Graphs how modules are used by other modules
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- class ford.graphs.UsesGraph(root, data, ident=None)#
Bases:
FortranGraph
Graphs how modules use other modules, including ancestor (sub)modules
- add_node(hop_nodes, hop_edges, node, colour)#
Add a single node and its edges to this graph, typically by iterating over parents/children
- ford.graphs.get_call_nodes(calls, visited=None, result=None)#
takes a list of calls, and returns a set of all the calls that should be nodes in the graph
not all calls are a node, some are not visible, and some are simple procedure bindings (bindings that bind one visible procedure to one label)
these should be skipped, and show a call to their descendant instead
- Return type:
- ford.graphs.is_blockdata(obj)#
- ford.graphs.is_module(obj)#
- ford.graphs.is_proc(obj)#
- ford.graphs.is_program(obj)#
- ford.graphs.is_sourcefile(obj)#
- ford.graphs.is_submodule(obj)#
- ford.graphs.is_type(obj)#
- ford.graphs.newdict(old, key, val)#
- ford.graphs.outputFuncWrap(args)#
Wrapper function for output graphs – needed to allow multiprocessing to pickle the function (must be at top level)