Commit 36d0bdcb authored by Bram Schoenmakers's avatar Bram Schoenmakers

Print the legend for each item

parent 99e30ce3
......@@ -32,6 +32,18 @@ class DotPrinter(Printer):
self.todolist = p_todolist
def print_list(self, p_todos):
def escape(p_text):
""" Escapes double quotes as they are special in attributes. """
return p_text.replace('"', '\\"')
def legend():
"""
Generates a legend for each todo item thas is to be printed.
"""
return '\n'.join(sorted([escape('{} {}'.format(
self.todolist.number(t), t.text()
)) for t in p_todos]))
node_name = lambda t: str(self.todolist.number(t))
node_tooltip = lambda t: escape(t.text())
......@@ -56,5 +68,9 @@ class DotPrinter(Printer):
node_name(child)
)
# print legend
result += 'rank=sink\n'
result += 'legend [ fontsize=8, shape=box, label="{}" ]\n'.format(legend())
result += '}\n'
return result
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment