From 37c51b80cceae9c03df139dca109fbae7d6edf8e Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 16 Oct 2012 00:31:47 -0400 Subject: [PATCH] Add a tool to draw the Django template inheritance graph (imported from commit e10bb719d62a76abfea76c7fc69093a3cc33272e) --- templates/.gitignore | 1 + tools/django-template-graph | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 templates/.gitignore create mode 100755 tools/django-template-graph 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