summaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorAdam Mitz <mitza-oci@users.noreply.github.com>2010-12-22 17:36:26 +0000
committerAdam Mitz <mitza-oci@users.noreply.github.com>2010-12-22 17:36:26 +0000
commita399cf075c134b906526c09c2ad8a2348dadb5bf (patch)
tree81b4fe7b5864eea2292f514c53bffb9cfe4d705d /devtools
parent34954baad53240c7e0dbba7bd95d01d4de9a8a35 (diff)
downloadMPC-a399cf075c134b906526c09c2ad8a2348dadb5bf.tar.gz
ChangeLogTag: Wed Dec 22 17:28:56 UTC 2010 Adam Mitz <mitza@ociweb.com>
Diffstat (limited to 'devtools')
-rwxr-xr-xdevtools/document_template.pl39
1 files changed, 35 insertions, 4 deletions
diff --git a/devtools/document_template.pl b/devtools/document_template.pl
index 49f68e68..d67d941d 100755
--- a/devtools/document_template.pl
+++ b/devtools/document_template.pl
@@ -39,7 +39,7 @@ require StringProcessor;
my %keywords;
my %arrow_op;
my $doc_ext = '.txt';
-my $version = '1.3';
+my $version = '1.4';
# ******************************************************************
# Subroutine Section
@@ -165,6 +165,8 @@ sub display_template {
sub usageAndExit {
print "document_template.pl v$version\n",
"Usage: ", basename($0), " <template> [<outputfile> [language]]\n\n",
+ "template - .mpd file to document. Certain MPC types don't use a template,\n",
+ " in that case this argument can be the Perl module.\n",
"outputfile - This defaults to the name of the template file with the .mpd\n",
" extension replaced with '.html' If <outputfile> ends in '.txt',\n",
" the output is in text format similar to what is found in\n",
@@ -191,6 +193,7 @@ usageAndExit() if (!defined $input || $input =~ /^-/);
if (!defined $output) {
$output = $input;
$output =~ s/\.mpd$//;
+ $output =~ s/(\w+)(Project|Workspace)Creator\.pm$/lc $1/e;
$output .= '.html';
}
elsif ($output =~ /\.txt$/) {
@@ -214,11 +217,29 @@ if (open($fh, $input)) {
}
my %template_keys;
- setup_keywords($language);
-
my @foreach;
my $findex = -1;
+
+ my $inputIsPerl = ($input =~ /\.pm$/);
+ my ($startPattern, $endPattern);
+ if ($inputIsPerl) {
+ my $pkg = basename($input);
+ $pkg =~ s/\.pm$//e;
+ require $input;
+ ($startPattern, $endPattern) = $pkg->documentation_info(\%keywords);
+ }
+ else {
+ setup_keywords($language);
+ }
+ my $skip = $inputIsPerl;
+
while(<$fh>) {
+ if ($inputIsPerl) {
+ $skip = 0 if ($skip && /$startPattern/);
+ $skip = 1 if (!$skip && /$endPattern/);
+ next if $skip;
+ }
+
my $len = length($_);
for(my $start = 0; $start < $len;) {
my $sindex = index($_, '<%', $start);
@@ -301,6 +322,9 @@ if (open($fh, $input)) {
$tvar = undef;
}
}
+ elsif (UNIVERSAL::isa($keywords{$name}, 'CODE')) {
+ ($name, $key, $vname, $tvar) = &{$keywords{$name}}($vname);
+ }
}
else {
$def = $2;
@@ -390,7 +414,14 @@ if (open($fh, $input)) {
my $doc = $input;
$doc =~ s/\.[^\.]+$/$doc_ext/;
- $doc =~ s/templates/docs\/templates/;
+ if ($inputIsPerl) {
+ $doc =~ s/modules/docs\/templates/;
+ $doc =~ s/(\w+)(Project|Workspace)Creator$doc_ext$/lc($1) . $doc_ext/e;
+ }
+ else {
+ $doc =~ s/templates/docs\/templates/;
+ }
+
if (-r $doc) {
$template_cp->read_file($doc);
}