Chris@381
|
1 @rem = '--*-Perl-*--';
|
Chris@381
|
2 @rem = '
|
Chris@381
|
3 @echo off
|
Chris@381
|
4 perl -w -S %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
|
Chris@381
|
5 goto endofperl
|
Chris@381
|
6 @rem ';
|
Chris@381
|
7 # perl -w -S %0.bat "$@"
|
Chris@381
|
8 #!/usr/pdsoft/bin/perl5
|
Chris@381
|
9 #
|
Chris@381
|
10 # mtree2html_2000 - produce html files from Matlab m-files.
|
Chris@381
|
11 # use configuration file for flexibility
|
Chris@381
|
12 # can process tree of directories
|
Chris@381
|
13 #
|
Chris@381
|
14 # Copyright (C) 1996-2000 Hartmut Pohlheim. All rights reserved.
|
Chris@381
|
15 # includes small parts of m2html from Jeffrey C. Kantor 1995
|
Chris@381
|
16 #
|
Chris@381
|
17 # Author: Hartmut Pohlheim
|
Chris@381
|
18 # History: 06.03.1996 file created
|
Chris@381
|
19 # 07.03.1996 first working version
|
Chris@381
|
20 # 08.03.1996 modularized, help text only once included
|
Chris@381
|
21 # 11.03.1996 clean up, some functions rwritten
|
Chris@381
|
22 # 18.04.1996 silent output with writing in one line only
|
Chris@381
|
23 # version 0.20 fixed
|
Chris@381
|
24 # 14.05.1996 start of adding tree structure, could create tree
|
Chris@381
|
25 # 15.05.1996 creating of index files for every directory
|
Chris@381
|
26 # 17.05.1996 first working version except compact A-Z index
|
Chris@381
|
27 # 20.05.1996 cleanup of actual version, more variables and
|
Chris@381
|
28 # configurable settings
|
Chris@381
|
29 # 21.05.1996 reading, update and creation of contents.m added
|
Chris@381
|
30 # 22.05.1996 creation of short index started
|
Chris@381
|
31 # 28.05.1996 jump letters for short index,
|
Chris@381
|
32 # 3 different directory indexes (short/long/contents)
|
Chris@381
|
33 # 29.05.1996 major cleanup, short and long index created from one function
|
Chris@381
|
34 # links for HTML and Indexes from 1 function,
|
Chris@381
|
35 # version 0.9
|
Chris@381
|
36 # 30.05.1996 contents.m changed to Contents.m (because unix likes it)
|
Chris@381
|
37 # function definition can be in first line of m file before comments
|
Chris@381
|
38 # version 0.91 fixed
|
Chris@381
|
39 # 03.06.1996 contents file can be written as wanted, the links will be correct
|
Chris@381
|
40 # cross references in help block of m-file will be found and
|
Chris@381
|
41 # converted, even if the name of the function is written upper case
|
Chris@381
|
42 # version 0.92 fixed
|
Chris@381
|
43 # 05.06.1996 construction of dependency matrix changed, is able now to process
|
Chris@381
|
44 # even the whole matlab tree (previous version needed to much memory)
|
Chris@381
|
45 # removed warning for contents files in different directories
|
Chris@381
|
46 # version 0.94 fixed
|
Chris@381
|
47 # 06.06.1996 new link name matrices for ConstructHTMLFile created,
|
Chris@381
|
48 # everything is done in ConstructDependencyMatrix,
|
Chris@381
|
49 # both dependencies (calls and called) and matrix
|
Chris@381
|
50 # with all mentioned names in this m-file, thus, much
|
Chris@381
|
51 # less scanning in html construction
|
Chris@381
|
52 # script is now (nearly) linear scalable, thus, matlab-toolbox
|
Chris@381
|
53 # tree takes less than 1 hour on a Pentium120, with source
|
Chris@381
|
54 # version 0.96 fixed
|
Chris@381
|
55 # 10.06.1996 order of creation changed, first all indexes (includes
|
Chris@381
|
56 # update/creation of contents.m) and then ConstructDepency
|
Chris@381
|
57 # thus, AutoAdd section will be linked as well
|
Chris@381
|
58 # excludenames extended, some more common word function names added
|
Chris@381
|
59 # version 0.97 fixed
|
Chris@381
|
60 # 17.02.1998 writecontentsm as command line parameter added
|
Chris@381
|
61 # error of file not found will even appear when silent
|
Chris@381
|
62 # version 1.02
|
Chris@381
|
63 # 21.05.2000 mark comments in source code specially (no fully correct,
|
Chris@381
|
64 # can't handle % in strings)
|
Chris@381
|
65 # version 1.11
|
Chris@381
|
66 # 05.11.2000 link also to upper and mixed case m-files
|
Chris@381
|
67 # searching for .m files now really works (doesn't find grep.com any longer)
|
Chris@381
|
68 # file renamed to mtree2html2001
|
Chris@381
|
69 # generated html code now all lower case
|
Chris@381
|
70 # inclusion of meta-description and meta-keywords in html files
|
Chris@381
|
71 # HTML4 compliance done (should be strict HTML4.0, quite near XHTML)
|
Chris@381
|
72 # version 1.23
|
Chris@381
|
73 #
|
Chris@381
|
74 # Latest version is available as:
|
Chris@381
|
75 #
|
Chris@381
|
76 #
|
Chris@381
|
77
|
Chris@381
|
78 $VERSION = '1.23';
|
Chris@381
|
79 ($PROGRAM = $0) =~ s@.*/@@; $PROGRAM = "\U$PROGRAM\E";
|
Chris@381
|
80 $debug = 0;
|
Chris@381
|
81
|
Chris@381
|
82 #------------------------------------------------------------------------
|
Chris@381
|
83 # Define platform specific things
|
Chris@381
|
84 #------------------------------------------------------------------------
|
Chris@381
|
85 # suffix for files to search is defined twice
|
Chris@381
|
86 # the first ($suffix) is for string creation and contains the . as well
|
Chris@381
|
87 # the second ($suffixforsearch) is for regular expression, handling of . is quite special
|
Chris@381
|
88 $suffix = ".m";
|
Chris@381
|
89 $suffixforsearch = "m";
|
Chris@381
|
90 # the directory separator
|
Chris@381
|
91 $dirsep = "/";
|
Chris@381
|
92 # what is the current directory
|
Chris@381
|
93 $diract = ".";
|
Chris@381
|
94
|
Chris@381
|
95 #------------------------------------------------------------------------
|
Chris@381
|
96 # Define all variables and there standard settings
|
Chris@381
|
97 # documentation of variables is contained in accompanying rc file
|
Chris@381
|
98 #------------------------------------------------------------------------
|
Chris@381
|
99 %var =
|
Chris@381
|
100 (
|
Chris@381
|
101 'authorfile', '',
|
Chris@381
|
102 'codebodyfiles', '',
|
Chris@381
|
103 'codebodyindex', '',
|
Chris@381
|
104 'codeheadmeta', '<meta name="author of conversion perl script" content="Hartmut Pohlheim" />',
|
Chris@381
|
105 'codehr', '<hr size="3" noshade="noshade" />',
|
Chris@381
|
106 'codeheader', '',
|
Chris@381
|
107 'configfile', 'mtree2html2001_rc.txt',
|
Chris@381
|
108 'csslink', '',
|
Chris@381
|
109 'dirmfiles', $diract,
|
Chris@381
|
110 'dirhtml', $diract,
|
Chris@381
|
111 'exthtml', '.html',
|
Chris@381
|
112 'filenametopframe', 'index',
|
Chris@381
|
113 'filenameindexlongglobal', 'indexlg',
|
Chris@381
|
114 'filenameindexlonglocal', 'indexll',
|
Chris@381
|
115 'filenameindexshortglobal', 'indexsg',
|
Chris@381
|
116 'filenameindexshortlocal', 'indexsl',
|
Chris@381
|
117 'filenameextensionframe', 'f',
|
Chris@381
|
118 'filenameextensionindex', 'i',
|
Chris@381
|
119 'filenameextensionjump', 'j',
|
Chris@381
|
120 'filenamedirshort', 'dirtops',
|
Chris@381
|
121 'filenamedirlong', 'dirtopl',
|
Chris@381
|
122 'filenamedircontents', 'dirtopc',
|
Chris@381
|
123 'includesource', 'yes',
|
Chris@381
|
124 'links2filescase', 'all',
|
Chris@381
|
125 'processtree', 'yes',
|
Chris@381
|
126 'producetree', 'yes',
|
Chris@381
|
127 'textjumpindexlocal', 'Local Index',
|
Chris@381
|
128 'textjumpindexglobal', 'Global Index',
|
Chris@381
|
129 'texttitleframelayout', 'Documentation of Matlab Files',
|
Chris@381
|
130 'texttitleindexalldirs', 'Index of Directories',
|
Chris@381
|
131 'textheaderindexalldirs', 'Index of Directories',
|
Chris@381
|
132 'texttitleindex', '',
|
Chris@381
|
133 'textheaderindex', '',
|
Chris@381
|
134 'texttitlefiles', 'Documentation of ',
|
Chris@381
|
135 'textheaderfiles', 'Documentation of ',
|
Chris@381
|
136 'usecontentsm', 'yes',
|
Chris@381
|
137 'writecontentsm', 'no'
|
Chris@381
|
138 );
|
Chris@381
|
139
|
Chris@381
|
140
|
Chris@381
|
141 # define all m-file names, that should be excluded from linking
|
Chris@381
|
142 # however, files will still be converted
|
Chris@381
|
143 @excludenames = ( 'all','ans','any','are',
|
Chris@381
|
144 'cs',
|
Chris@381
|
145 'demo','dos',
|
Chris@381
|
146 'echo','edit','else','elseif','end','exist',
|
Chris@381
|
147 'flag','for','function',
|
Chris@381
|
148 'global',
|
Chris@381
|
149 'help',
|
Chris@381
|
150 'i','if','inf','info',
|
Chris@381
|
151 'j',
|
Chris@381
|
152 'more',
|
Chris@381
|
153 'null',
|
Chris@381
|
154 'return',
|
Chris@381
|
155 'script','strings',
|
Chris@381
|
156 'what','which','while','who','whos','why',
|
Chris@381
|
157 );
|
Chris@381
|
158
|
Chris@381
|
159 # Text for inclusion in created HTML/Frame files: Doctype and Charset
|
Chris@381
|
160 $TextDocTypeHTML = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">';
|
Chris@381
|
161 $TextDocTypeFrame = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">';
|
Chris@381
|
162 $TextMetaCharset = '<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />';
|
Chris@381
|
163
|
Chris@381
|
164 #------------------------------------------------------------------------
|
Chris@381
|
165 # Read the command line arguments
|
Chris@381
|
166 #------------------------------------------------------------------------
|
Chris@381
|
167 if (@ARGV == 0) {
|
Chris@381
|
168 &DisplayHelp() if &CheckFileName($var{'configfile'}, 'configuration file');
|
Chris@381
|
169 }
|
Chris@381
|
170
|
Chris@381
|
171 # Print provided command line arguments on screen
|
Chris@381
|
172 foreach (@ARGV) { print " $_\n "; }
|
Chris@381
|
173
|
Chris@381
|
174 # Get the options
|
Chris@381
|
175 use Getopt::Long;
|
Chris@381
|
176 @options = ('help|h', 'todo|t', 'version|v',
|
Chris@381
|
177 'authorfile|a=s', 'configfile|c=s', 'dirhtml|html|d=s',
|
Chris@381
|
178 'dirmfiles|mfiles|m=s', 'includesource|i=s',
|
Chris@381
|
179 'processtree|r=s', 'producetree|p=s',
|
Chris@381
|
180 'silent|quiet|q', 'writecontentsm|w=s');
|
Chris@381
|
181 &GetOptions(@options) || die "use -h switch to display help statement\n";
|
Chris@381
|
182
|
Chris@381
|
183
|
Chris@381
|
184 # Display help or todo list, when requested
|
Chris@381
|
185 &DisplayHelp() if $opt_help;
|
Chris@381
|
186 &DisplayTodo() if $opt_todo;
|
Chris@381
|
187 die "$PROGRAM v$VERSION\n" if $opt_version;
|
Chris@381
|
188
|
Chris@381
|
189 $exit_status = 0;
|
Chris@381
|
190
|
Chris@381
|
191 #------------------------------------------------------------------------
|
Chris@381
|
192 # Read the config file
|
Chris@381
|
193 #------------------------------------------------------------------------
|
Chris@381
|
194 $var{'configfile'} = $opt_configfile if $opt_configfile;
|
Chris@381
|
195 &GetConfigFile($var{'configfile'});
|
Chris@381
|
196
|
Chris@381
|
197
|
Chris@381
|
198 #------------------------------------------------------------------------
|
Chris@381
|
199 # Process/Check the command line otions
|
Chris@381
|
200 #------------------------------------------------------------------------
|
Chris@381
|
201 $var{'dirhtml'} = $opt_dirhtml if $opt_dirhtml;
|
Chris@381
|
202 if (!(substr($var{'dirhtml'}, -1, 1) eq $dirsep)) { $var{'dirhtml'} = $var{'dirhtml'}.$dirsep; }
|
Chris@381
|
203 $var{'dirmfiles'} = $opt_dirmfiles if $opt_dirmfiles;
|
Chris@381
|
204 if (!(substr($var{'dirmfiles'}, -1, 1) eq $dirsep)) { $var{'dirmfiles'} = $var{'dirmfiles'}.$dirsep; }
|
Chris@381
|
205
|
Chris@381
|
206 $var{'authorfile'} = $opt_author if $opt_author;
|
Chris@381
|
207 $var{'includesource'} = $opt_includesource if $opt_includesource;
|
Chris@381
|
208 if ($var{'includesource'} ne 'no') { $var{'includesource'} = 'yes'; }
|
Chris@381
|
209 $var{'processtree'} = $opt_processtree if $opt_processtree;
|
Chris@381
|
210 if ($var{'processtree'} ne 'no') { $var{'processtree'} = 'yes'; }
|
Chris@381
|
211 $var{'producetree'} = $opt_producetree if $opt_producetree;
|
Chris@381
|
212 if ($var{'producetree'} ne 'no') { $var{'producetree'} = 'yes'; }
|
Chris@381
|
213 if ($var{'processtree'} eq 'no') { $var{'producetree'} = 'no'; }
|
Chris@381
|
214 # if (($var{'processtree'} eq 'yes') && ($var{'producetree'} eq 'no')) { $var{'usecontentsm'} = 'no'; }
|
Chris@381
|
215
|
Chris@381
|
216 $var{'writecontentsm'} = $opt_writecontentsm if $opt_writecontentsm;
|
Chris@381
|
217
|
Chris@381
|
218 #------------------------------------------------------------------------
|
Chris@381
|
219 # Do the real stuff
|
Chris@381
|
220 #------------------------------------------------------------------------
|
Chris@381
|
221
|
Chris@381
|
222 # Print variables on screen, when not silent
|
Chris@381
|
223 &ListVariables if !$opt_silent;
|
Chris@381
|
224
|
Chris@381
|
225 # Check the author file
|
Chris@381
|
226 if ($var{'authorfile'} ne '') {
|
Chris@381
|
227 if (&CheckFileName($var{'authorfile'}, 'author file')) {
|
Chris@381
|
228 $var{'authorfile'} = '';
|
Chris@381
|
229 if (!$opt_silent) { print " Proceeding without author information!\n"; }
|
Chris@381
|
230 }
|
Chris@381
|
231 }
|
Chris@381
|
232
|
Chris@381
|
233 # Call the function doing all the real work
|
Chris@381
|
234 &ConstructNameMatrix;
|
Chris@381
|
235
|
Chris@381
|
236 &ConstructDependencyMatrix;
|
Chris@381
|
237
|
Chris@381
|
238 &ConstructAllIndexFiles;
|
Chris@381
|
239
|
Chris@381
|
240 &ConstructHTMLFiles;
|
Chris@381
|
241
|
Chris@381
|
242 exit $exit_status;
|
Chris@381
|
243
|
Chris@381
|
244 #------------------------------------------------------------------------
|
Chris@381
|
245 # Construct list of all mfile names and initialize various data arrays.
|
Chris@381
|
246 #------------------------------------------------------------------------
|
Chris@381
|
247 sub ConstructNameMatrix
|
Chris@381
|
248 {
|
Chris@381
|
249 local(*MFILE);
|
Chris@381
|
250 local($file, $dirname);
|
Chris@381
|
251 local(@newdirectories);
|
Chris@381
|
252 local(%localnames);
|
Chris@381
|
253
|
Chris@381
|
254 $RecDeep = 0;
|
Chris@381
|
255 &ParseTreeReadFiles($var{'dirmfiles'}, $RecDeep);
|
Chris@381
|
256
|
Chris@381
|
257 foreach $dirname (@directories) {
|
Chris@381
|
258 if ($dirnumbermfiles{$dirname} > 0) {
|
Chris@381
|
259 push(@newdirectories, $dirname);
|
Chris@381
|
260 if (! defined($contentsname{$dirname})) {
|
Chris@381
|
261 $contentsname{$dirname} = 'Contents';
|
Chris@381
|
262 if (($var{'writecontentsm'} eq 'no') && ($var{'usecontentsm'} eq 'yes')) {
|
Chris@381
|
263 print "\r ParseTree - for directory $dirname no contents file found!\n";
|
Chris@381
|
264 print " create one or enable writing of contents file (writecontentsm = yes)!\n";
|
Chris@381
|
265 }
|
Chris@381
|
266 }
|
Chris@381
|
267 }
|
Chris@381
|
268 }
|
Chris@381
|
269 @alldirectories = @directories;
|
Chris@381
|
270 @directories = @newdirectories;
|
Chris@381
|
271
|
Chris@381
|
272 foreach $dirname (@directories) {
|
Chris@381
|
273 if ($debug > 0) { print "Dir: $dirname \t\t $dirnumbermfiles{$dirname} \t$contentsname{$dirname}\n"; }
|
Chris@381
|
274 }
|
Chris@381
|
275
|
Chris@381
|
276 @names = sort(keys %mfile);
|
Chris@381
|
277
|
Chris@381
|
278 # check, if name of directory is identical to name of file
|
Chris@381
|
279 @dirsinglenames = values(%dirnamesingle);
|
Chris@381
|
280 grep($localnames{$_}++, @dirsinglenames);
|
Chris@381
|
281 @dirandfilename = grep($localnames{$_}, @names);
|
Chris@381
|
282 if (@dirandfilename) {
|
Chris@381
|
283 print "\r Name clash between directory and file name: @dirandfilename\n";
|
Chris@381
|
284 print " These files will be excluded from linking!\n";
|
Chris@381
|
285 push(@excludenames, @dirandfilename);
|
Chris@381
|
286 }
|
Chris@381
|
287
|
Chris@381
|
288 # construct names matrix for help text linking
|
Chris@381
|
289 # exclude some common words (and at the same time m-functions) from linking in help text
|
Chris@381
|
290 grep($localnames{$_}++, @excludenames);
|
Chris@381
|
291 @linknames = grep(!$localnames{$_}, @names);
|
Chris@381
|
292
|
Chris@381
|
293 if ($debug > 2) { print "linknames (names of found m-files):\n @linknames\n"; }
|
Chris@381
|
294
|
Chris@381
|
295 }
|
Chris@381
|
296
|
Chris@381
|
297 #------------------------------------------------------------------------
|
Chris@381
|
298 # Parse tree and collect all Files
|
Chris@381
|
299 #------------------------------------------------------------------------
|
Chris@381
|
300 sub ParseTreeReadFiles
|
Chris@381
|
301 {
|
Chris@381
|
302 local($dirname, $localRecDeep) = @_;
|
Chris@381
|
303 local($file, $name, $filewosuffix);
|
Chris@381
|
304 local($dirhtmlname, $dirmode);
|
Chris@381
|
305 local($relpath, $relpathtoindex, $replacevardir);
|
Chris@381
|
306 local(*CHECKDIR, *AKTDIR);
|
Chris@381
|
307 local(@ALLEFILES);
|
Chris@381
|
308
|
Chris@381
|
309 opendir(AKTDIR, $dirname) || die "ParseTree - Can't open directory $dirname: $!";
|
Chris@381
|
310 if ($debug > 1) { print "\nDirectory: $dirname\n"; }
|
Chris@381
|
311
|
Chris@381
|
312 # create relative path
|
Chris@381
|
313 $_ = $dirname; $replacevardir = $var{'dirmfiles'};
|
Chris@381
|
314 s/$replacevardir//; $relpath = $_;
|
Chris@381
|
315 s/[^\/]+/../g; $relpathtoindex = $_;
|
Chris@381
|
316
|
Chris@381
|
317 # producetree no
|
Chris@381
|
318 if ($var{'producetree'} eq 'no') { $relpath = ''; $relpathtoindex = ''; }
|
Chris@381
|
319
|
Chris@381
|
320 # names of directories (top-level and below top-level m-file-directory)
|
Chris@381
|
321 push(@directories, $dirname);
|
Chris@381
|
322 $dirnumbermfiles{$dirname} = 0; # set number of m-files for this dir to zero
|
Chris@381
|
323 # relative path from top-level directory, depends on directory name
|
Chris@381
|
324 $dirnamerelpath{$dirname} = $relpath;
|
Chris@381
|
325 # relative path from actual directory to top-level directory, depends on directory name
|
Chris@381
|
326 $dirnamerelpathtoindex{$dirname} = $relpathtoindex;
|
Chris@381
|
327 # recursion level for directory, depends on directory name
|
Chris@381
|
328 $dirnamerecdeep{$dirname} = $localRecDeep;
|
Chris@381
|
329
|
Chris@381
|
330 # only the name of the directory, without path
|
Chris@381
|
331 $rindexprint = rindex($dirname, $dirsep, length($dirname)-2);
|
Chris@381
|
332 $rindsub = substr($dirname, $rindexprint+1, length($dirname)-$rindexprint-2);
|
Chris@381
|
333 $dirnamesingle{$dirname} = $rindsub;
|
Chris@381
|
334
|
Chris@381
|
335 # create name of html-directories
|
Chris@381
|
336 $_ = $dirname;
|
Chris@381
|
337 s/$var{'dirmfiles'}/$var{'dirhtml'}/;
|
Chris@381
|
338 $dirhtmlname = $_;
|
Chris@381
|
339 if ($var{'producetree'} eq 'no') { $dirhtmlname = $var{'dirhtml'}; }
|
Chris@381
|
340 # try to open html directory, if error, then create directory,
|
Chris@381
|
341 # use same mode as for corresponding m-file directory
|
Chris@381
|
342 opendir(CHECKDIR,"$dirhtmlname") || do {
|
Chris@381
|
343 $dirmode = (stat($dirname))[2]; # print "$dirmode\n";
|
Chris@381
|
344 mkdir("$dirhtmlname", $dirmode) || die ("Cannot create directory $dirhtmlname: $! !");
|
Chris@381
|
345 };
|
Chris@381
|
346 closedir(CHECKDIR);
|
Chris@381
|
347
|
Chris@381
|
348
|
Chris@381
|
349 # read everything from this directory and process them
|
Chris@381
|
350 @ALLEFILES = readdir(AKTDIR);
|
Chris@381
|
351
|
Chris@381
|
352 foreach $file (@ALLEFILES) {
|
Chris@381
|
353 # exclude . and .. directories
|
Chris@381
|
354 next if $file eq '.'; next if $file eq '..';
|
Chris@381
|
355
|
Chris@381
|
356 # test for existense of entry (redundant, used for debugging)
|
Chris@381
|
357 if (-e $dirname.$file) {
|
Chris@381
|
358 # if it's a directory, call this function recursively
|
Chris@381
|
359 if (-d $dirname.$file) {
|
Chris@381
|
360 if ($var{'processtree'} eq 'yes') {
|
Chris@381
|
361 &ParseTreeReadFiles($dirname.$file.$dirsep, $localRecDeep+1);
|
Chris@381
|
362 }
|
Chris@381
|
363 }
|
Chris@381
|
364 # if it's a file - test for m-file, save name and create some arrays
|
Chris@381
|
365 elsif (-f $dirname.$file) {
|
Chris@381
|
366 if ($file =~ /\.$suffixforsearch$/i) {
|
Chris@381
|
367 # Remove the file suffix to establish the matlab identifiers
|
Chris@381
|
368 $filewosuffix = $file;
|
Chris@381
|
369 $filewosuffix =~ s/\.$suffixforsearch$//i;
|
Chris@381
|
370 # $filename = $name;
|
Chris@381
|
371
|
Chris@381
|
372 # Contents file in unix must start with a capital letter (Contents.m)
|
Chris@381
|
373 # ensure, that m-file name is lower case, except the contents file
|
Chris@381
|
374 if (! ($filewosuffix =~ /^contents$/i)) {
|
Chris@381
|
375 # if ($var{'links2filescase'} eq 'low') { $filewosuffix = "\L$filewosuffix\E"; }
|
Chris@381
|
376 $filewosuffixlow = "\L$filewosuffix\E";
|
Chris@381
|
377 }
|
Chris@381
|
378 else { $contentsname{$dirname} = $filewosuffix; }
|
Chris@381
|
379
|
Chris@381
|
380 # internal handle name is always lower case
|
Chris@381
|
381 $name = $filewosuffixlow;
|
Chris@381
|
382 # file name is not lower case
|
Chris@381
|
383 $filename = $filewosuffix;
|
Chris@381
|
384
|
Chris@381
|
385 # if don't use C|contents.m, then forget all C|contents.m
|
Chris@381
|
386 if ($var{'usecontentsm'} eq 'no') { if ($name =~ /contents/i) { next; } }
|
Chris@381
|
387
|
Chris@381
|
388 # if m-file with this name already exists, use directory and name for name
|
Chris@381
|
389 # only the first occurence of name will be used for links
|
Chris@381
|
390 if (defined $mfile{$name}) {
|
Chris@381
|
391 if (! ($name =~ /^contents$/i) ) {
|
Chris@381
|
392 print "\r ParseTree - Name conflict: $name in $dirname already exists: $mfile{$name} !\n";
|
Chris@381
|
393 print " $mfile{$name} will be used for links!\n";
|
Chris@381
|
394 }
|
Chris@381
|
395 $name = $dirname.$name;
|
Chris@381
|
396 }
|
Chris@381
|
397 # mfile name with path
|
Chris@381
|
398 $mfile{$name} = $dirname.$file;
|
Chris@381
|
399 # mfile name (without path)
|
Chris@381
|
400 $mfilename{$name} = $filename;
|
Chris@381
|
401 # mfile directory
|
Chris@381
|
402 $mfiledir{$name} = $dirname;
|
Chris@381
|
403
|
Chris@381
|
404 # html file name and full path, special extension of Contents files
|
Chris@381
|
405 if ($name =~ /contents/i) { $extrahtmlfilename = $dirnamesingle{$dirname}; }
|
Chris@381
|
406 else { $extrahtmlfilename = ''; }
|
Chris@381
|
407 $hfile{$name} = $dirhtmlname.$mfilename{$name}.$extrahtmlfilename.$var{'exthtml'};
|
Chris@381
|
408
|
Chris@381
|
409 # save relative html path
|
Chris@381
|
410 # if ($var{'producetree'} eq 'yes') {
|
Chris@381
|
411 $hfilerelpath{$name} = $relpath;
|
Chris@381
|
412 # } else { # if no tree to produce, relative path is empty
|
Chris@381
|
413 # $hfilerelpath{$name} = '';
|
Chris@381
|
414 # }
|
Chris@381
|
415
|
Chris@381
|
416 # create relative path from html file to directory with global index file
|
Chris@381
|
417 $hfileindexpath{$name} = $relpathtoindex;
|
Chris@381
|
418
|
Chris@381
|
419 # Function declaration, if one exists, set default to script
|
Chris@381
|
420 $synopsis{$name} = "";
|
Chris@381
|
421 $mtype{$name} = "script";
|
Chris@381
|
422
|
Chris@381
|
423 # First comment line
|
Chris@381
|
424 $apropos{$name} = "";
|
Chris@381
|
425
|
Chris@381
|
426 # count number of m-files in directories
|
Chris@381
|
427 $dirnumbermfiles{$dirname}++;
|
Chris@381
|
428
|
Chris@381
|
429 if ($debug > 1) {
|
Chris@381
|
430 if ($opt_silent) { print "\r"; }
|
Chris@381
|
431 print " ParseTree: $name \t\t $mfile{$name} \t\t $hfile{$name}\t\t";
|
Chris@381
|
432 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
433 }
|
Chris@381
|
434 }
|
Chris@381
|
435 }
|
Chris@381
|
436 else {
|
Chris@381
|
437 print "Unknown type of file in $dirname: $file\n";
|
Chris@381
|
438 }
|
Chris@381
|
439 }
|
Chris@381
|
440 else { print "Error: Not existing file in $dirname: $file\n"; }
|
Chris@381
|
441 }
|
Chris@381
|
442
|
Chris@381
|
443 closedir(AKTDIR)
|
Chris@381
|
444
|
Chris@381
|
445 }
|
Chris@381
|
446
|
Chris@381
|
447 #------------------------------------------------------------------------
|
Chris@381
|
448 # Construct Dependency matrix
|
Chris@381
|
449 # $dep{$x,$y} > 0 if $x includes a reference to $y.
|
Chris@381
|
450 #------------------------------------------------------------------------
|
Chris@381
|
451 sub ConstructDependencyMatrix
|
Chris@381
|
452 {
|
Chris@381
|
453 &ConstructDependencyMatrixReadFiles('all');
|
Chris@381
|
454 &ConstructDependencyMatrixReally;
|
Chris@381
|
455 }
|
Chris@381
|
456
|
Chris@381
|
457
|
Chris@381
|
458 #------------------------------------------------------------------------
|
Chris@381
|
459 # Construct Dependency matrix
|
Chris@381
|
460 # $dep{$x,$y} > 0 if $x includes a reference to $y.
|
Chris@381
|
461 #------------------------------------------------------------------------
|
Chris@381
|
462 sub ConstructDependencyMatrixReadFiles
|
Chris@381
|
463 {
|
Chris@381
|
464 local($whatstring) = @_;
|
Chris@381
|
465 local(*MFILE);
|
Chris@381
|
466 local($name, $inames);
|
Chris@381
|
467 local(%symbolsdep, %symbolsall);
|
Chris@381
|
468
|
Chris@381
|
469 # Initialize as all zeros.
|
Chris@381
|
470 # foreach $name (@names) { grep($dep{$name,$_}=0,@names); if ($debug > 0) { print "\r DepMatrix anlegen: $name\t$#names\t"; } }
|
Chris@381
|
471
|
Chris@381
|
472 # Compute the dependency matrix
|
Chris@381
|
473 $inames = -1;
|
Chris@381
|
474 foreach $name (@names) {
|
Chris@381
|
475 # Read each file and tabulate the distinct alphanumeric identifiers in
|
Chris@381
|
476 # an array of symbols. Also scan for:
|
Chris@381
|
477 # synopsis: The function declaration line
|
Chris@381
|
478 # apropos: The first line of the help text
|
Chris@381
|
479
|
Chris@381
|
480 # look for whatstring, if all: process every file, if contents: process only contents files
|
Chris@381
|
481 if ($whatstring eq 'contents') { if (! ($name =~ /contents$/i) ) { next; } }
|
Chris@381
|
482 elsif ($whatstring eq 'all') { } # do nothing
|
Chris@381
|
483 else { print "\r ConstructDependency: Unknown parameter whatstring: $whatstring \n"; }
|
Chris@381
|
484
|
Chris@381
|
485 undef %symbolsall; undef %symbolsdep;
|
Chris@381
|
486 open(MFILE,"<$mfile{$name}") || die("Can't open $mfile{$name}: $!\n");
|
Chris@381
|
487 while (<MFILE>) {
|
Chris@381
|
488 chop;
|
Chris@381
|
489
|
Chris@381
|
490 # Split on nonalphanumerics, then look for all words, used for links later
|
Chris@381
|
491 # this one for all references
|
Chris@381
|
492 @wordsall = grep(/[a-zA-Z]\w*/, split('\W',$_));
|
Chris@381
|
493 # set all words to lower case for link checking
|
Chris@381
|
494 undef @wordsall2;
|
Chris@381
|
495 # do case conversion not, case checking is done later
|
Chris@381
|
496 foreach (@wordsall) { push(@wordsall2, "\L$_\E"); }
|
Chris@381
|
497 # @wordsall2 = @wordsall;
|
Chris@381
|
498 grep($symbolsall{$_}++, @wordsall2);
|
Chris@381
|
499
|
Chris@381
|
500 # Store first comment line, skip all others.
|
Chris@381
|
501 if (/^\s*%/) {
|
Chris@381
|
502 if (!$apropos{$name}) {
|
Chris@381
|
503 s/^\s*%\s*//; # remove % and leading white spaces on line
|
Chris@381
|
504 $_ = &SubstituteHTMLEntities($_);
|
Chris@381
|
505 $apropos{$name} = $_;
|
Chris@381
|
506 }
|
Chris@381
|
507 next;
|
Chris@381
|
508 }
|
Chris@381
|
509
|
Chris@381
|
510 # If it's the function declaration line, then store it and skip
|
Chris@381
|
511 # but only, when first function definition (multiple function lines when private subfunctions in file
|
Chris@381
|
512 if ($synopsis{$name} eq '') {
|
Chris@381
|
513 if (/^\s*function/) {
|
Chris@381
|
514 s/^\s*function\s*//;
|
Chris@381
|
515 $synopsis{$name} = $_;
|
Chris@381
|
516 $mtype{$name} = "function";
|
Chris@381
|
517 next;
|
Chris@381
|
518 }
|
Chris@381
|
519 }
|
Chris@381
|
520
|
Chris@381
|
521 # Split off any trailing comments
|
Chris@381
|
522 if ($_ ne '') {
|
Chris@381
|
523 # this one for references in program code only
|
Chris@381
|
524 # when syntax parsing, here is a working place
|
Chris@381
|
525 ($statement) = split('%',$_,1);
|
Chris@381
|
526 @wordsdep = grep(/[a-zA-Z]\w*/,split('\W',$statement));
|
Chris@381
|
527 # do case conversion not, case checking is done later
|
Chris@381
|
528 undef @wordsdep2;
|
Chris@381
|
529 foreach (@wordsdep) { push(@wordsdep2, "\L$_\E"); }
|
Chris@381
|
530 grep($symbolsdep{$_}++, @wordsdep2);
|
Chris@381
|
531 }
|
Chris@381
|
532 }
|
Chris@381
|
533 close MFILE;
|
Chris@381
|
534
|
Chris@381
|
535 # compute intersection between %symbolsall and @linknames
|
Chris@381
|
536 delete($symbolsall{$name});
|
Chris@381
|
537 # foreach $localsumall ($symbolsall) {
|
Chris@381
|
538 # $localsumall = "\L$localsumall\E";
|
Chris@381
|
539 # }
|
Chris@381
|
540 @{'all'.$name} = grep($symbolsall{$_}, @linknames);
|
Chris@381
|
541
|
Chris@381
|
542 # compute intersection between %symbolsdep and @linknames
|
Chris@381
|
543 delete($symbolsdep{$name});
|
Chris@381
|
544 @{'depcalls'.$name} = grep($symbolsdep{$_}, @linknames);
|
Chris@381
|
545
|
Chris@381
|
546 $inames++; print "\r DepCallsMatrix: $inames/$#names\t $name\t";
|
Chris@381
|
547 if ($debug > 2) { print "\n depnames: @{'depcalls'.$name}\n all: @{'all'.$name}\n"; }
|
Chris@381
|
548 }
|
Chris@381
|
549 }
|
Chris@381
|
550
|
Chris@381
|
551
|
Chris@381
|
552 #------------------------------------------------------------------------
|
Chris@381
|
553 # Construct Dependency matrix
|
Chris@381
|
554 # $dep{$x,$y} > 0 if $x includes a reference to $y.
|
Chris@381
|
555 #------------------------------------------------------------------------
|
Chris@381
|
556 sub ConstructDependencyMatrixReally
|
Chris@381
|
557 {
|
Chris@381
|
558 local($inames, $name);
|
Chris@381
|
559
|
Chris@381
|
560 $inames = -1;
|
Chris@381
|
561 foreach $name (@names) { undef %{'depint'.$name}; }
|
Chris@381
|
562 foreach $name (@names) {
|
Chris@381
|
563 grep(${'depint'.$_}{$name}++, @{'depcalls'.$name});
|
Chris@381
|
564 $inames++; print "\r DepCalledMatrix1: $inames/$#names\t $name\t";
|
Chris@381
|
565 }
|
Chris@381
|
566 $inames = -1;
|
Chris@381
|
567 foreach $name (@names) {
|
Chris@381
|
568 # compute intersection between %depint.name{$_} and @linknames
|
Chris@381
|
569 if (defined (%{'depint'.$name})) { @{'depcalled'.$name} = grep(${'depint'.$name}{$_}, @linknames); }
|
Chris@381
|
570 $inames++; print "\r DepCalledMatrix2: $inames/$#names\t $name\t";
|
Chris@381
|
571 if ($debug > 2) { print "\n depcalled: @{'depcalled'.$name}\n"; }
|
Chris@381
|
572 }
|
Chris@381
|
573
|
Chris@381
|
574 }
|
Chris@381
|
575
|
Chris@381
|
576
|
Chris@381
|
577 #========================================================================
|
Chris@381
|
578 # Construct all index files
|
Chris@381
|
579 #========================================================================
|
Chris@381
|
580 sub ConstructAllIndexFiles
|
Chris@381
|
581 {
|
Chris@381
|
582 local(@localnames);
|
Chris@381
|
583 local($ActDir);
|
Chris@381
|
584 local($name);
|
Chris@381
|
585
|
Chris@381
|
586 # define variables and names for frame target
|
Chris@381
|
587 $GlobalNameFrameMainLeft = 'Cont_Main';
|
Chris@381
|
588 $GlobalNameFrameMainRight = 'Cont_Lower';
|
Chris@381
|
589 $GlobalNameFrameAZIndexsmall = 'IndexAZindex';
|
Chris@381
|
590 $GlobalNameFrameAZIndexjump = 'IndexAZjump';
|
Chris@381
|
591
|
Chris@381
|
592 $indexcreated = 0;
|
Chris@381
|
593
|
Chris@381
|
594 &ConstructHighestIndexFile;
|
Chris@381
|
595 $indexcreated++;
|
Chris@381
|
596
|
Chris@381
|
597 # if ($var{'producetree'} eq 'yes') {
|
Chris@381
|
598 # moved next 2 lines out of if for producetree no
|
Chris@381
|
599 # &ConstructHighestIndexFile;
|
Chris@381
|
600 # $indexcreated++;
|
Chris@381
|
601
|
Chris@381
|
602 foreach $ActDir (@directories) {
|
Chris@381
|
603 undef @localnames;
|
Chris@381
|
604 foreach $name (@names) {
|
Chris@381
|
605 local($pathsubstr) = substr($mfile{$name}, 0, rindex($mfile{$name}, "/")+1);
|
Chris@381
|
606 if ($ActDir eq $pathsubstr) {
|
Chris@381
|
607 if ($debug > 1) { print "IndexFile: $pathsubstr ActDir: $ActDir Hfilerelpath: $hfilerelpath{$name}\n"; }
|
Chris@381
|
608 push(@localnames, $name);
|
Chris@381
|
609 }
|
Chris@381
|
610 }
|
Chris@381
|
611 if ($debug > 2) { print "localnames: @localnames\n"; }
|
Chris@381
|
612 # create contents file and short|long index of files in local directory
|
Chris@381
|
613 &ConstructContentsmFile($ActDir, @localnames);
|
Chris@381
|
614 &ConstructAZIndexFile($ActDir, 'short', 'local', @localnames);
|
Chris@381
|
615 &ConstructAZIndexFile($ActDir, 'long', 'local', @localnames);
|
Chris@381
|
616 $indexcreated+=2;
|
Chris@381
|
617 }
|
Chris@381
|
618 # } else {
|
Chris@381
|
619 # &ConstructContentsmFile($var{'dirmfiles'}, @names);
|
Chris@381
|
620 # }
|
Chris@381
|
621
|
Chris@381
|
622 # create short|long index of files in all directory
|
Chris@381
|
623 &ConstructAZIndexFile($var{'dirmfiles'}, 'short', 'global', @names);
|
Chris@381
|
624 &ConstructAZIndexFile($var{'dirmfiles'}, 'long', 'global', @names);
|
Chris@381
|
625 $indexcreated+=2;
|
Chris@381
|
626
|
Chris@381
|
627 # if contents.m were created or updated, the dependency matrices should
|
Chris@381
|
628 # be updated as well
|
Chris@381
|
629 if ($var{'writecontentsm'} eq 'yes') { &ConstructDependencyMatrixReadFiles('contents');; }
|
Chris@381
|
630 }
|
Chris@381
|
631
|
Chris@381
|
632
|
Chris@381
|
633 #========================================================================
|
Chris@381
|
634 # Construct the highest level index file
|
Chris@381
|
635 #========================================================================
|
Chris@381
|
636 sub ConstructHighestIndexFile
|
Chris@381
|
637 {
|
Chris@381
|
638 local(*IFILE);
|
Chris@381
|
639 local($indexfile, $filename);
|
Chris@381
|
640
|
Chris@381
|
641 # Build the frame layout file, this files includes the layout of the frames
|
Chris@381
|
642 # Build the frame layout file name (highest one)
|
Chris@381
|
643 $indexfile = $var{'dirhtml'}.$var{'filenametopframe'}.$var{'exthtml'};
|
Chris@381
|
644
|
Chris@381
|
645 open(IFILE,">$indexfile") || die("Cannot open frame layout file $indexfile\n");
|
Chris@381
|
646 # Write the header of frame file
|
Chris@381
|
647 print IFILE "$TextDocTypeFrame\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n";
|
Chris@381
|
648 print IFILE " <title>$var{'texttitleframelayout'}</title>\n";
|
Chris@381
|
649 print IFILE "</head>\n";
|
Chris@381
|
650
|
Chris@381
|
651 # definition of 2 frames, left the tree of directories,
|
Chris@381
|
652 # right the index of that directory or the docu of a file
|
Chris@381
|
653 print IFILE "<frameset cols=\"25%,75%\">\n";
|
Chris@381
|
654 print IFILE " <frame src=\"$var{'filenamedirshort'}$var{'exthtml'}\" name=\"$GlobalNameFrameMainLeft\" />\n";
|
Chris@381
|
655 print IFILE " <frame src=\"$var{'filenameindexshortglobal'}$var{'filenameextensionframe'}$var{'exthtml'}\" name=\"$GlobalNameFrameMainRight\" />\n"; print IFILE "</frameset>\n";
|
Chris@381
|
656
|
Chris@381
|
657 print IFILE "</html>\n";
|
Chris@381
|
658
|
Chris@381
|
659 close(IFILE);
|
Chris@381
|
660
|
Chris@381
|
661 if ($opt_silent) { print "\r"; }
|
Chris@381
|
662 print " Frame layout file created: $indexfile\t";
|
Chris@381
|
663 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
664
|
Chris@381
|
665 for($irun=0; $irun <= 2; $irun++) {
|
Chris@381
|
666 # Build the top directory index file, these files include the directory tree
|
Chris@381
|
667 # Build the directory tree index file name
|
Chris@381
|
668
|
Chris@381
|
669 # Create no directory file for contents, when no contents to use
|
Chris@381
|
670 if (($irun == 2) && ($var{'usecontentsm'} eq 'no')) { next; }
|
Chris@381
|
671
|
Chris@381
|
672 # Assign the correct index file name
|
Chris@381
|
673 if ($irun == 0) { $filename = $var{'filenamedirshort'}; }
|
Chris@381
|
674 elsif ($irun == 1) { $filename = $var{'filenamedirlong'}; }
|
Chris@381
|
675 elsif ($irun == 2) { $filename = $var{'filenamedircontents'}; }
|
Chris@381
|
676
|
Chris@381
|
677 $indexfile = $var{'dirhtml'}.$filename.$var{'exthtml'};
|
Chris@381
|
678
|
Chris@381
|
679 open(IFILE,">$indexfile") || die("Cannot open directory tree index file $indexfile\n");
|
Chris@381
|
680 # Write header of HTML file
|
Chris@381
|
681 print IFILE "$TextDocTypeHTML\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n$var{'csslink'}\n";
|
Chris@381
|
682
|
Chris@381
|
683 if ($var{'texttitleindexalldirs'} eq '') {
|
Chris@381
|
684 print IFILE "<title>Index of Directories of $var{'dirmfiles'}</title>\n";
|
Chris@381
|
685 } else {
|
Chris@381
|
686 print IFILE "<title>$var{'texttitleindexalldirs'}</title>\n";
|
Chris@381
|
687 }
|
Chris@381
|
688 print IFILE "<base target=\"$GlobalNameFrameMainRight\" />\n";
|
Chris@381
|
689
|
Chris@381
|
690 print IFILE "</head>\n";
|
Chris@381
|
691 print IFILE "<body $var{'codebodyindex'}>\n";
|
Chris@381
|
692 if ($var{'textheaderindexalldirs'} eq '') {
|
Chris@381
|
693 print IFILE "<h1 $var{'codeheader'}>Index of Directories of <em>$var{'dirmfiles'}</em></h1>\n";
|
Chris@381
|
694 } else {
|
Chris@381
|
695 print IFILE "<h1 $var{'codeheader'}>$var{'textheaderindexalldirs'}</h1>\n";
|
Chris@381
|
696 }
|
Chris@381
|
697 print IFILE "<p align=\"center\">\n";
|
Chris@381
|
698 if ($irun == 0) { print IFILE "<strong>short</strong>\n"; }
|
Chris@381
|
699 else { print IFILE "<a href=\"$var{'filenamedirshort'}$var{'exthtml'}\" target=\"$GlobalNameFrameMainLeft\">short</a>\n"; }
|
Chris@381
|
700 if ($irun == 1) { print IFILE " | <strong>long</strong>\n"; }
|
Chris@381
|
701 else { print IFILE " | <a href=\"$var{'filenamedirlong'}$var{'exthtml'}\" target=\"$GlobalNameFrameMainLeft\">long</a>\n"; }
|
Chris@381
|
702 if ($var{'usecontentsm'} eq 'yes') {
|
Chris@381
|
703 if ($irun == 2) { print IFILE " | <strong>contents</strong>\n"; }
|
Chris@381
|
704 else { print IFILE " | <a href=\"$var{'filenamedircontents'}$var{'exthtml'}\" target=\"$GlobalNameFrameMainLeft\">contents</a>\n"; }
|
Chris@381
|
705 }
|
Chris@381
|
706
|
Chris@381
|
707 print IFILE "</p><br />\n\n";
|
Chris@381
|
708 print IFILE "<ul>\n";
|
Chris@381
|
709
|
Chris@381
|
710 # go through all directories and create a list entry for each one,
|
Chris@381
|
711 # depending on recursion level create sublists
|
Chris@381
|
712 $prevrecdeeplevel = 0;
|
Chris@381
|
713 foreach $name (@alldirectories) {
|
Chris@381
|
714 $actrecdeeplevel = $dirnamerecdeep{$name};
|
Chris@381
|
715 for( ; $prevrecdeeplevel < $actrecdeeplevel; $prevrecdeeplevel++ ) { print IFILE "<ul>\n"; }
|
Chris@381
|
716 for( ; $prevrecdeeplevel > $actrecdeeplevel; $prevrecdeeplevel-- ) { print IFILE "</ul>\n"; }
|
Chris@381
|
717 if ($irun == 0) { $indexfilenameused = $var{'filenameindexshortlocal'}.$var{'filenameextensionframe'}; }
|
Chris@381
|
718 elsif ($irun == 1) { $indexfilenameused = $var{'filenameindexlonglocal'}.$var{'filenameextensionframe'}; }
|
Chris@381
|
719 elsif ($irun == 2) { $indexfilenameused = $contentsname{$name}; }
|
Chris@381
|
720 else { die "ConstructHighestIndexFile: Unknown value of irun"; }
|
Chris@381
|
721 if ($dirnumbermfiles{$name} > 0) {
|
Chris@381
|
722 # producetree no
|
Chris@381
|
723 # if ($var{'producetree'} eq 'no') { $dirnamehere = ''; }
|
Chris@381
|
724 # else { $dirnamehere = '$dirnamerelpath{$name}'; }
|
Chris@381
|
725 # print IFILE "<LI><A HREF=\"$dirnamehere$indexfilenameused_$dirnamesingle{$name}$var{'exthtml'}\">$dirnamesingle{$name}</A>\n";
|
Chris@381
|
726 print IFILE "<li><a href=\"$dirnamerelpath{$name}$indexfilenameused$dirnamesingle{$name}$var{'exthtml'}\">$dirnamesingle{$name}</a></li>\n";
|
Chris@381
|
727 } else {
|
Chris@381
|
728 # print directories with no m-files inside not
|
Chris@381
|
729 # print IFILE "<li>$dirnamesingle{$name}</li>\n";
|
Chris@381
|
730 }
|
Chris@381
|
731 }
|
Chris@381
|
732 $actrecdeeplevel = 0;
|
Chris@381
|
733 for( ; $prevrecdeeplevel > $actrecdeeplevel; $prevrecdeeplevel-- ) { print IFILE "</ul>\n"; }
|
Chris@381
|
734 print IFILE "</ul>\n<br />$var{'codehr'}\n";
|
Chris@381
|
735
|
Chris@381
|
736 # Include info about author from authorfile
|
Chris@381
|
737 &WriteFile2Handle($var{'authorfile'}, IFILE);
|
Chris@381
|
738
|
Chris@381
|
739 print IFILE "<!--navigate-->\n";
|
Chris@381
|
740 print IFILE "<!--copyright-->\n";
|
Chris@381
|
741 print IFILE "</body>\n</html>\n";
|
Chris@381
|
742
|
Chris@381
|
743 close(IFILE);
|
Chris@381
|
744
|
Chris@381
|
745 if ($opt_silent) { print "\r"; }
|
Chris@381
|
746 print " Directory - Indexfile created: $indexfile\t";
|
Chris@381
|
747 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
748 }
|
Chris@381
|
749 }
|
Chris@381
|
750
|
Chris@381
|
751
|
Chris@381
|
752 #========================================================================
|
Chris@381
|
753 # Construct the A-Z index file (global/local and/or short/long)
|
Chris@381
|
754 #========================================================================
|
Chris@381
|
755 sub ConstructAZIndexFile
|
Chris@381
|
756 {
|
Chris@381
|
757 local($LocalActDir, $LocalShortLong, $LocalGlobalLocal, @localnames) = @_;
|
Chris@381
|
758 local(*IFILE);
|
Chris@381
|
759 local($name, $indexfilename, $dirpath);
|
Chris@381
|
760 local($firstletter, $firstone);
|
Chris@381
|
761
|
Chris@381
|
762 if ($debug > 2) { print "localnames in AZ small: @localnames\n"; print " ActDir in A-Z: $LocalActDir\n"; }
|
Chris@381
|
763
|
Chris@381
|
764 # extract filename of index file from parameters of function
|
Chris@381
|
765 if ($LocalShortLong eq 'short') {
|
Chris@381
|
766 if ($LocalGlobalLocal eq 'global') { $indexfilename = $var{'filenameindexshortglobal'}; }
|
Chris@381
|
767 elsif ($LocalGlobalLocal eq 'local') { $indexfilename = $var{'filenameindexshortlocal'}; }
|
Chris@381
|
768 else { die "wrong parameter for LocalGlobalLocal in ConstructAZIndexFile: $LocalGlobalLocal."; }
|
Chris@381
|
769 } elsif ($LocalShortLong eq 'long') {
|
Chris@381
|
770 if ($LocalGlobalLocal eq 'global') { $indexfilename = $var{'filenameindexlongglobal'}; }
|
Chris@381
|
771 elsif ($LocalGlobalLocal eq 'local') { $indexfilename = $var{'filenameindexlonglocal'}; }
|
Chris@381
|
772 else { die "wrong parameter for LocalGlobalLocal in ConstructAZIndexFile: $LocalGlobalLocal."; }
|
Chris@381
|
773 } else { die "wrong parameter for LocalShortLong in ConstructAZIndexFile: $LocalShortLong."; }
|
Chris@381
|
774
|
Chris@381
|
775 # producetree no
|
Chris@381
|
776 # if ($var{'producetree'} eq 'no') { $dirnamehere = ''; }
|
Chris@381
|
777 # else { $dirnamehere = '$dirnamerelpath{$LocalActDir}'; }
|
Chris@381
|
778 # Build the index file name
|
Chris@381
|
779 # handle the global index file case separately (no extra directory name in file)
|
Chris@381
|
780 # the local index file name must be extended by the name of the directory
|
Chris@381
|
781 if ($LocalGlobalLocal eq 'global') { $extradirfilename = ''; }
|
Chris@381
|
782 else { $extradirfilename = $dirnamesingle{$LocalActDir}; }
|
Chris@381
|
783 $indexfile = $var{'dirhtml'}.$dirnamerelpath{$LocalActDir}.$indexfilename.$var{'filenameextensionindex'}.$extradirfilename.$var{'exthtml'};
|
Chris@381
|
784 if ($debug > 2) { print " indexfilename (a-z small): $indexfile\n"; }
|
Chris@381
|
785
|
Chris@381
|
786 open(IFILE,">$indexfile") || die("Cannot open index file $indexfile: $!\n");
|
Chris@381
|
787
|
Chris@381
|
788 # Write the header of HTML file
|
Chris@381
|
789 print IFILE "$TextDocTypeHTML\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n$var{'csslink'}\n";
|
Chris@381
|
790
|
Chris@381
|
791 if ($var{'texttitleindex'} eq '') {
|
Chris@381
|
792 print IFILE "<title>Index of Matlab Files in Directory $LocalActDir</title>\n";
|
Chris@381
|
793 } else {
|
Chris@381
|
794 if ($LocalGlobalLocal eq 'global') { print IFILE "<title>$var{'texttitleindex'}</title>\n"; }
|
Chris@381
|
795 else { print IFILE "<title>$var{'texttitleindex'} in Directory $LocalActDir</title>\n"; }
|
Chris@381
|
796 }
|
Chris@381
|
797 print IFILE "<base target=\"$GlobalNameFrameMainRight\" />\n";
|
Chris@381
|
798 print IFILE "</head>\n";
|
Chris@381
|
799 print IFILE "<body $var{'codebodyindex'}>\n";
|
Chris@381
|
800 if ($var{'textheaderindex'} eq '') {
|
Chris@381
|
801 print IFILE "<h1 $var{'codeheader'}>Index of Matlab Files in Directory $LocalActDir</h1>\n";
|
Chris@381
|
802 } else {
|
Chris@381
|
803 if ($LocalGlobalLocal eq 'global') { print IFILE "<h1 $var{'codeheader'}>$var{'textheaderindex'}</h1>\n"; }
|
Chris@381
|
804 else { print IFILE "<h1 $var{'codeheader'}>$var{'textheaderindex'} in Directory $LocalActDir</h1>\n"; }
|
Chris@381
|
805 }
|
Chris@381
|
806
|
Chris@381
|
807 # include links to indexes
|
Chris@381
|
808 &ConstructLinks2Index(IFILE, $dirnamerelpathtoindex{$LocalActDir}, $LocalActDir, $LocalGlobalLocal);
|
Chris@381
|
809
|
Chris@381
|
810 # Collect the starting letters of m files in this directory or all m-files
|
Chris@381
|
811 for('a'..'z') { undef @{$_}; }
|
Chris@381
|
812 foreach $name (@localnames) {
|
Chris@381
|
813 if (! ($mfilename{$name} =~ /contents/i)) {
|
Chris@381
|
814 $firstletter = substr($mfilename{$name}, 0, 1);
|
Chris@381
|
815 # convert first letter always to lower case
|
Chris@381
|
816 # needed for reference to lower and upper case m-files
|
Chris@381
|
817 $firstletter = "\L$firstletter\E";
|
Chris@381
|
818 push(@{$firstletter}, $name);
|
Chris@381
|
819 }
|
Chris@381
|
820 }
|
Chris@381
|
821
|
Chris@381
|
822 if ($LocalShortLong eq 'short') {
|
Chris@381
|
823 # begin create short index
|
Chris@381
|
824 print IFILE "<table width=\"100%\">\n";
|
Chris@381
|
825
|
Chris@381
|
826 for('a'..'z') {
|
Chris@381
|
827 # print " $_: @{$_}\n";
|
Chris@381
|
828 $numberofletter = $#{$_}+1;
|
Chris@381
|
829 if ($numberofletter > 0) {
|
Chris@381
|
830 print IFILE "\n<tr><td colspan=\"2\"><br /><strong><a name=\"\U$_\E$_\" class=\"an\">\U$_\E</a></strong></td></tr>\n";
|
Chris@381
|
831 $numberhalf = ($numberofletter + 1 - (($numberofletter+1) % 2))/2;
|
Chris@381
|
832 if ($debug > 2) { print " $_: @{$_} \t $numberhalf \t $numberofletter\n"; }
|
Chris@381
|
833 for($count = 0; $count < $numberhalf; $count++) {
|
Chris@381
|
834 $name = @{$_}[$count];
|
Chris@381
|
835 if ($LocalGlobalLocal eq 'global') { $dirpath = $hfilerelpath{$name}; } else { $dirpath = ""; }
|
Chris@381
|
836 print IFILE "<tr><td width=\"50%\"><a href=\"$dirpath$mfilename{$name}$var{'exthtml'}\">$mfilename{$name}</a></td>";
|
Chris@381
|
837 if (($count + $numberhalf) < $numberofletter) {
|
Chris@381
|
838 $name = @{$_}[$count + $numberhalf];
|
Chris@381
|
839 if ($LocalGlobalLocal eq 'global') { $dirpath = $hfilerelpath{$name}; } else { $dirpath = ""; }
|
Chris@381
|
840 print IFILE "<td width=\"50%\"><a href=\"$dirpath$mfilename{$name}$var{'exthtml'}\">$mfilename{$name}</a></td></tr>\n";
|
Chris@381
|
841 } else {
|
Chris@381
|
842 print IFILE "<td width=\"50%\"></td></tr>\n";
|
Chris@381
|
843 }
|
Chris@381
|
844 }
|
Chris@381
|
845 }
|
Chris@381
|
846 }
|
Chris@381
|
847 print IFILE "</table>\n<br />$var{'codehr'}\n";
|
Chris@381
|
848
|
Chris@381
|
849 } elsif ($LocalShortLong eq 'long') {
|
Chris@381
|
850 # begin create long index
|
Chris@381
|
851 print IFILE "<table border=\"5\" width=\"100%\" cellpadding=\"5\">\n";
|
Chris@381
|
852 print IFILE "<tr align=\"center\"><th>Name</th><th>Description</th></tr>\n";
|
Chris@381
|
853
|
Chris@381
|
854 for('a'..'z') {
|
Chris@381
|
855 # print " $_: @{$_}\n";
|
Chris@381
|
856 $numberofletter = $#{$_}+1;
|
Chris@381
|
857 if ($numberofletter > 0) {
|
Chris@381
|
858 $firstone = 1;
|
Chris@381
|
859 foreach $name (@{$_}) {
|
Chris@381
|
860 if ($debug > 1) { print " AZinforeach1: $name \t\t $hfilerelpath{$name} \t\t $dirnamerelpath{$LocalActDir}\n"; }
|
Chris@381
|
861 if ($LocalGlobalLocal eq 'global') { $dirpath = $hfilerelpath{$name}; } else { $dirpath = ""; }
|
Chris@381
|
862 if (! ($mfilename{$name} =~ /contents/i)) {
|
Chris@381
|
863 if ($firstone == 1) { print IFILE "\n<tr><td colspan=\"2\"><br /><strong><a name=\"\U$_\E$_\" class=\"an\">\U$_\E</a></strong></td></tr>\n"; $firstone = 0; }
|
Chris@381
|
864 print IFILE "<tr><td valign=\"top\"><a href=\"$dirpath$mfilename{$name}$var{'exthtml'}\">$mfilename{$name}</a></td><td>$apropos{$name}</td></tr>\n";
|
Chris@381
|
865 }
|
Chris@381
|
866 }
|
Chris@381
|
867 }
|
Chris@381
|
868 }
|
Chris@381
|
869 print IFILE "</table>\n<br />$var{'codehr'}\n";
|
Chris@381
|
870 } else { die "wrong parameter for LocalShortLong in ConstructAZIndexFile: $LocalShortLong."; }
|
Chris@381
|
871
|
Chris@381
|
872 # Include info about author from authorfile
|
Chris@381
|
873 &WriteFile2Handle($var{'authorfile'}, IFILE);
|
Chris@381
|
874
|
Chris@381
|
875 print IFILE "<!--navigate-->\n";
|
Chris@381
|
876 print IFILE "<!--copyright-->\n";
|
Chris@381
|
877 print IFILE "</body>\n</html>\n";
|
Chris@381
|
878
|
Chris@381
|
879 close(IFILE);
|
Chris@381
|
880
|
Chris@381
|
881 if ($opt_silent) { print "\r"; }
|
Chris@381
|
882 print " Indexfile small (A-Z) created: $indexfile\t";
|
Chris@381
|
883 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
884
|
Chris@381
|
885
|
Chris@381
|
886 # Build the A-Z jump index file name
|
Chris@381
|
887 # handle the global index file case separately (no extra directory name in file)
|
Chris@381
|
888 if ($LocalGlobalLocal eq 'global') { $extradirfilename = ''; }
|
Chris@381
|
889 else { $extradirfilename = $dirnamesingle{$LocalActDir}; }
|
Chris@381
|
890 $indexfile = $var{'dirhtml'}.$dirnamerelpath{$LocalActDir}.$indexfilename.$var{'filenameextensionjump'}.$extradirfilename.$var{'exthtml'};
|
Chris@381
|
891 if ($debug > 2) { print " indexfilename (a-z jump): $indexfile\n"; }
|
Chris@381
|
892 open(IFILE,">$indexfile") || die("Cannot open jump index file $indexfile: $!\n");
|
Chris@381
|
893
|
Chris@381
|
894 # Write the header of HTML file
|
Chris@381
|
895 print IFILE "$TextDocTypeHTML\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n$var{'csslink'}\n";
|
Chris@381
|
896
|
Chris@381
|
897 if ($var{'texttitleindex'} eq '') {
|
Chris@381
|
898 print IFILE "<title>A-Z jump index in directory $LocalActDir</title>\n";
|
Chris@381
|
899 } else {
|
Chris@381
|
900 if ($LocalGlobalLocal eq 'global') { print IFILE "<title>$var{'texttitleindex'}</title>\n"; }
|
Chris@381
|
901 else { print IFILE "<title>$var{'texttitleindex'} in Directory $LocalActDir</title>\n"; }
|
Chris@381
|
902 }
|
Chris@381
|
903 print IFILE "<base target=\"$GlobalNameFrameAZIndexsmall\" />\n";
|
Chris@381
|
904 print IFILE "</head>\n";
|
Chris@381
|
905 print IFILE "<body $var{'codebodyindex'}>\n";
|
Chris@381
|
906
|
Chris@381
|
907 # Write the A-Z jump line, generate link for letters with files starting with this letter
|
Chris@381
|
908 # and only letters for no files starting with this letter
|
Chris@381
|
909 # use previously generated arrays with names of files sorted by starting letter
|
Chris@381
|
910 for('a'..'z') {
|
Chris@381
|
911 $numberofletter = $#{$_}+1;
|
Chris@381
|
912 if ($numberofletter > 0) {
|
Chris@381
|
913 print IFILE "<strong><a href=\"$indexfilename$var{'filenameextensionindex'}$extradirfilename$var{'exthtml'}#\U$_\E$_\">\U$_\E</a> </strong>\n";
|
Chris@381
|
914 } else {
|
Chris@381
|
915 print IFILE "\U$_\E \n";
|
Chris@381
|
916 }
|
Chris@381
|
917 }
|
Chris@381
|
918
|
Chris@381
|
919 print IFILE "</body>\n</html>\n";
|
Chris@381
|
920
|
Chris@381
|
921 close(IFILE);
|
Chris@381
|
922
|
Chris@381
|
923 if ($opt_silent) { print "\r"; }
|
Chris@381
|
924 print " Indexfile small (A-Z jump) created: $indexfile\t";
|
Chris@381
|
925 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
926
|
Chris@381
|
927
|
Chris@381
|
928 # Build the frame layout file, this file includes the layout of the frames
|
Chris@381
|
929 # Build the frame layout file name (for small/compact A-Z index)
|
Chris@381
|
930 # handle the global index file case separately (no extra directory name in file)
|
Chris@381
|
931 if ($LocalGlobalLocal eq 'global') { $extradirfilename = ''; }
|
Chris@381
|
932 else { $extradirfilename = $dirnamesingle{$LocalActDir}; }
|
Chris@381
|
933 $indexfile = $var{'dirhtml'}.$dirnamerelpath{$LocalActDir}.$indexfilename.$var{'filenameextensionframe'}.$extradirfilename.$var{'exthtml'};
|
Chris@381
|
934 if ($debug > 2) { print " indexfilename (a-z frame): $indexfile\n"; }
|
Chris@381
|
935
|
Chris@381
|
936 open(IFILE,">$indexfile") || die("Cannot open jump index frame file $indexfile: $!\n");
|
Chris@381
|
937
|
Chris@381
|
938 # Write the header of Frame file
|
Chris@381
|
939 print IFILE "$TextDocTypeHTML\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n$var{'csslink'}\n";
|
Chris@381
|
940
|
Chris@381
|
941 if ($var{'texttitleindex'} eq '') {
|
Chris@381
|
942 print IFILE "<title>Index of Matlab Files in Directory $LocalActDir</title>\n";
|
Chris@381
|
943 } else {
|
Chris@381
|
944 if ($LocalGlobalLocal eq 'global') { print IFILE "<title>$var{'texttitleindex'}</title>\n"; }
|
Chris@381
|
945 else { print IFILE "<title>$var{'texttitleindex'} in Directory $LocalActDir</title>\n"; }
|
Chris@381
|
946 }
|
Chris@381
|
947 print IFILE "</head>\n";
|
Chris@381
|
948
|
Chris@381
|
949 # definition of 2 frames, top the A-Z index, below the jump letter line
|
Chris@381
|
950 print IFILE "<frameset rows=\"90%,10%\">\n";
|
Chris@381
|
951 print IFILE " <frame src=\"$indexfilename$var{'filenameextensionindex'}$extradirfilename$var{'exthtml'}\" name=\"$GlobalNameFrameAZIndexsmall\" />\n";
|
Chris@381
|
952 print IFILE " <frame src=\"$indexfilename$var{'filenameextensionjump'}$extradirfilename$var{'exthtml'}\" name=\"$GlobalNameFrameAZIndexjump\" />\n";
|
Chris@381
|
953 print IFILE "</frameset>\n";
|
Chris@381
|
954
|
Chris@381
|
955 print IFILE "</html>\n";
|
Chris@381
|
956
|
Chris@381
|
957 close(IFILE);
|
Chris@381
|
958
|
Chris@381
|
959 if ($opt_silent) { print "\r"; }
|
Chris@381
|
960 print " Frame layout file created: $indexfile\t";
|
Chris@381
|
961 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
962 }
|
Chris@381
|
963
|
Chris@381
|
964
|
Chris@381
|
965 #========================================================================
|
Chris@381
|
966 # Construct the links to all indexes
|
Chris@381
|
967 #========================================================================
|
Chris@381
|
968 sub ConstructLinks2Index
|
Chris@381
|
969 {
|
Chris@381
|
970 local(*WRITEFILE, $LocalPath2Index, $PathContents, $LocalGlobalLocal) = @_;
|
Chris@381
|
971
|
Chris@381
|
972 # include links to short/long - local/global index and C|contents.m
|
Chris@381
|
973 print WRITEFILE "\n<p align=\"center\">";
|
Chris@381
|
974 print WRITEFILE "$var{'textjumpindexglobal'} (";
|
Chris@381
|
975 print WRITEFILE "<a href = \"$LocalPath2Index$var{'filenameindexshortglobal'}$var{'filenameextensionframe'}$var{'exthtml'}\">short</a> | ";
|
Chris@381
|
976 print WRITEFILE "<a href = \"$LocalPath2Index$var{'filenameindexlongglobal'}$var{'filenameextensionframe'}$var{'exthtml'}\">long</a>)\n";
|
Chris@381
|
977 if ($LocalGlobalLocal eq 'local') {
|
Chris@381
|
978 if ($var{'usecontentsm'} eq 'yes') {
|
Chris@381
|
979 print WRITEFILE " | <a href=\"$contentsname{$PathContents}$dirnamesingle{$PathContents}$var{'exthtml'}\">Local contents</a>\n";
|
Chris@381
|
980 }
|
Chris@381
|
981 # if ($var{'producetree'} eq 'yes') {
|
Chris@381
|
982 print WRITEFILE " | $var{'textjumpindexlocal'} (";
|
Chris@381
|
983 print WRITEFILE "<a href = \"$var{'filenameindexshortlocal'}$var{'filenameextensionframe'}$dirnamesingle{$PathContents}$var{'exthtml'}\">short</a> | ";
|
Chris@381
|
984 print WRITEFILE "<a href = \"$var{'filenameindexlonglocal'}$var{'filenameextensionframe'}$dirnamesingle{$PathContents}$var{'exthtml'}\">long</a>)\n";
|
Chris@381
|
985 # }
|
Chris@381
|
986 }
|
Chris@381
|
987 print WRITEFILE "</p>\n\n";
|
Chris@381
|
988 print WRITEFILE "$var{'codehr'}\n";
|
Chris@381
|
989 }
|
Chris@381
|
990
|
Chris@381
|
991
|
Chris@381
|
992 #========================================================================
|
Chris@381
|
993 # Construct the contents.m files or update
|
Chris@381
|
994 #========================================================================
|
Chris@381
|
995 sub ConstructContentsmFile
|
Chris@381
|
996 {
|
Chris@381
|
997 local($LocalActDir, @localnames) = @_;
|
Chris@381
|
998 local(*CFILE, $name,$newline);
|
Chris@381
|
999 local($contentsfile, $isincontentsonly);
|
Chris@381
|
1000 local(@lines, @autoaddlines, @emptylines);
|
Chris@381
|
1001 local($autoadd) = 'AutoAdd';
|
Chris@381
|
1002 local($autoaddsection) = 0;
|
Chris@381
|
1003 local($emptylineflag) = 0;
|
Chris@381
|
1004 local(%nameincontents);
|
Chris@381
|
1005
|
Chris@381
|
1006 # Build the contents file name
|
Chris@381
|
1007 $contentsfile = $LocalActDir.$contentsname{$LocalActDir}.$suffix;
|
Chris@381
|
1008
|
Chris@381
|
1009 if (-e $contentsfile) {
|
Chris@381
|
1010 open(CFILE,"<$contentsfile") || die("Cannot open contents file $contentsfile: $!\n");
|
Chris@381
|
1011 while (<CFILE>) {
|
Chris@381
|
1012 # Search for the specified string pattern
|
Chris@381
|
1013 @words = split;
|
Chris@381
|
1014 if ((@words >= 3) && ($words[2] eq '-')) {
|
Chris@381
|
1015 $isincontentsonly = 0;
|
Chris@381
|
1016 foreach $name (@localnames) {
|
Chris@381
|
1017 if ($name eq $words[1]) { # old
|
Chris@381
|
1018 # if ($mfilename{$name} eq $words[1]) {
|
Chris@381
|
1019 $isincontentsonly = 1;
|
Chris@381
|
1020 $nameincontents{$name} = 1;
|
Chris@381
|
1021 $newline = sprintf("%% %-13s - %s\n", $mfilename{$name}, $apropos{$name});
|
Chris@381
|
1022 push(@lines, $newline);
|
Chris@381
|
1023 }
|
Chris@381
|
1024 }
|
Chris@381
|
1025 # issue a warning, if file is in contents, but not as file in the directory
|
Chris@381
|
1026 if ($isincontentsonly == 0) {
|
Chris@381
|
1027 print "\rConstructContents: Obsolete entry $words[1] in $contentsfile ! Entry not used.\n";
|
Chris@381
|
1028 }
|
Chris@381
|
1029 } else {
|
Chris@381
|
1030 # look for the AutoAdd section, should be the second word
|
Chris@381
|
1031 if ((@words >= 2) && ($words[1] eq $autoadd)) { $autoaddsection = 1; }
|
Chris@381
|
1032 # push the red line in an array
|
Chris@381
|
1033 push(@lines, $_);
|
Chris@381
|
1034 }
|
Chris@381
|
1035 }
|
Chris@381
|
1036 close(CFILE);
|
Chris@381
|
1037 } else {
|
Chris@381
|
1038 $newline = "% MATLAB Files in directory $LocalActDir\n%\n";
|
Chris@381
|
1039 push(@lines, $newline);
|
Chris@381
|
1040
|
Chris@381
|
1041 }
|
Chris@381
|
1042
|
Chris@381
|
1043 # collect the file names, that were not included in original C|contents.m
|
Chris@381
|
1044 foreach $name (@localnames) {
|
Chris@381
|
1045 if (! defined $nameincontents{$name}) {
|
Chris@381
|
1046 if (! ($mfilename{$name} =~ /contents/i)) {
|
Chris@381
|
1047 $newline = sprintf("%% %-13s - %s\n", $mfilename{$name}, $apropos{$name});
|
Chris@381
|
1048 push(@autoaddlines, $newline);
|
Chris@381
|
1049 }
|
Chris@381
|
1050 }
|
Chris@381
|
1051 }
|
Chris@381
|
1052
|
Chris@381
|
1053 # write/update C|contents.m only if variable is set
|
Chris@381
|
1054 if ($var{'writecontentsm'} eq 'yes') {
|
Chris@381
|
1055 unlink($contentsfile);
|
Chris@381
|
1056 open(CFILE,">$contentsfile") || die("Cannot open contents file $contentsfile: $!\n");
|
Chris@381
|
1057 # write old C|contents.m or header of new file, as long as comment lines
|
Chris@381
|
1058 foreach $line (@lines) {
|
Chris@381
|
1059 if ($emptylineflag == 0) {
|
Chris@381
|
1060 if ($line =~ /^\s*%/) { print CFILE $line; }
|
Chris@381
|
1061 else { $emptylineflag = 1; push(@emptylines, $line); }
|
Chris@381
|
1062 } else { push(@emptylines, $line); }
|
Chris@381
|
1063 }
|
Chris@381
|
1064 # add header of AutoAdd section
|
Chris@381
|
1065 if (($autoaddsection == 0) && (@autoaddlines > 0)) { print CFILE "%\n% $autoadd\n"; }
|
Chris@381
|
1066 # add autoadd section lines (previously undocumented files
|
Chris@381
|
1067 foreach $line (@autoaddlines) { print CFILE $line; }
|
Chris@381
|
1068 # add tail of original C|contents.m (everything behind first non-comment line)
|
Chris@381
|
1069 foreach $line (@emptylines) { print CFILE $line; }
|
Chris@381
|
1070 print CFILE "\n";
|
Chris@381
|
1071 close CFILE;
|
Chris@381
|
1072 if ($opt_silent) { print "\r"; }
|
Chris@381
|
1073 print " Contents file created/updated: $contentsfile\t";
|
Chris@381
|
1074 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
1075 }
|
Chris@381
|
1076 }
|
Chris@381
|
1077
|
Chris@381
|
1078
|
Chris@381
|
1079 #========================================================================
|
Chris@381
|
1080 # Replace found special characters with their HTMl Entities
|
Chris@381
|
1081 #========================================================================
|
Chris@381
|
1082 sub SubstituteHTMLEntities {
|
Chris@381
|
1083 local($_) = @_;
|
Chris@381
|
1084
|
Chris@381
|
1085 # Replace & <-> & < <-> < > <-> > " <-> "
|
Chris@381
|
1086 s/&/&/g; s/\</</g; s/\>/>/g; s/\"/"/g;
|
Chris@381
|
1087 return $_;
|
Chris@381
|
1088 }
|
Chris@381
|
1089
|
Chris@381
|
1090 #========================================================================
|
Chris@381
|
1091 # Replace found m-filenamestring with full link.
|
Chris@381
|
1092 #========================================================================
|
Chris@381
|
1093 sub SubstituteName2Link {
|
Chris@381
|
1094 local($_, $funname) = @_;
|
Chris@381
|
1095 local($refstr1, $refstr2, $reffound);
|
Chris@381
|
1096
|
Chris@381
|
1097 # Look for something matching in the line
|
Chris@381
|
1098 if ( /(\W+)($funname)(\W+)/i ) {
|
Chris@381
|
1099 $reffound = $2;
|
Chris@381
|
1100 $refstr1 = "<a class=\"mfun\" href=\"$hfileindexpath{$name}$hfilerelpath{$funname}$funname$var{'exthtml'}\">";
|
Chris@381
|
1101 $refstr2 = "<\/a>";
|
Chris@381
|
1102 # Do links only for exact case match
|
Chris@381
|
1103 if ( ($var{'links2filescase'} eq 'exact') || ($var{'links2filescase'} eq 'exactvery') ) {
|
Chris@381
|
1104 if ( /(\W+)($funname)(\W+)/g ) {
|
Chris@381
|
1105 s/(\W+)($funname)(\W+)/$1$refstr1$funname$refstr2$3/g;
|
Chris@381
|
1106 }
|
Chris@381
|
1107 else {
|
Chris@381
|
1108 # Print info for not matching case in references, good for check up of files
|
Chris@381
|
1109 if ( ($var{'links2filescase'} eq 'exactvery') ) {
|
Chris@381
|
1110 print "Diff in case found: $funname (case of file name) <-> $reffound (case in source code)\n";
|
Chris@381
|
1111 print " (source line) $_ \n";
|
Chris@381
|
1112 }
|
Chris@381
|
1113 }
|
Chris@381
|
1114 }
|
Chris@381
|
1115 # Do links for exact match and additionally for all upper case (often used in original matlab help text)
|
Chris@381
|
1116 elsif ( ($var{'links2filescase'} eq 'exactupper') ) {
|
Chris@381
|
1117 s/(\W+)($funname)(\W+)/$1$refstr1$2$refstr2$3/g;
|
Chris@381
|
1118 $funname2 = "\U$funname\E";
|
Chris@381
|
1119 s/(\W+)($funname2)(\W+)/$1$refstr1$2$refstr2$3/g;
|
Chris@381
|
1120 }
|
Chris@381
|
1121 # Do links for all case mixes, this calls for trouble under LINUX/UNIX
|
Chris@381
|
1122 else { #elsif ( ($var{'links2filescase'} eq 'all') )
|
Chris@381
|
1123 s/(\W+)($funname)(\W+)/$1$refstr1$2$refstr2$3/ig;
|
Chris@381
|
1124 }
|
Chris@381
|
1125 }
|
Chris@381
|
1126
|
Chris@381
|
1127 return $_;
|
Chris@381
|
1128 }
|
Chris@381
|
1129
|
Chris@381
|
1130 #========================================================================
|
Chris@381
|
1131 # Construct the html files for each matlab file.
|
Chris@381
|
1132 # Need to reread each matlab file to find the help text.
|
Chris@381
|
1133 # Note that we can't do this in a single loop because sometimes
|
Chris@381
|
1134 # the help text maybe before the function declaration.
|
Chris@381
|
1135 #========================================================================
|
Chris@381
|
1136 sub ConstructHTMLFiles
|
Chris@381
|
1137 {
|
Chris@381
|
1138 local(*MFILE);
|
Chris@381
|
1139 local(*HFILE);
|
Chris@381
|
1140
|
Chris@381
|
1141 local($filescreated) = 0;
|
Chris@381
|
1142 local($functionline);
|
Chris@381
|
1143
|
Chris@381
|
1144 foreach $name (@names) {
|
Chris@381
|
1145 # Create cross reference information already here, used for keywords as well
|
Chris@381
|
1146 # Construct list of referenced functions
|
Chris@381
|
1147 @xref = @{'depcalls'.$name}; # the functions, that this m-file calls
|
Chris@381
|
1148 @yref = @{'depcalled'.$name}; # the functions, that this m-file is called from
|
Chris@381
|
1149 # print " depcalls: @{'depcalls'.$name}\n depcalled: @{'depcalled'.$name}\n";
|
Chris@381
|
1150 # foreach $cname (@names) { next if $cname eq $name; push(@yref,$cname) if grep(/$name/,@{'depcalls'.$cname}); }
|
Chris@381
|
1151
|
Chris@381
|
1152
|
Chris@381
|
1153 # Open m-file and html-file
|
Chris@381
|
1154 open(MFILE,"<$mfile{$name}");
|
Chris@381
|
1155 open(HFILE,">$hfile{$name}");
|
Chris@381
|
1156
|
Chris@381
|
1157 # Write the header of HTML file
|
Chris@381
|
1158 print HFILE "$TextDocTypeHTML\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n$var{'csslink'}\n";
|
Chris@381
|
1159
|
Chris@381
|
1160 # Write meta tags: use apropos (one line function description) for description
|
Chris@381
|
1161 # and cross reference function names for keywords (any better ideas?)
|
Chris@381
|
1162 print HFILE "<meta name=\"description\" content=\" $apropos{$name} \" />\n";
|
Chris@381
|
1163 print HFILE "<meta name=\"keywords\" content=\" @xref @yref \" />\n";
|
Chris@381
|
1164
|
Chris@381
|
1165 # Write Title and start body of html-file
|
Chris@381
|
1166 print HFILE "<title>$var{'texttitlefiles'} $mfilename{$name}</title>\n</head>\n";
|
Chris@381
|
1167 print HFILE "<body $var{'codebodyfiles'}>\n";
|
Chris@381
|
1168 print HFILE "<h1 $var{'codeheader'}>$var{'textheaderfiles'} $mfilename{$name}</h1>\n";
|
Chris@381
|
1169 print HFILE "$var{'codehr'}\n";
|
Chris@381
|
1170
|
Chris@381
|
1171 # include links to short/long - local/global index and C|contents.m
|
Chris@381
|
1172 &ConstructLinks2Index(HFILE, $hfileindexpath{$name}, $mfiledir{$name}, 'local');
|
Chris@381
|
1173
|
Chris@381
|
1174 # If this is a function, then write out the first line as a synopsis
|
Chris@381
|
1175 if ($mtype{$name} eq "function") {
|
Chris@381
|
1176 print HFILE "<h2 $var{'codeheader'}>Function Synopsis</h2>\n";
|
Chris@381
|
1177 print HFILE "<pre>$synopsis{$name}</pre>\n$var{'codehr'}\n";
|
Chris@381
|
1178 }
|
Chris@381
|
1179
|
Chris@381
|
1180 # Look for the matlab help text block
|
Chris@381
|
1181 $functionline = "\n";
|
Chris@381
|
1182 do {
|
Chris@381
|
1183 $_ = <MFILE>;
|
Chris@381
|
1184 # remember functionline, if before help text block
|
Chris@381
|
1185 if (/^\s*function/) { $functionline = $_; }
|
Chris@381
|
1186 } until (/^\s*%/ || eof);
|
Chris@381
|
1187 if (! (eof(MFILE))) {
|
Chris@381
|
1188 print HFILE "<h2 $var{'codeheader'}>Help text</h2>\n";
|
Chris@381
|
1189 print HFILE "<pre>\n";
|
Chris@381
|
1190 while (/^\s*%/) {
|
Chris@381
|
1191 # First remove leading % and white space, then Substitute special characlers
|
Chris@381
|
1192 s/^\s*%//;
|
Chris@381
|
1193 $_ = &SubstituteHTMLEntities($_);
|
Chris@381
|
1194
|
Chris@381
|
1195 # check/create cross references
|
Chris@381
|
1196 foreach $funname (@{'all'.$name}) {
|
Chris@381
|
1197 if ($funname =~ /simulink/) { print "\n Simulink - Filename: $name; scanname: $funname\n"; }
|
Chris@381
|
1198 next if $funname eq $name;
|
Chris@381
|
1199 $_ = &SubstituteName2Link($_, $funname);
|
Chris@381
|
1200 }
|
Chris@381
|
1201 print HFILE $_;
|
Chris@381
|
1202 if (! eof) { $_ = <MFILE>; }
|
Chris@381
|
1203 }
|
Chris@381
|
1204 print HFILE "</pre>\n$var{'codehr'}\n";
|
Chris@381
|
1205 }
|
Chris@381
|
1206
|
Chris@381
|
1207 # Write the cross reference information
|
Chris@381
|
1208 if (@xref || @yref) {
|
Chris@381
|
1209 print HFILE "<h2 $var{'codeheader'}>Cross-Reference Information</H2>\n";
|
Chris@381
|
1210 print HFILE "<table border=\"0\" width=\"100%\">\n<tr align=\"left\">\n<th width=\"50%\">";
|
Chris@381
|
1211 if (@xref) {
|
Chris@381
|
1212 print HFILE "This $mtype{$name} calls";
|
Chris@381
|
1213 }
|
Chris@381
|
1214 print HFILE "</th>\n<th width=\"50%\">";
|
Chris@381
|
1215 if (@yref) {
|
Chris@381
|
1216 print HFILE "This $mtype{$name} is called by";
|
Chris@381
|
1217 }
|
Chris@381
|
1218 print HFILE "</th>\n</tr>\n<tr valign=\"top\"><td>";
|
Chris@381
|
1219 if (@xref) {
|
Chris@381
|
1220 print HFILE "\n<ul>\n";
|
Chris@381
|
1221 foreach $cname (sort @xref) {
|
Chris@381
|
1222 print HFILE "<li><a class=\"mfun\" href=\"$hfileindexpath{$name}$hfilerelpath{$cname}$mfilename{$cname}$var{'exthtml'}\">$mfilename{$cname}</a></li>\n";
|
Chris@381
|
1223 }
|
Chris@381
|
1224 print HFILE "</ul>\n";
|
Chris@381
|
1225 }
|
Chris@381
|
1226 print HFILE "</td><td>";
|
Chris@381
|
1227 if (@yref) {
|
Chris@381
|
1228 print HFILE "\n<ul>\n";
|
Chris@381
|
1229 foreach $cname (sort @yref) {
|
Chris@381
|
1230 print HFILE "<li><a class=\"mfun\" href=\"$hfileindexpath{$name}$hfilerelpath{$cname}$mfilename{$cname}$var{'exthtml'}\">$mfilename{$cname}</a></li>\n";
|
Chris@381
|
1231 }
|
Chris@381
|
1232 print HFILE "</ul>\n";
|
Chris@381
|
1233 }
|
Chris@381
|
1234 print HFILE "</td>\n</tr>\n</table>\n";
|
Chris@381
|
1235 print HFILE "$var{'codehr'}\n";
|
Chris@381
|
1236 }
|
Chris@381
|
1237
|
Chris@381
|
1238 # Include source text if requested
|
Chris@381
|
1239 if (($var{'includesource'} eq 'yes') && (! ($mfilename{$name} =~ /^contents$/i))) {
|
Chris@381
|
1240 print HFILE "<h2 $var{'codeheader'}>Listing of $mtype{$name} $mfilename{$name}</h2>\n";
|
Chris@381
|
1241 seek(MFILE,0,0);
|
Chris@381
|
1242 print HFILE "<pre>\n";
|
Chris@381
|
1243 $IsStillHelp = 2;
|
Chris@381
|
1244 print HFILE $functionline; # functionline from scanning of help
|
Chris@381
|
1245 while (<MFILE>) {
|
Chris@381
|
1246 if ($IsStillHelp == 2) {
|
Chris@381
|
1247 next if (/^\s*$/);
|
Chris@381
|
1248 next if (/^\s*function/);
|
Chris@381
|
1249 if (/^\s*%/) { $IsStillHelp = 1; next; }
|
Chris@381
|
1250 } elsif ($IsStillHelp == 1) {
|
Chris@381
|
1251 next if (/^\s*%/);
|
Chris@381
|
1252 $IsStillHelp = 0;
|
Chris@381
|
1253 }
|
Chris@381
|
1254
|
Chris@381
|
1255 # Substritute special characters
|
Chris@381
|
1256 $_ = &SubstituteHTMLEntities($_);
|
Chris@381
|
1257
|
Chris@381
|
1258 # check for comment in line and format with css em
|
Chris@381
|
1259 s/(.*)%(.*)/$1<em class=\"mcom\">%$2<\/em>/;
|
Chris@381
|
1260
|
Chris@381
|
1261 # check/create cross references
|
Chris@381
|
1262 foreach $funname (@{'all'.$name}) {
|
Chris@381
|
1263 next if $funname eq $name;
|
Chris@381
|
1264 $_ = &SubstituteName2Link($_, $funname);
|
Chris@381
|
1265 }
|
Chris@381
|
1266 print HFILE $_;
|
Chris@381
|
1267 }
|
Chris@381
|
1268 print HFILE "</pre>\n$var{'codehr'}\n";
|
Chris@381
|
1269 }
|
Chris@381
|
1270
|
Chris@381
|
1271 # Include info about author from authorfile
|
Chris@381
|
1272 &WriteFile2Handle($var{'authorfile'}, HFILE) ;
|
Chris@381
|
1273
|
Chris@381
|
1274 print HFILE "<!--navigate-->\n";
|
Chris@381
|
1275 print HFILE "<!--copyright-->\n";
|
Chris@381
|
1276 print HFILE "</body>\n</html>\n";
|
Chris@381
|
1277 close(MFILE);
|
Chris@381
|
1278 close(HFILE);
|
Chris@381
|
1279
|
Chris@381
|
1280 # Print name of finished file
|
Chris@381
|
1281 if ($opt_silent) { print "\r"; }
|
Chris@381
|
1282 print " HTML-File created: $hfile{$name}\t";
|
Chris@381
|
1283 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
1284 $filescreated++;
|
Chris@381
|
1285 }
|
Chris@381
|
1286
|
Chris@381
|
1287 print "\n$PROGRAM: $indexcreated index and $filescreated files created.\n";
|
Chris@381
|
1288 }
|
Chris@381
|
1289
|
Chris@381
|
1290 #========================================================================
|
Chris@381
|
1291 # Function: CheckFileName
|
Chris@381
|
1292 # Purpose: .
|
Chris@381
|
1293 #========================================================================
|
Chris@381
|
1294 sub CheckFileName {
|
Chris@381
|
1295 local($filename, $description) = @_;
|
Chris@381
|
1296 local(*CHECKFILE);
|
Chris@381
|
1297
|
Chris@381
|
1298 open(CHECKFILE,"<$filename") || do {
|
Chris@381
|
1299 if ($description eq '') {$description = 'file';}
|
Chris@381
|
1300 # if (!$opt_silent) { print "Cannot open $description $filename: $!\n"; }
|
Chris@381
|
1301 print "Cannot open $description $filename: $!\n";
|
Chris@381
|
1302 return 1;
|
Chris@381
|
1303 };
|
Chris@381
|
1304 close(CHECKFILE);
|
Chris@381
|
1305 return 0;
|
Chris@381
|
1306
|
Chris@381
|
1307 }
|
Chris@381
|
1308
|
Chris@381
|
1309 #========================================================================
|
Chris@381
|
1310 # Function: CheckDirName
|
Chris@381
|
1311 # Purpose: .
|
Chris@381
|
1312 #========================================================================
|
Chris@381
|
1313 sub CheckDirName {
|
Chris@381
|
1314 local($dirname, $description) = @_;
|
Chris@381
|
1315 local(*CHECKDIR);
|
Chris@381
|
1316
|
Chris@381
|
1317 opendir(CHECKDIR,"$dirname") || die ("Cannot open $description directory $dirname: $!\n");
|
Chris@381
|
1318 closedir(CHECKDIR);
|
Chris@381
|
1319 }
|
Chris@381
|
1320
|
Chris@381
|
1321 #========================================================================
|
Chris@381
|
1322 # Function: WriteFile2Handle
|
Chris@381
|
1323 # Purpose: .
|
Chris@381
|
1324 #========================================================================
|
Chris@381
|
1325 sub WriteFile2Handle {
|
Chris@381
|
1326 local($filename, *WRITEFILE) = @_;
|
Chris@381
|
1327 local(*READFILE);
|
Chris@381
|
1328
|
Chris@381
|
1329 if ($filename ne '') {
|
Chris@381
|
1330 open(READFILE,"<$filename");
|
Chris@381
|
1331 @filecontents = <READFILE>;
|
Chris@381
|
1332 close(READFILE);
|
Chris@381
|
1333 print WRITEFILE "@filecontents\n";
|
Chris@381
|
1334 # if (!$opt_silent) {print " Contents of $filename added\n"};
|
Chris@381
|
1335 }
|
Chris@381
|
1336 }
|
Chris@381
|
1337
|
Chris@381
|
1338
|
Chris@381
|
1339 #========================================================================
|
Chris@381
|
1340 # Function: GetConfigFile
|
Chris@381
|
1341 # Purpose: Read user's configuration file, if such exists.
|
Chris@381
|
1342 #========================================================================
|
Chris@381
|
1343 sub GetConfigFile
|
Chris@381
|
1344 {
|
Chris@381
|
1345 local($filename) = @_;
|
Chris@381
|
1346 local(*CONFIG);
|
Chris@381
|
1347 local($value);
|
Chris@381
|
1348
|
Chris@381
|
1349 if (&CheckFileName($filename, 'configuration file')) {
|
Chris@381
|
1350 # if (!$opt_silent) { print " Proceeding using built-in defaults for configuration.\n"; }
|
Chris@381
|
1351 print " Proceeding using built-in defaults for configuration.\n";
|
Chris@381
|
1352 return 0;
|
Chris@381
|
1353 };
|
Chris@381
|
1354
|
Chris@381
|
1355 open(CONFIG,"< $filename");
|
Chris@381
|
1356 while (<CONFIG>) {
|
Chris@381
|
1357 s/#.*$//;
|
Chris@381
|
1358 next if /^\s*$/o;
|
Chris@381
|
1359
|
Chris@381
|
1360 # match keyword: process one or more arguments
|
Chris@381
|
1361 # keyword set
|
Chris@381
|
1362 if (/^\s*set\s+(\S+)\s*=\s*(.*)/) {
|
Chris@381
|
1363 # setting a configuration variable
|
Chris@381
|
1364 if (defined $var{$1}) {
|
Chris@381
|
1365 $var{$1} = $2;
|
Chris@381
|
1366 if ($debug > 3) { print "$1: $var{$1}\n"; }
|
Chris@381
|
1367 }
|
Chris@381
|
1368 else {
|
Chris@381
|
1369 print "$PROGRAM: unknown variable `$1' in configuration file\n"
|
Chris@381
|
1370 }
|
Chris@381
|
1371 } else {
|
Chris@381
|
1372 chop($_);
|
Chris@381
|
1373 print "$PROGRAM: unknown keyword in configuration file in line: `$_'\n"
|
Chris@381
|
1374 }
|
Chris@381
|
1375 }
|
Chris@381
|
1376 close CONFIG;
|
Chris@381
|
1377 1;
|
Chris@381
|
1378 }
|
Chris@381
|
1379
|
Chris@381
|
1380
|
Chris@381
|
1381 #------------------------------------------------------------------------
|
Chris@381
|
1382 # DisplayHelp - display help text using -h or -help command-line switch
|
Chris@381
|
1383 #------------------------------------------------------------------------
|
Chris@381
|
1384 sub DisplayHelp
|
Chris@381
|
1385 {
|
Chris@381
|
1386 $help=<<EofHelp;
|
Chris@381
|
1387 $PROGRAM v$VERSION - generate html documentation from Matlab m-files
|
Chris@381
|
1388
|
Chris@381
|
1389 Usage: $PROGRAM [-h] [-c config_file] [-m|dirmfiles matlab_dir] [-d|dirhtml html_dir]
|
Chris@381
|
1390 [-i yes|no] [-r yes|no] [-p yes|no] [-quiet|q] [-a authorfile]
|
Chris@381
|
1391
|
Chris@381
|
1392 $PROGRAM is a perl script that reads each matlab .m file in a directory
|
Chris@381
|
1393 to produce a corresponding .html file of help documentation and cross
|
Chris@381
|
1394 reference information. An index file is written with links to all of
|
Chris@381
|
1395 the html files produced. The options are:
|
Chris@381
|
1396
|
Chris@381
|
1397 -quiet or -q : be silent, no status information during generation
|
Chris@381
|
1398 -help or -h : display this help message
|
Chris@381
|
1399 -todo or -t : print the todo list for $PROGRAM
|
Chris@381
|
1400 -version or -v : display version
|
Chris@381
|
1401
|
Chris@381
|
1402 -configfile or -c : name of configuration file (default to $var{'configfile'}).
|
Chris@381
|
1403 -dirmfiles or -m : top level directory containing matlab files to generate html for;
|
Chris@381
|
1404 default to actual directory.
|
Chris@381
|
1405 -dirhtml or -d : top level directory for generated html files;
|
Chris@381
|
1406 default to actual directory.
|
Chris@381
|
1407
|
Chris@381
|
1408 -includesource or -i : Include matlab source in the html documentation [yes|no]
|
Chris@381
|
1409 default to yes.
|
Chris@381
|
1410 -processtree or -r : create docu for m-file directory and all subdirectories [yes|no];
|
Chris@381
|
1411 default to yes.
|
Chris@381
|
1412 -producetree or -p : create multi-level docu identical to directory structure
|
Chris@381
|
1413 of m-files [yes|no]; default to yes.
|
Chris@381
|
1414 -writecontentsm or -w: update or write contents.m files into the matlab source
|
Chris@381
|
1415 directories [yes|no]; default to no.
|
Chris@381
|
1416
|
Chris@381
|
1417 -authorfile or -a : name of file including author information, last element in html;
|
Chris@381
|
1418 default to empty.
|
Chris@381
|
1419
|
Chris@381
|
1420 The command line setting overwrite all other settings (built-in and configuration file).
|
Chris@381
|
1421 The configuration file settings overwrite the built-in settings (and not the command
|
Chris@381
|
1422 line settings).
|
Chris@381
|
1423
|
Chris@381
|
1424 Typical usages are:
|
Chris@381
|
1425 $PROGRAM
|
Chris@381
|
1426 (use default parameters from perl script, if configuration
|
Chris@381
|
1427 file is found -> generation of docu, else display of help)
|
Chris@381
|
1428
|
Chris@381
|
1429 $PROGRAM -dirmfiles matlab -dirhtml html
|
Chris@381
|
1430 (generate html documentation for all m-files in directory matlab,
|
Chris@381
|
1431 place html files in directory html, use built-in defaults for
|
Chris@381
|
1432 all other parameters, this way all m-files in the directory
|
Chris@381
|
1433 matlab and below are converted and the generated html-files are
|
Chris@381
|
1434 placed in the directory html and below producing the same
|
Chris@381
|
1435 directory structure than below matlab)
|
Chris@381
|
1436
|
Chris@381
|
1437 $PROGRAM -quiet
|
Chris@381
|
1438 (use built-in parameters from perl script, if configuration
|
Chris@381
|
1439 file is found use these settings as well, do generation,
|
Chris@381
|
1440 no display except critical errors, status of conversion and result)
|
Chris@381
|
1441
|
Chris@381
|
1442 $PROGRAM -m toolbox -dirhtml doc/html -r yes -p no
|
Chris@381
|
1443 (convert all m-files in directory toolbox and below and place
|
Chris@381
|
1444 the generated html files in directory doc/html, read all m-files
|
Chris@381
|
1445 recursively, however, the generated html files are placed in one
|
Chris@381
|
1446 directory)
|
Chris@381
|
1447
|
Chris@381
|
1448 $PROGRAM -m toolbox -dirhtml doc/html -i no -r no
|
Chris@381
|
1449 (convert all m-files in directory toolbox and place
|
Chris@381
|
1450 the generated html files in directory doc/html, do not read m-files
|
Chris@381
|
1451 recursively, do not include source code in documentation)
|
Chris@381
|
1452
|
Chris@381
|
1453 EofHelp
|
Chris@381
|
1454
|
Chris@381
|
1455 die "$help";
|
Chris@381
|
1456 }
|
Chris@381
|
1457
|
Chris@381
|
1458 #------------------------------------------------------------------------
|
Chris@381
|
1459 # DisplayTodo - display ToDo list using -t or -todo command-line switch
|
Chris@381
|
1460 #------------------------------------------------------------------------
|
Chris@381
|
1461 sub DisplayTodo
|
Chris@381
|
1462 {
|
Chris@381
|
1463 $todo=<<EofToDo;
|
Chris@381
|
1464 $PROGRAM v$VERSION - ToDo list
|
Chris@381
|
1465
|
Chris@381
|
1466 o use more than one high level directory
|
Chris@381
|
1467
|
Chris@381
|
1468 o what should/could be done here???
|
Chris@381
|
1469
|
Chris@381
|
1470 EofToDo
|
Chris@381
|
1471
|
Chris@381
|
1472 die "$todo";
|
Chris@381
|
1473 }
|
Chris@381
|
1474
|
Chris@381
|
1475
|
Chris@381
|
1476 #------------------------------------------------------------------------
|
Chris@381
|
1477 # ListVariables - list all defined variables and their values
|
Chris@381
|
1478 #------------------------------------------------------------------------
|
Chris@381
|
1479 sub ListVariables
|
Chris@381
|
1480 {
|
Chris@381
|
1481 local($value);
|
Chris@381
|
1482
|
Chris@381
|
1483 if ($debug > 0) {
|
Chris@381
|
1484 print "List of all variables and their values\n";
|
Chris@381
|
1485 foreach (sort keys %var)
|
Chris@381
|
1486 {
|
Chris@381
|
1487 if ($var{$_} eq '') {
|
Chris@381
|
1488 $value = "empty";
|
Chris@381
|
1489 } else {
|
Chris@381
|
1490 $value = $var{$_};
|
Chris@381
|
1491 }
|
Chris@381
|
1492 print " $_\n $value\n";
|
Chris@381
|
1493 }
|
Chris@381
|
1494 print "\n\n";
|
Chris@381
|
1495 }
|
Chris@381
|
1496 }
|
Chris@381
|
1497
|
Chris@381
|
1498
|
Chris@381
|
1499 __END__
|
Chris@381
|
1500 :endofperl
|