Created
February 29, 2012 09:29
-
-
Save xen/1939420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| find templates/ -name '*.html'|xargs -n 1 gawk ' | |
| BEGIN {ln=0;} | |
| {ln+=1} | |
| ln==1 { | |
| gsub("templates/?","",FILENAME); | |
| label=FILENAME; | |
| gsub("[/.]", "_", FILENAME); | |
| cluster=label; | |
| sub("/[^/]*$", "", cluster); | |
| print "###CLUSTER " cluster; | |
| sub("^.*/", "", label); | |
| print "f_" FILENAME "[label=\"" label "\"]"; | |
| } | |
| /{%[[:space:]]*extends[[:space:]]*[[:punct:]][^%]+%}/ { | |
| gsub("[/.]", "_"); | |
| match($0, /{%[[:space:]]*extends[[:space:]][[:punct:]](.*)[[:punct:]][[:space:]]%}/, ary); | |
| print "f_" FILENAME " -> f_" ary[1] " [arrowhead = empty]; "; | |
| } | |
| /{%[[:space:]]*include[^%]+%}/ { | |
| gsub("[/.]", "_"); | |
| match($0, /{%[[:space:]]*include[[:space:]][[:punct:]]([a-zA-Z0-9_/.]*)[[:punct:]][[:space:]](with|%)/, ary); | |
| print "f_" FILENAME " -> f_" ary[1] " [style = dotted, constraint = false, color = gray]; "; | |
| }'|gawk ' | |
| BEGIN { | |
| cur_cluster=""; theend="" | |
| print "digraph G \{rankdir=LR;" | |
| print "node[shape=box, style=filled]" | |
| } | |
| END { | |
| if (cur_cluster) print "}"; | |
| print theend | |
| print "\}"; | |
| } | |
| /^###CLUSTER / { | |
| sub("^###CLUSTER ", ""); | |
| if (cur_cluster!=$0) { | |
| if (cur_cluster) print "}"; | |
| cluster = $0 | |
| gsub("[/.]", "_", cluster); | |
| if ($0) print "subgraph cluster" cluster " { label=\"" $0 "\""; | |
| cur_cluster = $0; | |
| } | |
| $0=""; | |
| } | |
| /->/ { | |
| theend = theend $0; | |
| $0="" | |
| } | |
| {if ($0) print} | |
| ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment