Add a tool to draw the Django template inheritance graph

(imported from commit e10bb719d62a76abfea76c7fc69093a3cc33272e)
This commit is contained in:
Keegan McAllister 2012-10-16 00:31:47 -04:00
parent dbd88b28f3
commit 37c51b80cc
2 changed files with 19 additions and 0 deletions

1
templates/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/graph.svg

18
tools/django-template-graph Executable file
View File

@ -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