]> git.decadent.org.uk Git - maypole.git/blobdiff - doc/makedoc.pl
This is a (slightly dodgy) way of keeping template documentation with
[maypole.git] / doc / makedoc.pl
diff --git a/doc/makedoc.pl b/doc/makedoc.pl
new file mode 100644 (file)
index 0000000..b6dec2f
--- /dev/null
@@ -0,0 +1,21 @@
+my @templates = <../templates/factory/*>;
+
+my %doc;
+
+for my $template (@templates) {
+    open TEMP, $template or die $!;
+    $template =~ s/.*factory\///g;
+    while (<TEMP>) {
+        next unless /^#?=for doc/... /^#?=cut/
+                    and not /(%#?\]|\[%#?)$/
+                    and not /=cut|=for doc/; # Much magic.
+        s/^\s*#//g;
+        $doc{$template} .= $_;
+    }
+}
+
+while (<>) {
+    if (!/^=template (\w+)/) { print; next; }
+    die "Can't find doc for template $1" unless $doc{$1};
+    print $doc{$1};
+}