This example uses the doc
package to inspect the relationships within one of its own modules: doc/doc/utils.py
In [1]:
cd /Users/harrold/Documents/GitHub/stharrold/doc/
In [2]:
from __future__ import absolute_import, division, print_function
import doc
%matplotlib inline
In [3]:
# Create a dict from the docstrings in doc/doc/utils.py
docs_dict = doc.utils.make_docs_dict(fpath='/Users/harrold/Documents/GitHub/stharrold/doc/doc/utils.py')
doc.utils.pretty_print_dict(dobj=docs_dict, indent=0)
In [4]:
print("Graph the relationships between methods within the module.")
print("NOTE: Asymmetries in the thickness of the graph edges show\n" +
" that the manual labeling of relationships within doc/utils.py\n" +
" is inconsistent.")
graph = doc.utils.make_graph(dobj=docs_dict, parent='')
doc.utils.plot_graph(graph=graph, fixed=None, positions=None, show_plot=True, fpath=None)
In [5]:
print("Plot the relationships between modules rank-sorted by:\n" +
"line number from top to bottom\n" +
"column number from left to right.")
print("NOTE: As of 2015-04-08, all methods are at column 0, so rank sorting is degenerate.")
positions = doc.utils.make_positions_dict(dobj=docs_dict, graph=graph, parent='')
doc.utils.plot_graph(graph=graph, fixed=None, positions=positions, show_plot=True, fpath=None)
In [6]:
print("TODO: Color code edges by label.\n" +
"Here, the edge label is just the string representation of the relationship.")
import networkx as nx
positions=nx.spring_layout(graph)
nx.draw(graph, pos=positions)
nx.draw_networkx_labels(graph, pos=positions)
nx.draw_networkx_edge_labels(graph, pos=positions)
Out[6]:
In [7]:
print("TODO: Color code edges by label.\n" +
"Here, the edge label is just the string representation of the relationship.")
positions = doc.utils.make_positions_dict(dobj=docs_dict, graph=graph, parent='')
nx.draw(graph, pos=positions)
nx.draw_networkx_labels(graph, pos=positions)
nx.draw_networkx_edge_labels(graph, pos=positions)
Out[7]:
In [ ]: