Mercurial > hg > batmud > ggrtf
annotate docs/tfdoc.pl @ 1642:acd73fb8402f
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 30 Jan 2021 15:42:55 +0200 |
parents | cc4b935b9482 |
children | de46e2e23c66 |
rev | line source |
---|---|
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 #!/usr/bin/perl -w |
1642 | 2 ### |
3 ### TFDoc for extending GgrTF DocBook manual with embedded TF docs. | |
4 ### Programmed by Matti 'ccr' Hamalainen <ccr@tnsp.org> | |
5 ### (C) Copyright 2009-2016 Tecnic Software productions (TNSP) | |
6 ### | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 use strict; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 use warnings; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 |
1642 | 10 |
1054
04d9510b9591
Convert special characters to XML entities when processing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1051
diff
changeset
|
11 ## Convert special characters to HTML/XML entities |
04d9510b9591
Convert special characters to XML entities when processing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1051
diff
changeset
|
12 sub xmlentities($) |
04d9510b9591
Convert special characters to XML entities when processing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1051
diff
changeset
|
13 { |
04d9510b9591
Convert special characters to XML entities when processing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1051
diff
changeset
|
14 my $value = $_[0]; |
1622 | 15 $value =~ s/&/&/g; |
16 $value =~ s/</</g; | |
17 $value =~ s/>/>/g; | |
1054
04d9510b9591
Convert special characters to XML entities when processing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1051
diff
changeset
|
18 return $value; |
04d9510b9591
Convert special characters to XML entities when processing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1051
diff
changeset
|
19 } |
04d9510b9591
Convert special characters to XML entities when processing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1051
diff
changeset
|
20 |
1642 | 21 |
1424
6a0876dfc9d4
Handle TFDoc @desc lines differently when it comes to entity expansion.
Matti Hamalainen <ccr@tnsp.org>
parents:
1070
diff
changeset
|
22 sub xmlentities2($) |
6a0876dfc9d4
Handle TFDoc @desc lines differently when it comes to entity expansion.
Matti Hamalainen <ccr@tnsp.org>
parents:
1070
diff
changeset
|
23 { |
6a0876dfc9d4
Handle TFDoc @desc lines differently when it comes to entity expansion.
Matti Hamalainen <ccr@tnsp.org>
parents:
1070
diff
changeset
|
24 my $value = $_[0]; |
1622 | 25 $value =~ s/&/&/g; |
1560 | 26 |
27 my $str = ""; | |
28 my $state = 0; | |
29 foreach my $qch (split(//, $value)) | |
30 { | |
31 if ($qch eq "\$") | |
32 { | |
33 $state = !$state; | |
34 $str .= ($state ? "<emphasis>" : "</emphasis>"); | |
35 } | |
36 else | |
37 { | |
38 $str .= $qch; | |
39 } | |
40 } | |
41 return $str; | |
1424
6a0876dfc9d4
Handle TFDoc @desc lines differently when it comes to entity expansion.
Matti Hamalainen <ccr@tnsp.org>
parents:
1070
diff
changeset
|
42 } |
6a0876dfc9d4
Handle TFDoc @desc lines differently when it comes to entity expansion.
Matti Hamalainen <ccr@tnsp.org>
parents:
1070
diff
changeset
|
43 |
1054
04d9510b9591
Convert special characters to XML entities when processing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1051
diff
changeset
|
44 |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 ### Scan one TinyFugue script file for documentation entries |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 sub scan_file($) |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 { |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 my $filename = $_[0]; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 print STDERR "Scanning '$filename'\n"; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 my $data = {}; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 my $cmd = ""; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 my $sect = ""; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 my %bindtypes = ("c" => "cast", "g" => "general", "s" => "skill"); |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 |
1056
1ceda308d03a
Use ISO-8859-1 encoding for TF input files.
Matti Hamalainen <ccr@tnsp.org>
parents:
1054
diff
changeset
|
55 open(FILE, "<:encoding(iso-8859-1)", $filename) or die("Could not open '$filename' for reading.\n"); |
1621 | 56 while (<FILE>) |
57 { | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 chomp; |
1621 | 59 if (/\/prdef(c|g|b)bind\s+-s\"(.+?)\"\s+-c\"(.+?)\"\s*(.*)$/) |
60 { | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 my $opts = $4; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 my $type = $bindtypes{$1}; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 my $tmp = {}; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 $tmp->{"name"} = $2; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 $tmp->{"desc"} = $3; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 $tmp->{"quiet"} = ($opts =~ /-q/) ? 1 : 0; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 $tmp->{"notarget"} = ($opts =~ /-n/) ? 1 : 0; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 push(@{$data->{"binds"}{$type}}, $tmp); |
1621 | 69 } |
70 elsif (/;\s*\@keybind\s+(.*?)\s*=\s*(.*?)$/) | |
71 { | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 $data->{"keybinds"}{$1} = $2; |
1621 | 73 } |
74 elsif (/;\s*\@command\s+(\S+)\s*?(.*)$/) | |
75 { | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 $cmd = $1; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 $sect = "commands"; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 $data->{$sect}{$cmd}{"opts"} = $2; |
1621 | 79 } |
80 elsif (/;\s*\@desc\s+(.*)$/) | |
81 { | |
82 if ($sect ne "" && $cmd ne "") | |
83 { | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 $data->{$sect}{$cmd}{"desc"} .= $1." "; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 } |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 } |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 } |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 close(FILE); |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 return $data; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 } |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 |
1621 | 93 |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 ### Print out a DocBook SGML/XML table header |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 sub table_start |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 { |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 my $title = shift; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 my $cols = shift; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 |
1621 | 100 print |
101 "<table>\n". | |
102 " <title>$title</title>\n". | |
103 " <tgroup cols=\"$cols\" align=\"left\">\n". | |
104 " <thead>\n". | |
105 " <row>\n"; | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 |
1621 | 107 foreach my $col (@_) |
108 { | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 print " <entry>$col</entry>\n"; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 } |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 |
1621 | 112 print |
113 " </row>\n". | |
114 " </thead>\n". | |
115 " <tbody>\n"; | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 } |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 sub table_end |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 { |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 print |
1621 | 121 " </tbody>\n". |
122 " </tgroup>\n". | |
123 "</table>\n"; | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
124 } |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
126 |
1061 | 127 sub handle_directive($$$$$) |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
128 { |
1061 | 129 my ($mode, $title, $currfile, $files, $linen) = @_; |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 |
1061 | 131 die("Directive '\@$mode $title' found, but no \@file directive set before it on line $linen.\n") |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
132 unless defined($currfile); |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 |
1621 | 134 if ($mode eq "keybinds") |
135 { | |
136 # Keyboard bindings | |
137 if (defined($files->{$currfile}{"keybinds"})) | |
138 { | |
139 my $data = $files->{$currfile}{"keybinds"}; | |
140 table_start((defined($title) ? xmlentities($title)." k" : "K")."eybindings", "2", "Key(s)", "Function"); | |
141 foreach my $tmp (sort keys %{$data}) | |
142 { | |
143 print | |
144 " <row><entry>".xmlentities($tmp)."</entry>". | |
1054
04d9510b9591
Convert special characters to XML entities when processing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1051
diff
changeset
|
145 "<entry>".xmlentities($data->{$tmp})."</entry></row>\n"; |
1621 | 146 } |
147 table_end(); | |
148 } | |
149 } | |
150 elsif ($mode eq "binds") | |
151 { | |
152 # Command bindings | |
153 if (defined($files->{$currfile}{"binds"})) | |
154 { | |
155 my $data = $files->{$currfile}{"binds"}; | |
156 foreach my $type (sort keys %{$data}) | |
157 { | |
158 my $entry = $data->{$type}; | |
159 table_start((defined($title) ? xmlentities($title)." " : "")."'$type' type command bindings", "4", "Command", "Quiet", "NoTarget", "Description"); | |
160 foreach my $entry (sort @{$data->{$type}}) | |
161 { | |
162 print | |
163 " <row><entry>".xmlentities($entry->{"name"})."</entry>". | |
164 "<entry>".($entry->{"quiet"} ? "X" : "")."</entry>". | |
165 "<entry>".($entry->{"notarget"} ? "X" : "")."</entry>". | |
166 "<entry>".xmlentities($entry->{"desc"})."</entry></row>\n"; | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 } |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 table_end(); |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
169 } |
1621 | 170 } |
171 } | |
172 elsif ($mode eq "commands") | |
173 { | |
174 # Macro commands | |
175 if (defined($files->{$currfile}{"commands"})) | |
176 { | |
177 my $data = $files->{$currfile}{"commands"}; | |
178 | |
179 table_start((defined($title) ? xmlentities($title)." m" : "M")."acro commands", "2", "Command", "Description"); | |
180 foreach my $tmp (sort keys %{$data}) | |
181 { | |
182 print | |
183 " <row><entry><emphasis>".xmlentities($tmp)."</emphasis> ".xmlentities($data->{$tmp}{"opts"})."</entry>". | |
184 "<entry>".xmlentities2($data->{$tmp}{"desc"}). | |
185 "</entry></row>\n"; | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
186 } |
1621 | 187 table_end(); |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 } |
1621 | 189 } |
190 else | |
191 { | |
192 die("Invalid/unsupported directive '\@$mode $title' on line $linen.\n"); | |
193 } | |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
194 } |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
195 |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
196 |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
197 ### |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
198 ### Main program |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
199 ### |
1061 | 200 my $basepath = shift or die("Usage: <tfdir basepath> < input.sgml > output.sgml\n"); |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
201 |
1061 | 202 print STDERR "Using TF-basepath '$basepath'\n"; |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
203 |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
204 binmode(STDOUT, ":utf8"); |
1061 | 205 binmode(STDIN, ":utf8"); |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
206 |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
207 my $linen = 0; |
1051 | 208 my ($currfile, $currtitle); |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
209 my $files = {}; |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
210 |
1061 | 211 while (<STDIN>) { |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
212 $linen++; |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
213 # Get module filenames from section titles |
1621 | 214 if (/<title>(.*?)\((\S+?\.tf)\)<\/title>/) |
215 { | |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
216 print $_; |
1051 | 217 $currtitle = $1; |
218 $currfile = $2; | |
1621 | 219 if (!defined($files->{$currfile})) |
220 { | |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
221 $files->{$currfile} = scan_file($basepath.$currfile); |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
222 } |
1621 | 223 } |
224 elsif (/<!--\s*\@file\s+\"(.+?)\"\s+\"(.+?)\"\s*-->/) | |
225 { | |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
226 $currfile = $1; |
1051 | 227 $currtitle = $2; |
1621 | 228 if (!defined($files->{$currfile})) |
229 { | |
1047
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
230 $files->{$currfile} = scan_file($basepath.$currfile); |
4451f1a1467a
Modularize the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1044
diff
changeset
|
231 } |
1621 | 232 } |
233 elsif (/<!--\s*\@([a-z]+)\s+\"(.+?)\"\s*-->/) | |
234 { | |
1061 | 235 handle_directive($1, $2, $currfile, $files, $linen); |
1621 | 236 } |
237 elsif (/<!--\s*\@([a-z]+)\s*-->/) | |
238 { | |
1061 | 239 handle_directive($1, $currtitle, $currfile, $files, $linen); |
1621 | 240 } |
241 else | |
242 { | |
1044
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
243 print $_; |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
244 } |
d8b504e5b356
Imported initial implementation of TFDoc, an extremely simplistic embedded documentation extractor.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
245 } |