Skip to content

Commit

Permalink
Make traceables in graphs lineup per category
Browse files Browse the repository at this point in the history
  • Loading branch information
t4ngo committed Aug 14, 2016
1 parent ce0f693 commit 239b3e1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion sphinxcontrib/traceables/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,21 @@ def generate_dot(self, graph_input):
dot.attr("node", fontname="helvetica", fontsize="7.5")
dot.attr("edge", fontname="helvetica", fontsize="7.5")

# Group traceables by their category.
categorized = {}
for traceable in graph_input.traceables:
self.add_dot_traceable(dot, traceable)
category = traceable.attributes.get("category")
categorized.setdefault(category, []).append(traceable)

# Create subgraphs for each category so that its traceables lineup.
for category, traceables in categorized.items():
subgraph = Digraph(str(category))
subgraph.body.append("rank=same")
for traceable in traceables:
self.add_dot_traceable(subgraph, traceable)
dot.subgraph(subgraph)

# Add the relationships between traceables.
for relationship_info in graph_input.relationships:
traceable1, traceable2, relationship, direction = relationship_info
src = traceable1.tag if direction >= 0 else traceable2.tag
Expand Down

0 comments on commit 239b3e1

Please sign in to comment.