diff --git a/templates/.gitignore b/templates/.gitignore new file mode 100644 index 0000000000..0710042df0 --- /dev/null +++ b/templates/.gitignore @@ -0,0 +1 @@ +/graph.svg diff --git a/tools/django-template-graph b/tools/django-template-graph new file mode 100755 index 0000000000..58e5a8b0b7 --- /dev/null +++ b/tools/django-template-graph @@ -0,0 +1,18 @@ +#!/bin/bash -e + +# Draws the Django template inheritance graph. + +cd "$(dirname "$0")"/../templates + +( + echo 'digraph {' + for t in $(find -name '*.html' -printf '%P\n'); do + echo "\"$t\";" + perl -lne 'print "\"'"$t"'\" -> \"$1\";" if m/{%\s*extends\s*"([^"]+)"/' "$t" + done + echo '}' +) > graph.dot + +dot -Tsvg graph.dot > graph.svg +rm graph.dot +echo file://"$(pwd)"/graph.svg