aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-04 03:28:49 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-07 13:10:38 +0200
commit85f4a0479c4f1ecb8b589b18393ee00d164b026a (patch)
tree5aab9ae66f4dba116bd78dfab08992a069b75946
parentReplace datetime literals with proper sexps. (diff)
downloadcalp-85f4a0479c4f1ecb8b589b18393ee00d164b026a.tar.gz
calp-85f4a0479c4f1ecb8b589b18393ee00d164b026a.tar.xz
Add script for generating dependency graphs.
-rwxr-xr-xuse2dot/change_graph.py40
-rwxr-xr-xuse2dot/gen_use_graph10
2 files changed, 50 insertions, 0 deletions
diff --git a/use2dot/change_graph.py b/use2dot/change_graph.py
new file mode 100755
index 00000000..50d1c34f
--- /dev/null
+++ b/use2dot/change_graph.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+
+import re
+import colorsys
+import hashlib
+import sys
+
+def md5(str):
+ return hashlib.md5(str.encode("UTF-8")).hexdigest()
+
+def rgb(str):
+ return md5(str)[0:6]
+
+def main(args):
+
+ if len(args) < 3:
+ print("Usage: ./change_graph.py <infile> <outfile>")
+ return
+
+ [_, infile, outfile, *rest] = args
+
+ with open(infile) as f:
+ lines = f.readlines()
+ # [3:-1]
+
+ f = open(outfile, 'w')
+
+ for line in lines:
+ m = re.search('^( *"\(([^)]*)\)" -> "(\([^)]*\))");', line)
+ if m:
+ f.write(f'{m.group(1)} [color="#{rgb(m.group(2))}"];\n')
+ else:
+ f.write(line)
+ # colorsys.hsv_to_rgb(
+
+
+# "(server macro)" -> "(ice-9 regex)";
+
+if __name__ == "__main__":
+ main(sys.argv)
diff --git a/use2dot/gen_use_graph b/use2dot/gen_use_graph
new file mode 100755
index 00000000..030d0c7d
--- /dev/null
+++ b/use2dot/gen_use_graph
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+dir=$(mktemp -d)
+here=$(dirname $(realpath $0))
+
+guild use2dot -m '(main)' -- `find module -name \*.scm` > $dir/use.dot
+$here/change_graph.py $dir/use.dot $dir/use2.dot
+grep -v '\(srfi\|ice-9\|(util)\)' $dir/use2.dot > $dir/use3.dot
+
+fdp $dir/use3.dot -Tpdf -o use.pdf