diff options
author | Lars Wirzenius <liw@qvarnlabs.com> | 2019-09-14 20:26:45 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@qvarnlabs.com> | 2019-09-14 20:26:45 +0300 |
commit | b7e919e56109acf509253a243b0eb23787b4653c (patch) | |
tree | 5cd8825932cec123222b3b21fc09428f13115d45 | |
parent | c909dc2cf3b65992eca761d6508d4b45ea255d9f (diff) | |
download | ql-ikiwiki-publish-b7e919e56109acf509253a243b0eb23787b4653c.tar.gz |
Change: wrap labels automatically
-rw-r--r-- | NEWS | 3 | ||||
-rwxr-xr-x | projgraph | 16 |
2 files changed, 19 insertions, 0 deletions
@@ -8,6 +8,9 @@ Version 0.15+git, not yet released the goal, and automatically finds goal (tasks that nothing depend on). +* `projgraph` now wraps label text to lines of up to 20 chars, unless + the label already contains a newline. + Version 0.15, released 2018-05-03 ---------------------------------- @@ -1,10 +1,14 @@ #!/usr/bin/python3 import sys +import textwrap import yaml +LABEL_WIDTH = 20 + + unknown = 0 blocked = 1 finished = 2 @@ -113,6 +117,17 @@ def set_status(tasks): unknown_tasks = find_unknown(tasklist) +def wrap_labels(tasks): + for name in tasks: + task = tasks[name] + if 'label' in task: + label = task['label'] + if '\n' not in label: + label = textwrap.wrap(label, width=LABEL_WIDTH) + label = '\n'.join(label) + task['label'] = label + + obj = yaml.safe_load(sys.stdin) ikiwiki = sys.argv[1:] == ['ikiwiki'] @@ -122,6 +137,7 @@ else: print('digraph "project" {') tasks = obj.get('tasks', obj) +wrap_labels(tasks) set_status(tasks) for name, task in tasks.items(): print('{} [label="{}"]'.format(name, task['label'])) |