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@382
|
8 #!/usr/bin/perl
|
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@383
|
74 # 29.03.2011 (Chris Cannam) add frames option.
|
Chris@381
|
75
|
Chris@381
|
76 $VERSION = '1.23';
|
Chris@381
|
77 ($PROGRAM = $0) =~ s@.*/@@; $PROGRAM = "\U$PROGRAM\E";
|
chris@389
|
78 $debug = 4;
|
Chris@381
|
79
|
Chris@381
|
80 #------------------------------------------------------------------------
|
Chris@381
|
81 # Define platform specific things
|
Chris@381
|
82 #------------------------------------------------------------------------
|
Chris@381
|
83 # suffix for files to search is defined twice
|
Chris@381
|
84 # the first ($suffix) is for string creation and contains the . as well
|
Chris@381
|
85 # the second ($suffixforsearch) is for regular expression, handling of . is quite special
|
Chris@381
|
86 $suffix = ".m";
|
Chris@381
|
87 $suffixforsearch = "m";
|
Chris@381
|
88 # the directory separator
|
Chris@381
|
89 $dirsep = "/";
|
Chris@381
|
90 # what is the current directory
|
Chris@381
|
91 $diract = ".";
|
Chris@381
|
92
|
Chris@381
|
93 #------------------------------------------------------------------------
|
Chris@382
|
94 # Define all variables and their standard settings
|
Chris@381
|
95 # documentation of variables is contained in accompanying rc file
|
Chris@381
|
96 #------------------------------------------------------------------------
|
Chris@381
|
97 %var =
|
Chris@381
|
98 (
|
Chris@381
|
99 'authorfile', '',
|
Chris@381
|
100 'codebodyfiles', '',
|
Chris@381
|
101 'codebodyindex', '',
|
Chris@381
|
102 'codeheadmeta', '<meta name="author of conversion perl script" content="Hartmut Pohlheim" />',
|
Chris@381
|
103 'codehr', '<hr size="3" noshade="noshade" />',
|
Chris@381
|
104 'codeheader', '',
|
Chris@383
|
105 'configfile', 'matlab-docs.conf',
|
Chris@381
|
106 'csslink', '',
|
Chris@381
|
107 'dirmfiles', $diract,
|
Chris@381
|
108 'dirhtml', $diract,
|
Chris@381
|
109 'exthtml', '.html',
|
Chris@382
|
110 'frames', 'yes',
|
Chris@381
|
111 'filenametopframe', 'index',
|
Chris@381
|
112 'filenameindexlongglobal', 'indexlg',
|
Chris@381
|
113 'filenameindexlonglocal', 'indexll',
|
Chris@381
|
114 'filenameindexshortglobal', 'indexsg',
|
Chris@381
|
115 'filenameindexshortlocal', 'indexsl',
|
Chris@381
|
116 'filenameextensionframe', 'f',
|
Chris@381
|
117 'filenameextensionindex', 'i',
|
Chris@381
|
118 'filenameextensionjump', 'j',
|
Chris@381
|
119 'filenamedirshort', 'dirtops',
|
Chris@381
|
120 'filenamedirlong', 'dirtopl',
|
Chris@381
|
121 'filenamedircontents', 'dirtopc',
|
Chris@381
|
122 'includesource', 'yes',
|
Chris@381
|
123 'links2filescase', 'all',
|
Chris@381
|
124 'processtree', 'yes',
|
Chris@381
|
125 'producetree', 'yes',
|
Chris@381
|
126 'textjumpindexlocal', 'Local Index',
|
Chris@381
|
127 'textjumpindexglobal', 'Global Index',
|
Chris@381
|
128 'texttitleframelayout', 'Documentation of Matlab Files',
|
Chris@381
|
129 'texttitleindexalldirs', 'Index of Directories',
|
Chris@381
|
130 'textheaderindexalldirs', 'Index of Directories',
|
Chris@381
|
131 'texttitleindex', '',
|
Chris@381
|
132 'textheaderindex', '',
|
Chris@381
|
133 'texttitlefiles', 'Documentation of ',
|
Chris@381
|
134 'textheaderfiles', 'Documentation of ',
|
Chris@381
|
135 'usecontentsm', 'yes',
|
Chris@381
|
136 'writecontentsm', 'no'
|
Chris@381
|
137 );
|
Chris@381
|
138
|
Chris@381
|
139
|
Chris@381
|
140 # define all m-file names, that should be excluded from linking
|
Chris@381
|
141 # however, files will still be converted
|
Chris@381
|
142 @excludenames = ( 'all','ans','any','are',
|
Chris@381
|
143 'cs',
|
Chris@381
|
144 'demo','dos',
|
Chris@381
|
145 'echo','edit','else','elseif','end','exist',
|
Chris@381
|
146 'flag','for','function',
|
Chris@381
|
147 'global',
|
Chris@381
|
148 'help',
|
Chris@381
|
149 'i','if','inf','info',
|
Chris@381
|
150 'j',
|
Chris@381
|
151 'more',
|
Chris@381
|
152 'null',
|
Chris@381
|
153 'return',
|
Chris@381
|
154 'script','strings',
|
Chris@381
|
155 'what','which','while','who','whos','why',
|
Chris@381
|
156 );
|
Chris@381
|
157
|
Chris@381
|
158 # Text for inclusion in created HTML/Frame files: Doctype and Charset
|
Chris@381
|
159 $TextDocTypeHTML = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">';
|
Chris@381
|
160 $TextDocTypeFrame = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">';
|
Chris@381
|
161 $TextMetaCharset = '<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />';
|
Chris@381
|
162
|
Chris@381
|
163 #------------------------------------------------------------------------
|
Chris@381
|
164 # Read the command line arguments
|
Chris@381
|
165 #------------------------------------------------------------------------
|
Chris@381
|
166 if (@ARGV == 0) {
|
Chris@381
|
167 &DisplayHelp() if &CheckFileName($var{'configfile'}, 'configuration file');
|
Chris@381
|
168 }
|
Chris@381
|
169
|
Chris@381
|
170 # Print provided command line arguments on screen
|
Chris@381
|
171 foreach (@ARGV) { print " $_\n "; }
|
Chris@381
|
172
|
Chris@381
|
173 # Get the options
|
Chris@381
|
174 use Getopt::Long;
|
Chris@381
|
175 @options = ('help|h', 'todo|t', 'version|v',
|
Chris@381
|
176 'authorfile|a=s', 'configfile|c=s', 'dirhtml|html|d=s',
|
Chris@381
|
177 'dirmfiles|mfiles|m=s', 'includesource|i=s',
|
Chris@381
|
178 'processtree|r=s', 'producetree|p=s',
|
Chris@381
|
179 'silent|quiet|q', 'writecontentsm|w=s');
|
Chris@381
|
180 &GetOptions(@options) || die "use -h switch to display help statement\n";
|
Chris@381
|
181
|
Chris@381
|
182
|
Chris@381
|
183 # Display help or todo list, when requested
|
Chris@381
|
184 &DisplayHelp() if $opt_help;
|
Chris@381
|
185 &DisplayTodo() if $opt_todo;
|
Chris@381
|
186 die "$PROGRAM v$VERSION\n" if $opt_version;
|
Chris@381
|
187
|
Chris@381
|
188 $exit_status = 0;
|
Chris@381
|
189
|
Chris@381
|
190 #------------------------------------------------------------------------
|
Chris@381
|
191 # Read the config file
|
Chris@381
|
192 #------------------------------------------------------------------------
|
Chris@381
|
193 $var{'configfile'} = $opt_configfile if $opt_configfile;
|
Chris@381
|
194 &GetConfigFile($var{'configfile'});
|
Chris@381
|
195
|
Chris@381
|
196
|
Chris@381
|
197 #------------------------------------------------------------------------
|
Chris@381
|
198 # Process/Check the command line otions
|
Chris@381
|
199 #------------------------------------------------------------------------
|
Chris@381
|
200 $var{'dirhtml'} = $opt_dirhtml if $opt_dirhtml;
|
Chris@381
|
201 if (!(substr($var{'dirhtml'}, -1, 1) eq $dirsep)) { $var{'dirhtml'} = $var{'dirhtml'}.$dirsep; }
|
Chris@381
|
202 $var{'dirmfiles'} = $opt_dirmfiles if $opt_dirmfiles;
|
Chris@381
|
203 if (!(substr($var{'dirmfiles'}, -1, 1) eq $dirsep)) { $var{'dirmfiles'} = $var{'dirmfiles'}.$dirsep; }
|
Chris@381
|
204
|
Chris@381
|
205 $var{'authorfile'} = $opt_author if $opt_author;
|
Chris@381
|
206 $var{'includesource'} = $opt_includesource if $opt_includesource;
|
Chris@381
|
207 if ($var{'includesource'} ne 'no') { $var{'includesource'} = 'yes'; }
|
Chris@381
|
208 $var{'processtree'} = $opt_processtree if $opt_processtree;
|
Chris@381
|
209 if ($var{'processtree'} ne 'no') { $var{'processtree'} = 'yes'; }
|
Chris@381
|
210 $var{'producetree'} = $opt_producetree if $opt_producetree;
|
Chris@381
|
211 if ($var{'producetree'} ne 'no') { $var{'producetree'} = 'yes'; }
|
Chris@381
|
212 if ($var{'processtree'} eq 'no') { $var{'producetree'} = 'no'; }
|
Chris@382
|
213 if ($var{'frames'} ne 'no') { $var{'frames'} = 'yes'; }
|
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@388
|
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@382
|
645 if ($var{'frames'} eq 'yes') {
|
Chris@381
|
646
|
Chris@382
|
647 open(IFILE,">$indexfile") || die("Cannot open frame layout file $indexfile\n");
|
Chris@381
|
648
|
Chris@382
|
649 # Write the header of frame file
|
Chris@382
|
650 print IFILE "$TextDocTypeFrame\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n";
|
Chris@382
|
651 print IFILE " <title>$var{'texttitleframelayout'}</title>\n";
|
Chris@382
|
652 print IFILE "</head>\n";
|
Chris@381
|
653
|
Chris@382
|
654 # definition of 2 frames, left the tree of directories,
|
Chris@382
|
655 # right the index of that directory or the docu of a file
|
Chris@382
|
656 print IFILE "<frameset cols=\"25%,75%\">\n";
|
Chris@382
|
657 print IFILE " <frame src=\"$var{'filenamedirshort'}$var{'exthtml'}\" name=\"$GlobalNameFrameMainLeft\" />\n";
|
Chris@382
|
658 print IFILE " <frame src=\"$var{'filenameindexshortglobal'}$var{'filenameextensionframe'}$var{'exthtml'}\" name=\"$GlobalNameFrameMainRight\" />\n"; print IFILE "</frameset>\n";
|
Chris@381
|
659
|
Chris@382
|
660 print IFILE "</html>\n";
|
Chris@382
|
661
|
Chris@382
|
662 close(IFILE);
|
Chris@382
|
663
|
Chris@382
|
664 if ($opt_silent) { print "\r"; }
|
Chris@382
|
665 print " Frame layout file created: $indexfile\t";
|
Chris@382
|
666 if (!$opt_silent) { print "\n"; }
|
Chris@382
|
667 }
|
Chris@381
|
668
|
Chris@381
|
669 for($irun=0; $irun <= 2; $irun++) {
|
Chris@381
|
670 # Build the top directory index file, these files include the directory tree
|
Chris@381
|
671 # Build the directory tree index file name
|
Chris@381
|
672
|
Chris@381
|
673 # Create no directory file for contents, when no contents to use
|
Chris@381
|
674 if (($irun == 2) && ($var{'usecontentsm'} eq 'no')) { next; }
|
Chris@381
|
675
|
Chris@381
|
676 # Assign the correct index file name
|
Chris@381
|
677 if ($irun == 0) { $filename = $var{'filenamedirshort'}; }
|
Chris@381
|
678 elsif ($irun == 1) { $filename = $var{'filenamedirlong'}; }
|
Chris@381
|
679 elsif ($irun == 2) { $filename = $var{'filenamedircontents'}; }
|
Chris@381
|
680
|
Chris@381
|
681 $indexfile = $var{'dirhtml'}.$filename.$var{'exthtml'};
|
Chris@381
|
682
|
Chris@381
|
683 open(IFILE,">$indexfile") || die("Cannot open directory tree index file $indexfile\n");
|
Chris@381
|
684 # Write header of HTML file
|
Chris@381
|
685 print IFILE "$TextDocTypeHTML\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n$var{'csslink'}\n";
|
Chris@381
|
686
|
Chris@381
|
687 if ($var{'texttitleindexalldirs'} eq '') {
|
Chris@381
|
688 print IFILE "<title>Index of Directories of $var{'dirmfiles'}</title>\n";
|
Chris@381
|
689 } else {
|
Chris@381
|
690 print IFILE "<title>$var{'texttitleindexalldirs'}</title>\n";
|
Chris@381
|
691 }
|
Chris@382
|
692
|
Chris@382
|
693 if ($var{'frames'} eq 'yes') {
|
Chris@382
|
694 print IFILE "<base target=\"$GlobalNameFrameMainRight\" />\n";
|
Chris@382
|
695 }
|
Chris@382
|
696
|
Chris@381
|
697 print IFILE "</head>\n";
|
Chris@381
|
698 print IFILE "<body $var{'codebodyindex'}>\n";
|
Chris@381
|
699 if ($var{'textheaderindexalldirs'} eq '') {
|
Chris@381
|
700 print IFILE "<h1 $var{'codeheader'}>Index of Directories of <em>$var{'dirmfiles'}</em></h1>\n";
|
Chris@381
|
701 } else {
|
Chris@381
|
702 print IFILE "<h1 $var{'codeheader'}>$var{'textheaderindexalldirs'}</h1>\n";
|
Chris@381
|
703 }
|
chris@389
|
704 print IFILE "<p>\n";
|
Chris@382
|
705
|
Chris@382
|
706 if ($var{'frames'} eq 'yes') {
|
Chris@382
|
707 if ($irun == 0) { print IFILE "<strong>short</strong>\n"; }
|
Chris@382
|
708 else { print IFILE "<a href=\"$var{'filenamedirshort'}$var{'exthtml'}\" target=\"$GlobalNameFrameMainLeft\">short</a>\n"; }
|
Chris@382
|
709 if ($irun == 1) { print IFILE " | <strong>long</strong>\n"; }
|
Chris@382
|
710 else { print IFILE " | <a href=\"$var{'filenamedirlong'}$var{'exthtml'}\" target=\"$GlobalNameFrameMainLeft\">long</a>\n"; }
|
Chris@382
|
711 if ($var{'usecontentsm'} eq 'yes') {
|
Chris@382
|
712 if ($irun == 2) { print IFILE " | <strong>contents</strong>\n"; }
|
Chris@382
|
713 else { print IFILE " | <a href=\"$var{'filenamedircontents'}$var{'exthtml'}\" target=\"$GlobalNameFrameMainLeft\">contents</a>\n"; }
|
Chris@382
|
714 }
|
Chris@382
|
715 } else {
|
Chris@382
|
716 if ($irun == 0) { print IFILE "<strong>short</strong>\n"; }
|
Chris@382
|
717 else { print IFILE "<a href=\"$var{'filenamedirshort'}$var{'exthtml'}\">short</a>\n"; }
|
Chris@382
|
718 if ($irun == 1) { print IFILE " | <strong>long</strong>\n"; }
|
Chris@382
|
719 else { print IFILE " | <a href=\"$var{'filenamedirlong'}$var{'exthtml'}\">long</a>\n"; }
|
Chris@382
|
720 if ($var{'usecontentsm'} eq 'yes') {
|
Chris@382
|
721 if ($irun == 2) { print IFILE " | <strong>contents</strong>\n"; }
|
Chris@382
|
722 else { print IFILE " | <a href=\"$var{'filenamedircontents'}$var{'exthtml'}\">contents</a>\n"; }
|
Chris@382
|
723 }
|
Chris@381
|
724 }
|
Chris@381
|
725
|
Chris@381
|
726 print IFILE "</p><br />\n\n";
|
Chris@381
|
727 print IFILE "<ul>\n";
|
Chris@381
|
728
|
Chris@381
|
729 # go through all directories and create a list entry for each one,
|
Chris@381
|
730 # depending on recursion level create sublists
|
Chris@381
|
731 $prevrecdeeplevel = 0;
|
Chris@381
|
732 foreach $name (@alldirectories) {
|
Chris@381
|
733 $actrecdeeplevel = $dirnamerecdeep{$name};
|
Chris@381
|
734 for( ; $prevrecdeeplevel < $actrecdeeplevel; $prevrecdeeplevel++ ) { print IFILE "<ul>\n"; }
|
Chris@381
|
735 for( ; $prevrecdeeplevel > $actrecdeeplevel; $prevrecdeeplevel-- ) { print IFILE "</ul>\n"; }
|
Chris@381
|
736 if ($irun == 0) { $indexfilenameused = $var{'filenameindexshortlocal'}.$var{'filenameextensionframe'}; }
|
Chris@381
|
737 elsif ($irun == 1) { $indexfilenameused = $var{'filenameindexlonglocal'}.$var{'filenameextensionframe'}; }
|
Chris@381
|
738 elsif ($irun == 2) { $indexfilenameused = $contentsname{$name}; }
|
Chris@381
|
739 else { die "ConstructHighestIndexFile: Unknown value of irun"; }
|
Chris@381
|
740 if ($dirnumbermfiles{$name} > 0) {
|
Chris@381
|
741 # producetree no
|
Chris@381
|
742 # if ($var{'producetree'} eq 'no') { $dirnamehere = ''; }
|
Chris@381
|
743 # else { $dirnamehere = '$dirnamerelpath{$name}'; }
|
Chris@381
|
744 # print IFILE "<LI><A HREF=\"$dirnamehere$indexfilenameused_$dirnamesingle{$name}$var{'exthtml'}\">$dirnamesingle{$name}</A>\n";
|
Chris@381
|
745 print IFILE "<li><a href=\"$dirnamerelpath{$name}$indexfilenameused$dirnamesingle{$name}$var{'exthtml'}\">$dirnamesingle{$name}</a></li>\n";
|
Chris@381
|
746 } else {
|
Chris@381
|
747 # print directories with no m-files inside not
|
Chris@381
|
748 # print IFILE "<li>$dirnamesingle{$name}</li>\n";
|
Chris@381
|
749 }
|
Chris@381
|
750 }
|
Chris@381
|
751 $actrecdeeplevel = 0;
|
Chris@381
|
752 for( ; $prevrecdeeplevel > $actrecdeeplevel; $prevrecdeeplevel-- ) { print IFILE "</ul>\n"; }
|
Chris@381
|
753 print IFILE "</ul>\n<br />$var{'codehr'}\n";
|
Chris@381
|
754
|
Chris@381
|
755 # Include info about author from authorfile
|
Chris@381
|
756 &WriteFile2Handle($var{'authorfile'}, IFILE);
|
Chris@381
|
757
|
Chris@381
|
758 print IFILE "<!--navigate-->\n";
|
Chris@381
|
759 print IFILE "<!--copyright-->\n";
|
Chris@381
|
760 print IFILE "</body>\n</html>\n";
|
Chris@381
|
761
|
Chris@381
|
762 close(IFILE);
|
Chris@381
|
763
|
Chris@381
|
764 if ($opt_silent) { print "\r"; }
|
Chris@381
|
765 print " Directory - Indexfile created: $indexfile\t";
|
Chris@381
|
766 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
767 }
|
Chris@381
|
768 }
|
Chris@381
|
769
|
Chris@381
|
770
|
Chris@381
|
771 #========================================================================
|
Chris@381
|
772 # Construct the A-Z index file (global/local and/or short/long)
|
Chris@381
|
773 #========================================================================
|
Chris@381
|
774 sub ConstructAZIndexFile
|
Chris@381
|
775 {
|
Chris@381
|
776 local($LocalActDir, $LocalShortLong, $LocalGlobalLocal, @localnames) = @_;
|
Chris@381
|
777 local(*IFILE);
|
Chris@381
|
778 local($name, $indexfilename, $dirpath);
|
Chris@381
|
779 local($firstletter, $firstone);
|
Chris@381
|
780
|
Chris@381
|
781 if ($debug > 2) { print "localnames in AZ small: @localnames\n"; print " ActDir in A-Z: $LocalActDir\n"; }
|
Chris@381
|
782
|
Chris@381
|
783 # extract filename of index file from parameters of function
|
Chris@381
|
784 if ($LocalShortLong eq 'short') {
|
Chris@381
|
785 if ($LocalGlobalLocal eq 'global') { $indexfilename = $var{'filenameindexshortglobal'}; }
|
Chris@381
|
786 elsif ($LocalGlobalLocal eq 'local') { $indexfilename = $var{'filenameindexshortlocal'}; }
|
Chris@381
|
787 else { die "wrong parameter for LocalGlobalLocal in ConstructAZIndexFile: $LocalGlobalLocal."; }
|
Chris@381
|
788 } elsif ($LocalShortLong eq 'long') {
|
Chris@381
|
789 if ($LocalGlobalLocal eq 'global') { $indexfilename = $var{'filenameindexlongglobal'}; }
|
Chris@381
|
790 elsif ($LocalGlobalLocal eq 'local') { $indexfilename = $var{'filenameindexlonglocal'}; }
|
Chris@381
|
791 else { die "wrong parameter for LocalGlobalLocal in ConstructAZIndexFile: $LocalGlobalLocal."; }
|
Chris@381
|
792 } else { die "wrong parameter for LocalShortLong in ConstructAZIndexFile: $LocalShortLong."; }
|
Chris@381
|
793
|
Chris@381
|
794 # producetree no
|
Chris@381
|
795 # if ($var{'producetree'} eq 'no') { $dirnamehere = ''; }
|
Chris@381
|
796 # else { $dirnamehere = '$dirnamerelpath{$LocalActDir}'; }
|
Chris@381
|
797 # Build the index file name
|
Chris@381
|
798 # handle the global index file case separately (no extra directory name in file)
|
Chris@381
|
799 # the local index file name must be extended by the name of the directory
|
Chris@381
|
800 if ($LocalGlobalLocal eq 'global') { $extradirfilename = ''; }
|
Chris@381
|
801 else { $extradirfilename = $dirnamesingle{$LocalActDir}; }
|
Chris@381
|
802 $indexfile = $var{'dirhtml'}.$dirnamerelpath{$LocalActDir}.$indexfilename.$var{'filenameextensionindex'}.$extradirfilename.$var{'exthtml'};
|
Chris@382
|
803
|
chris@401
|
804 if ($LocalShortLong eq 'short' and $extradirfilename eq '' and $var{'frames'} ne 'yes') {
|
chris@401
|
805 # With no frames and no subdir path, this must go in the
|
chris@401
|
806 # top-level index file instead
|
Chris@382
|
807 $indexfile = $var{'dirhtml'}.$var{'filenametopframe'}.$var{'exthtml'};
|
Chris@382
|
808 }
|
Chris@382
|
809
|
Chris@381
|
810 if ($debug > 2) { print " indexfilename (a-z small): $indexfile\n"; }
|
Chris@381
|
811
|
Chris@381
|
812 open(IFILE,">$indexfile") || die("Cannot open index file $indexfile: $!\n");
|
Chris@381
|
813
|
Chris@381
|
814 # Write the header of HTML file
|
Chris@381
|
815 print IFILE "$TextDocTypeHTML\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n$var{'csslink'}\n";
|
Chris@381
|
816
|
Chris@381
|
817 if ($var{'texttitleindex'} eq '') {
|
Chris@381
|
818 print IFILE "<title>Index of Matlab Files in Directory $LocalActDir</title>\n";
|
Chris@381
|
819 } else {
|
Chris@381
|
820 if ($LocalGlobalLocal eq 'global') { print IFILE "<title>$var{'texttitleindex'}</title>\n"; }
|
Chris@381
|
821 else { print IFILE "<title>$var{'texttitleindex'} in Directory $LocalActDir</title>\n"; }
|
Chris@381
|
822 }
|
Chris@382
|
823
|
Chris@382
|
824 if ($var{'frames'} eq 'yes') {
|
Chris@382
|
825 print IFILE "<base target=\"$GlobalNameFrameMainRight\" />\n";
|
Chris@382
|
826 }
|
Chris@381
|
827 print IFILE "</head>\n";
|
Chris@382
|
828
|
Chris@381
|
829 print IFILE "<body $var{'codebodyindex'}>\n";
|
Chris@381
|
830 if ($var{'textheaderindex'} eq '') {
|
Chris@381
|
831 print IFILE "<h1 $var{'codeheader'}>Index of Matlab Files in Directory $LocalActDir</h1>\n";
|
Chris@381
|
832 } else {
|
Chris@381
|
833 if ($LocalGlobalLocal eq 'global') { print IFILE "<h1 $var{'codeheader'}>$var{'textheaderindex'}</h1>\n"; }
|
Chris@381
|
834 else { print IFILE "<h1 $var{'codeheader'}>$var{'textheaderindex'} in Directory $LocalActDir</h1>\n"; }
|
Chris@381
|
835 }
|
Chris@381
|
836
|
Chris@381
|
837 # include links to indexes
|
Chris@381
|
838 &ConstructLinks2Index(IFILE, $dirnamerelpathtoindex{$LocalActDir}, $LocalActDir, $LocalGlobalLocal);
|
Chris@381
|
839
|
Chris@381
|
840 # Collect the starting letters of m files in this directory or all m-files
|
Chris@381
|
841 for('a'..'z') { undef @{$_}; }
|
Chris@381
|
842 foreach $name (@localnames) {
|
Chris@381
|
843 if (! ($mfilename{$name} =~ /contents/i)) {
|
Chris@381
|
844 $firstletter = substr($mfilename{$name}, 0, 1);
|
Chris@381
|
845 # convert first letter always to lower case
|
Chris@381
|
846 # needed for reference to lower and upper case m-files
|
Chris@381
|
847 $firstletter = "\L$firstletter\E";
|
Chris@381
|
848 push(@{$firstletter}, $name);
|
Chris@381
|
849 }
|
Chris@381
|
850 }
|
Chris@381
|
851
|
Chris@381
|
852 if ($LocalShortLong eq 'short') {
|
Chris@381
|
853 # begin create short index
|
Chris@381
|
854 print IFILE "<table width=\"100%\">\n";
|
Chris@381
|
855
|
Chris@381
|
856 for('a'..'z') {
|
Chris@381
|
857 # print " $_: @{$_}\n";
|
Chris@381
|
858 $numberofletter = $#{$_}+1;
|
Chris@381
|
859 if ($numberofletter > 0) {
|
chris@400
|
860 print IFILE "\n<tr><td colspan=\"2\"><br /><strong><a name=\"\U$_\E$_\"></a><span class=\"an\">\U$_\E</span></strong></td></tr>\n";
|
Chris@381
|
861 $numberhalf = ($numberofletter + 1 - (($numberofletter+1) % 2))/2;
|
Chris@381
|
862 if ($debug > 2) { print " $_: @{$_} \t $numberhalf \t $numberofletter\n"; }
|
Chris@381
|
863 for($count = 0; $count < $numberhalf; $count++) {
|
Chris@381
|
864 $name = @{$_}[$count];
|
Chris@381
|
865 if ($LocalGlobalLocal eq 'global') { $dirpath = $hfilerelpath{$name}; } else { $dirpath = ""; }
|
Chris@381
|
866 print IFILE "<tr><td width=\"50%\"><a href=\"$dirpath$mfilename{$name}$var{'exthtml'}\">$mfilename{$name}</a></td>";
|
Chris@381
|
867 if (($count + $numberhalf) < $numberofletter) {
|
Chris@381
|
868 $name = @{$_}[$count + $numberhalf];
|
Chris@381
|
869 if ($LocalGlobalLocal eq 'global') { $dirpath = $hfilerelpath{$name}; } else { $dirpath = ""; }
|
Chris@381
|
870 print IFILE "<td width=\"50%\"><a href=\"$dirpath$mfilename{$name}$var{'exthtml'}\">$mfilename{$name}</a></td></tr>\n";
|
Chris@381
|
871 } else {
|
Chris@381
|
872 print IFILE "<td width=\"50%\"></td></tr>\n";
|
Chris@381
|
873 }
|
Chris@381
|
874 }
|
Chris@381
|
875 }
|
Chris@381
|
876 }
|
Chris@381
|
877 print IFILE "</table>\n<br />$var{'codehr'}\n";
|
Chris@381
|
878
|
Chris@381
|
879 } elsif ($LocalShortLong eq 'long') {
|
Chris@381
|
880 # begin create long index
|
Chris@381
|
881 print IFILE "<table border=\"5\" width=\"100%\" cellpadding=\"5\">\n";
|
chris@401
|
882 print IFILE "<tr><th>Name</th><th>Synopsis</th></tr>\n";
|
Chris@381
|
883
|
Chris@381
|
884 for('a'..'z') {
|
Chris@381
|
885 # print " $_: @{$_}\n";
|
Chris@381
|
886 $numberofletter = $#{$_}+1;
|
Chris@381
|
887 if ($numberofletter > 0) {
|
Chris@381
|
888 $firstone = 1;
|
Chris@381
|
889 foreach $name (@{$_}) {
|
Chris@381
|
890 if ($debug > 1) { print " AZinforeach1: $name \t\t $hfilerelpath{$name} \t\t $dirnamerelpath{$LocalActDir}\n"; }
|
Chris@381
|
891 if ($LocalGlobalLocal eq 'global') { $dirpath = $hfilerelpath{$name}; } else { $dirpath = ""; }
|
Chris@381
|
892 if (! ($mfilename{$name} =~ /contents/i)) {
|
chris@400
|
893 if ($firstone == 1) { print IFILE "\n<tr><td colspan=\"2\"><br /><strong><a name=\"\U$_\E$_\"></a><span class=\"an\">\U$_\E</span></strong></td></tr>\n"; $firstone = 0; }
|
Chris@381
|
894 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
|
895 }
|
Chris@381
|
896 }
|
Chris@381
|
897 }
|
Chris@381
|
898 }
|
Chris@381
|
899 print IFILE "</table>\n<br />$var{'codehr'}\n";
|
Chris@381
|
900 } else { die "wrong parameter for LocalShortLong in ConstructAZIndexFile: $LocalShortLong."; }
|
Chris@381
|
901
|
Chris@381
|
902 # Include info about author from authorfile
|
Chris@381
|
903 &WriteFile2Handle($var{'authorfile'}, IFILE);
|
Chris@381
|
904
|
Chris@381
|
905 print IFILE "<!--navigate-->\n";
|
Chris@381
|
906 print IFILE "<!--copyright-->\n";
|
Chris@381
|
907 print IFILE "</body>\n</html>\n";
|
Chris@381
|
908
|
Chris@381
|
909 close(IFILE);
|
Chris@381
|
910
|
Chris@381
|
911 if ($opt_silent) { print "\r"; }
|
Chris@381
|
912 print " Indexfile small (A-Z) created: $indexfile\t";
|
Chris@381
|
913 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
914
|
Chris@381
|
915
|
Chris@381
|
916 # Build the A-Z jump index file name
|
Chris@381
|
917 # handle the global index file case separately (no extra directory name in file)
|
Chris@381
|
918 if ($LocalGlobalLocal eq 'global') { $extradirfilename = ''; }
|
Chris@381
|
919 else { $extradirfilename = $dirnamesingle{$LocalActDir}; }
|
Chris@381
|
920
|
Chris@382
|
921 if ($var{'frames'} eq 'yes') {
|
Chris@382
|
922
|
Chris@382
|
923 $indexfile = $var{'dirhtml'}.$dirnamerelpath{$LocalActDir}.$indexfilename.$var{'filenameextensionjump'}.$extradirfilename.$var{'exthtml'};
|
Chris@382
|
924 if ($debug > 2) { print " indexfilename (a-z jump): $indexfile\n"; }
|
Chris@382
|
925 open(IFILE,">$indexfile") || die("Cannot open jump index file $indexfile: $!\n");
|
Chris@382
|
926
|
Chris@382
|
927 # Write the header of HTML file
|
Chris@382
|
928 print IFILE "$TextDocTypeHTML\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n$var{'csslink'}\n";
|
Chris@382
|
929
|
Chris@382
|
930 if ($var{'texttitleindex'} eq '') {
|
Chris@382
|
931 print IFILE "<title>A-Z jump index in directory $LocalActDir</title>\n";
|
Chris@382
|
932 } else {
|
Chris@382
|
933 if ($LocalGlobalLocal eq 'global') { print IFILE "<title>$var{'texttitleindex'}</title>\n"; }
|
Chris@382
|
934 else { print IFILE "<title>$var{'texttitleindex'} in Directory $LocalActDir</title>\n"; }
|
Chris@382
|
935 }
|
Chris@382
|
936
|
Chris@382
|
937 if ($var{'frames'} eq 'yes') {
|
Chris@382
|
938 print IFILE "<base target=\"$GlobalNameFrameAZIndexsmall\" />\n";
|
Chris@382
|
939 }
|
Chris@382
|
940 print IFILE "</head>\n";
|
Chris@382
|
941 print IFILE "<body $var{'codebodyindex'}>\n";
|
Chris@382
|
942
|
Chris@382
|
943 # Write the A-Z jump line, generate link for letters with files starting with this letter
|
Chris@382
|
944 # and only letters for no files starting with this letter
|
Chris@382
|
945 # use previously generated arrays with names of files sorted by starting letter
|
Chris@382
|
946 for('a'..'z') {
|
Chris@382
|
947 $numberofletter = $#{$_}+1;
|
Chris@382
|
948 if ($numberofletter > 0) {
|
Chris@382
|
949 print IFILE "<strong><a href=\"$indexfilename$var{'filenameextensionindex'}$extradirfilename$var{'exthtml'}#\U$_\E$_\">\U$_\E</a> </strong>\n";
|
Chris@382
|
950 } else {
|
Chris@382
|
951 print IFILE "\U$_\E \n";
|
Chris@382
|
952 }
|
Chris@382
|
953 }
|
Chris@382
|
954
|
Chris@382
|
955 print IFILE "</body>\n</html>\n";
|
Chris@382
|
956
|
Chris@382
|
957 close(IFILE);
|
Chris@382
|
958
|
Chris@382
|
959 if ($opt_silent) { print "\r"; }
|
Chris@382
|
960 print " Indexfile small (A-Z jump) created: $indexfile\t";
|
Chris@382
|
961 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
962 }
|
Chris@381
|
963
|
Chris@381
|
964
|
Chris@381
|
965 # Build the frame layout file, this file includes the layout of the frames
|
Chris@381
|
966 # Build the frame layout file name (for small/compact A-Z index)
|
Chris@381
|
967 # handle the global index file case separately (no extra directory name in file)
|
Chris@381
|
968 if ($LocalGlobalLocal eq 'global') { $extradirfilename = ''; }
|
Chris@381
|
969 else { $extradirfilename = $dirnamesingle{$LocalActDir}; }
|
Chris@381
|
970
|
Chris@382
|
971 if ($var{'frames'} eq 'yes') {
|
Chris@381
|
972
|
Chris@382
|
973 $indexfile = $var{'dirhtml'}.$dirnamerelpath{$LocalActDir}.$indexfilename.$var{'filenameextensionframe'}.$extradirfilename.$var{'exthtml'};
|
Chris@382
|
974 if ($debug > 2) { print " indexfilename (a-z frame): $indexfile\n"; }
|
Chris@381
|
975
|
Chris@382
|
976 open(IFILE,">$indexfile") || die("Cannot open jump index frame file $indexfile: $!\n");
|
Chris@382
|
977
|
Chris@382
|
978 # Write the header of Frame file
|
Chris@382
|
979 print IFILE "$TextDocTypeHTML\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n$var{'csslink'}\n";
|
Chris@382
|
980
|
Chris@382
|
981 if ($var{'texttitleindex'} eq '') {
|
Chris@382
|
982 print IFILE "<title>Index of Matlab Files in Directory $LocalActDir</title>\n";
|
Chris@382
|
983 } else {
|
Chris@382
|
984 if ($LocalGlobalLocal eq 'global') { print IFILE "<title>$var{'texttitleindex'}</title>\n"; }
|
Chris@382
|
985 else { print IFILE "<title>$var{'texttitleindex'} in Directory $LocalActDir</title>\n"; }
|
Chris@382
|
986 }
|
Chris@382
|
987 print IFILE "</head>\n";
|
Chris@382
|
988
|
Chris@382
|
989 # definition of 2 frames, top the A-Z index, below the jump letter line
|
Chris@382
|
990 print IFILE "<frameset rows=\"90%,10%\">\n";
|
Chris@382
|
991 print IFILE " <frame src=\"$indexfilename$var{'filenameextensionindex'}$extradirfilename$var{'exthtml'}\" name=\"$GlobalNameFrameAZIndexsmall\" />\n";
|
Chris@382
|
992 print IFILE " <frame src=\"$indexfilename$var{'filenameextensionjump'}$extradirfilename$var{'exthtml'}\" name=\"$GlobalNameFrameAZIndexjump\" />\n";
|
Chris@382
|
993 print IFILE "</frameset>\n";
|
Chris@382
|
994
|
Chris@382
|
995 print IFILE "</html>\n";
|
Chris@382
|
996
|
Chris@382
|
997 close(IFILE);
|
Chris@382
|
998
|
Chris@382
|
999 if ($opt_silent) { print "\r"; }
|
Chris@382
|
1000 print " Frame layout file created: $indexfile\t";
|
Chris@382
|
1001 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
1002 }
|
Chris@381
|
1003 }
|
Chris@382
|
1004
|
Chris@381
|
1005
|
Chris@381
|
1006 #========================================================================
|
Chris@381
|
1007 # Construct the links to all indexes
|
Chris@381
|
1008 #========================================================================
|
Chris@381
|
1009 sub ConstructLinks2Index
|
Chris@381
|
1010 {
|
Chris@381
|
1011 local(*WRITEFILE, $LocalPath2Index, $PathContents, $LocalGlobalLocal) = @_;
|
Chris@381
|
1012
|
Chris@381
|
1013 # include links to short/long - local/global index and C|contents.m
|
chris@389
|
1014 print WRITEFILE "\n<p>";
|
chris@389
|
1015 print WRITEFILE "$var{'textjumpindexglobal'} ";
|
Chris@382
|
1016
|
Chris@382
|
1017 if ($var{'frames'} eq 'yes') {
|
Chris@382
|
1018 print WRITEFILE "<a href=\"$LocalPath2Index$var{'filenameindexshortglobal'}$var{'filenameextensionframe'}$var{'exthtml'}\">short</a> | ";
|
chris@389
|
1019 print WRITEFILE "<a href=\"$LocalPath2Index$var{'filenameindexlongglobal'}$var{'filenameextensionframe'}$var{'exthtml'}\">long</a>\n";
|
Chris@382
|
1020 } else {
|
Chris@387
|
1021 print WRITEFILE "<a href=\"$LocalPath2Index$var{'filenametopframe'}$var{'exthtml'}\">short</a> | ";
|
chris@389
|
1022 print WRITEFILE "<a href=\"$LocalPath2Index$var{'filenameindexlongglobal'}$var{'filenameextensionindex'}$var{'exthtml'}\">long</a>\n";
|
Chris@382
|
1023 }
|
Chris@382
|
1024
|
Chris@381
|
1025 if ($LocalGlobalLocal eq 'local') {
|
Chris@381
|
1026 if ($var{'usecontentsm'} eq 'yes') {
|
Chris@381
|
1027 print WRITEFILE " | <a href=\"$contentsname{$PathContents}$dirnamesingle{$PathContents}$var{'exthtml'}\">Local contents</a>\n";
|
Chris@381
|
1028 }
|
chris@389
|
1029 if ($var{'frames'} eq 'yes') {
|
chris@389
|
1030 print WRITEFILE " | $var{'textjumpindexlocal'} ";
|
Chris@382
|
1031 print WRITEFILE "<a href=\"$var{'filenameindexshortlocal'}$var{'filenameextensionframe'}$dirnamesingle{$PathContents}$var{'exthtml'}\">short</a> | ";
|
chris@389
|
1032 print WRITEFILE "<a href=\"$var{'filenameindexlonglocal'}$var{'filenameextensionframe'}$dirnamesingle{$PathContents}$var{'exthtml'}\">long</a>\n";
|
chris@389
|
1033 } else {
|
chris@389
|
1034 print WRITEFILE " | $var{'textjumpindexlocal'} ";
|
chris@389
|
1035 print WRITEFILE "<a href=\"$var{'filenameindexshortlocal'}$var{'filenameextensionindex'}$dirnamesingle{$PathContents}$var{'exthtml'}\">short</a> | ";
|
chris@389
|
1036 print WRITEFILE "<a href=\"$var{'filenameindexlonglocal'}$var{'filenameextensionindex'}$dirnamesingle{$PathContents}$var{'exthtml'}\">long</a>\n";
|
chris@389
|
1037 }
|
Chris@381
|
1038 }
|
Chris@381
|
1039 print WRITEFILE "</p>\n\n";
|
Chris@381
|
1040 print WRITEFILE "$var{'codehr'}\n";
|
Chris@381
|
1041 }
|
Chris@381
|
1042
|
Chris@381
|
1043
|
Chris@381
|
1044 #========================================================================
|
Chris@381
|
1045 # Construct the contents.m files or update
|
Chris@381
|
1046 #========================================================================
|
Chris@381
|
1047 sub ConstructContentsmFile
|
Chris@381
|
1048 {
|
Chris@381
|
1049 local($LocalActDir, @localnames) = @_;
|
Chris@381
|
1050 local(*CFILE, $name,$newline);
|
Chris@381
|
1051 local($contentsfile, $isincontentsonly);
|
Chris@381
|
1052 local(@lines, @autoaddlines, @emptylines);
|
Chris@381
|
1053 local($autoadd) = 'AutoAdd';
|
Chris@381
|
1054 local($autoaddsection) = 0;
|
Chris@381
|
1055 local($emptylineflag) = 0;
|
Chris@381
|
1056 local(%nameincontents);
|
Chris@381
|
1057
|
Chris@381
|
1058 # Build the contents file name
|
Chris@381
|
1059 $contentsfile = $LocalActDir.$contentsname{$LocalActDir}.$suffix;
|
Chris@381
|
1060
|
Chris@381
|
1061 if (-e $contentsfile) {
|
Chris@381
|
1062 open(CFILE,"<$contentsfile") || die("Cannot open contents file $contentsfile: $!\n");
|
Chris@381
|
1063 while (<CFILE>) {
|
Chris@381
|
1064 # Search for the specified string pattern
|
Chris@381
|
1065 @words = split;
|
Chris@381
|
1066 if ((@words >= 3) && ($words[2] eq '-')) {
|
Chris@381
|
1067 $isincontentsonly = 0;
|
Chris@381
|
1068 foreach $name (@localnames) {
|
Chris@381
|
1069 if ($name eq $words[1]) { # old
|
Chris@381
|
1070 # if ($mfilename{$name} eq $words[1]) {
|
Chris@381
|
1071 $isincontentsonly = 1;
|
Chris@381
|
1072 $nameincontents{$name} = 1;
|
Chris@381
|
1073 $newline = sprintf("%% %-13s - %s\n", $mfilename{$name}, $apropos{$name});
|
Chris@381
|
1074 push(@lines, $newline);
|
Chris@381
|
1075 }
|
Chris@381
|
1076 }
|
Chris@381
|
1077 # issue a warning, if file is in contents, but not as file in the directory
|
Chris@381
|
1078 if ($isincontentsonly == 0) {
|
Chris@381
|
1079 print "\rConstructContents: Obsolete entry $words[1] in $contentsfile ! Entry not used.\n";
|
Chris@381
|
1080 }
|
Chris@381
|
1081 } else {
|
Chris@381
|
1082 # look for the AutoAdd section, should be the second word
|
Chris@381
|
1083 if ((@words >= 2) && ($words[1] eq $autoadd)) { $autoaddsection = 1; }
|
Chris@381
|
1084 # push the red line in an array
|
Chris@381
|
1085 push(@lines, $_);
|
Chris@381
|
1086 }
|
Chris@381
|
1087 }
|
Chris@381
|
1088 close(CFILE);
|
Chris@381
|
1089 } else {
|
Chris@381
|
1090 $newline = "% MATLAB Files in directory $LocalActDir\n%\n";
|
Chris@381
|
1091 push(@lines, $newline);
|
Chris@381
|
1092
|
Chris@381
|
1093 }
|
Chris@381
|
1094
|
Chris@381
|
1095 # collect the file names, that were not included in original C|contents.m
|
Chris@381
|
1096 foreach $name (@localnames) {
|
Chris@381
|
1097 if (! defined $nameincontents{$name}) {
|
Chris@381
|
1098 if (! ($mfilename{$name} =~ /contents/i)) {
|
Chris@381
|
1099 $newline = sprintf("%% %-13s - %s\n", $mfilename{$name}, $apropos{$name});
|
Chris@381
|
1100 push(@autoaddlines, $newline);
|
Chris@381
|
1101 }
|
Chris@381
|
1102 }
|
Chris@381
|
1103 }
|
Chris@381
|
1104
|
Chris@381
|
1105 # write/update C|contents.m only if variable is set
|
Chris@381
|
1106 if ($var{'writecontentsm'} eq 'yes') {
|
Chris@381
|
1107 unlink($contentsfile);
|
Chris@381
|
1108 open(CFILE,">$contentsfile") || die("Cannot open contents file $contentsfile: $!\n");
|
Chris@381
|
1109 # write old C|contents.m or header of new file, as long as comment lines
|
Chris@381
|
1110 foreach $line (@lines) {
|
Chris@381
|
1111 if ($emptylineflag == 0) {
|
Chris@381
|
1112 if ($line =~ /^\s*%/) { print CFILE $line; }
|
Chris@381
|
1113 else { $emptylineflag = 1; push(@emptylines, $line); }
|
Chris@381
|
1114 } else { push(@emptylines, $line); }
|
Chris@381
|
1115 }
|
Chris@381
|
1116 # add header of AutoAdd section
|
Chris@381
|
1117 if (($autoaddsection == 0) && (@autoaddlines > 0)) { print CFILE "%\n% $autoadd\n"; }
|
Chris@381
|
1118 # add autoadd section lines (previously undocumented files
|
Chris@381
|
1119 foreach $line (@autoaddlines) { print CFILE $line; }
|
Chris@381
|
1120 # add tail of original C|contents.m (everything behind first non-comment line)
|
Chris@381
|
1121 foreach $line (@emptylines) { print CFILE $line; }
|
Chris@381
|
1122 print CFILE "\n";
|
Chris@381
|
1123 close CFILE;
|
Chris@381
|
1124 if ($opt_silent) { print "\r"; }
|
Chris@381
|
1125 print " Contents file created/updated: $contentsfile\t";
|
Chris@381
|
1126 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
1127 }
|
Chris@381
|
1128 }
|
Chris@381
|
1129
|
Chris@381
|
1130
|
Chris@381
|
1131 #========================================================================
|
Chris@381
|
1132 # Replace found special characters with their HTMl Entities
|
Chris@381
|
1133 #========================================================================
|
Chris@381
|
1134 sub SubstituteHTMLEntities {
|
Chris@381
|
1135 local($_) = @_;
|
Chris@381
|
1136
|
Chris@381
|
1137 # Replace & <-> & < <-> < > <-> > " <-> "
|
Chris@381
|
1138 s/&/&/g; s/\</</g; s/\>/>/g; s/\"/"/g;
|
Chris@381
|
1139 return $_;
|
Chris@381
|
1140 }
|
Chris@381
|
1141
|
Chris@381
|
1142 #========================================================================
|
Chris@381
|
1143 # Replace found m-filenamestring with full link.
|
Chris@381
|
1144 #========================================================================
|
Chris@381
|
1145 sub SubstituteName2Link {
|
Chris@381
|
1146 local($_, $funname) = @_;
|
Chris@381
|
1147 local($refstr1, $refstr2, $reffound);
|
Chris@381
|
1148
|
Chris@381
|
1149 # Look for something matching in the line
|
Chris@381
|
1150 if ( /(\W+)($funname)(\W+)/i ) {
|
Chris@381
|
1151 $reffound = $2;
|
chris@388
|
1152 $refstr1 = "<a class=\"mfun\" href=\"$hfileindexpath{$name}$hfilerelpath{$funname}$mfilename{$funname}$var{'exthtml'}\">";
|
Chris@381
|
1153 $refstr2 = "<\/a>";
|
Chris@381
|
1154 # Do links only for exact case match
|
Chris@381
|
1155 if ( ($var{'links2filescase'} eq 'exact') || ($var{'links2filescase'} eq 'exactvery') ) {
|
Chris@381
|
1156 if ( /(\W+)($funname)(\W+)/g ) {
|
Chris@381
|
1157 s/(\W+)($funname)(\W+)/$1$refstr1$funname$refstr2$3/g;
|
Chris@381
|
1158 }
|
Chris@381
|
1159 else {
|
Chris@381
|
1160 # Print info for not matching case in references, good for check up of files
|
Chris@381
|
1161 if ( ($var{'links2filescase'} eq 'exactvery') ) {
|
Chris@381
|
1162 print "Diff in case found: $funname (case of file name) <-> $reffound (case in source code)\n";
|
Chris@381
|
1163 print " (source line) $_ \n";
|
Chris@381
|
1164 }
|
Chris@381
|
1165 }
|
Chris@381
|
1166 }
|
Chris@381
|
1167 # Do links for exact match and additionally for all upper case (often used in original matlab help text)
|
Chris@381
|
1168 elsif ( ($var{'links2filescase'} eq 'exactupper') ) {
|
Chris@381
|
1169 s/(\W+)($funname)(\W+)/$1$refstr1$2$refstr2$3/g;
|
Chris@381
|
1170 $funname2 = "\U$funname\E";
|
Chris@381
|
1171 s/(\W+)($funname2)(\W+)/$1$refstr1$2$refstr2$3/g;
|
Chris@381
|
1172 }
|
Chris@381
|
1173 # Do links for all case mixes, this calls for trouble under LINUX/UNIX
|
Chris@381
|
1174 else { #elsif ( ($var{'links2filescase'} eq 'all') )
|
Chris@381
|
1175 s/(\W+)($funname)(\W+)/$1$refstr1$2$refstr2$3/ig;
|
Chris@381
|
1176 }
|
Chris@381
|
1177 }
|
Chris@381
|
1178
|
Chris@381
|
1179 return $_;
|
Chris@381
|
1180 }
|
Chris@381
|
1181
|
Chris@381
|
1182 #========================================================================
|
Chris@381
|
1183 # Construct the html files for each matlab file.
|
Chris@381
|
1184 # Need to reread each matlab file to find the help text.
|
Chris@381
|
1185 # Note that we can't do this in a single loop because sometimes
|
Chris@381
|
1186 # the help text maybe before the function declaration.
|
Chris@381
|
1187 #========================================================================
|
Chris@381
|
1188 sub ConstructHTMLFiles
|
Chris@381
|
1189 {
|
Chris@381
|
1190 local(*MFILE);
|
Chris@381
|
1191 local(*HFILE);
|
Chris@381
|
1192
|
Chris@381
|
1193 local($filescreated) = 0;
|
Chris@381
|
1194 local($functionline);
|
Chris@381
|
1195
|
Chris@381
|
1196 foreach $name (@names) {
|
Chris@381
|
1197 # Create cross reference information already here, used for keywords as well
|
Chris@381
|
1198 # Construct list of referenced functions
|
Chris@381
|
1199 @xref = @{'depcalls'.$name}; # the functions, that this m-file calls
|
Chris@381
|
1200 @yref = @{'depcalled'.$name}; # the functions, that this m-file is called from
|
Chris@381
|
1201 # print " depcalls: @{'depcalls'.$name}\n depcalled: @{'depcalled'.$name}\n";
|
Chris@381
|
1202 # foreach $cname (@names) { next if $cname eq $name; push(@yref,$cname) if grep(/$name/,@{'depcalls'.$cname}); }
|
Chris@381
|
1203
|
Chris@381
|
1204
|
Chris@381
|
1205 # Open m-file and html-file
|
Chris@381
|
1206 open(MFILE,"<$mfile{$name}");
|
Chris@381
|
1207 open(HFILE,">$hfile{$name}");
|
Chris@381
|
1208
|
Chris@381
|
1209 # Write the header of HTML file
|
Chris@381
|
1210 print HFILE "$TextDocTypeHTML\n<html>\n<head>\n$var{'codeheadmeta'}\n$TextMetaCharset\n$var{'csslink'}\n";
|
Chris@381
|
1211
|
Chris@381
|
1212 # Write meta tags: use apropos (one line function description) for description
|
Chris@381
|
1213 # and cross reference function names for keywords (any better ideas?)
|
Chris@381
|
1214 print HFILE "<meta name=\"description\" content=\" $apropos{$name} \" />\n";
|
Chris@381
|
1215 print HFILE "<meta name=\"keywords\" content=\" @xref @yref \" />\n";
|
Chris@381
|
1216
|
Chris@381
|
1217 # Write Title and start body of html-file
|
Chris@381
|
1218 print HFILE "<title>$var{'texttitlefiles'} $mfilename{$name}</title>\n</head>\n";
|
Chris@381
|
1219 print HFILE "<body $var{'codebodyfiles'}>\n";
|
Chris@381
|
1220 print HFILE "<h1 $var{'codeheader'}>$var{'textheaderfiles'} $mfilename{$name}</h1>\n";
|
chris@401
|
1221
|
chris@401
|
1222 # http://test.soundsoftware.ac.uk/cannam/projects/smallbox/repository/annotate/DL/RLS-DLA/SolveFISTA.m
|
chris@401
|
1223
|
chris@401
|
1224 print HFILE "<a href=\"" . $hfileindexpath{$name} . "../../projects/smallbox/repository/annotate/" . $mfiledir{$name} . $mfilename{$name} . ".m\">View in repository</a>\n";
|
chris@401
|
1225
|
Chris@381
|
1226 print HFILE "$var{'codehr'}\n";
|
Chris@381
|
1227
|
Chris@381
|
1228 # include links to short/long - local/global index and C|contents.m
|
Chris@381
|
1229 &ConstructLinks2Index(HFILE, $hfileindexpath{$name}, $mfiledir{$name}, 'local');
|
Chris@381
|
1230
|
Chris@381
|
1231 # If this is a function, then write out the first line as a synopsis
|
Chris@381
|
1232 if ($mtype{$name} eq "function") {
|
Chris@381
|
1233 print HFILE "<h2 $var{'codeheader'}>Function Synopsis</h2>\n";
|
Chris@381
|
1234 print HFILE "<pre>$synopsis{$name}</pre>\n$var{'codehr'}\n";
|
Chris@381
|
1235 }
|
Chris@381
|
1236
|
Chris@381
|
1237 # Look for the matlab help text block
|
Chris@381
|
1238 $functionline = "\n";
|
Chris@381
|
1239 do {
|
Chris@381
|
1240 $_ = <MFILE>;
|
Chris@381
|
1241 # remember functionline, if before help text block
|
Chris@381
|
1242 if (/^\s*function/) { $functionline = $_; }
|
Chris@381
|
1243 } until (/^\s*%/ || eof);
|
Chris@381
|
1244 if (! (eof(MFILE))) {
|
Chris@381
|
1245 print HFILE "<h2 $var{'codeheader'}>Help text</h2>\n";
|
Chris@381
|
1246 print HFILE "<pre>\n";
|
Chris@381
|
1247 while (/^\s*%/) {
|
Chris@381
|
1248 # First remove leading % and white space, then Substitute special characlers
|
Chris@381
|
1249 s/^\s*%//;
|
Chris@381
|
1250 $_ = &SubstituteHTMLEntities($_);
|
Chris@381
|
1251
|
Chris@381
|
1252 # check/create cross references
|
Chris@381
|
1253 foreach $funname (@{'all'.$name}) {
|
Chris@381
|
1254 if ($funname =~ /simulink/) { print "\n Simulink - Filename: $name; scanname: $funname\n"; }
|
Chris@381
|
1255 next if $funname eq $name;
|
Chris@381
|
1256 $_ = &SubstituteName2Link($_, $funname);
|
Chris@381
|
1257 }
|
Chris@381
|
1258 print HFILE $_;
|
Chris@381
|
1259 if (! eof) { $_ = <MFILE>; }
|
Chris@381
|
1260 }
|
Chris@381
|
1261 print HFILE "</pre>\n$var{'codehr'}\n";
|
Chris@381
|
1262 }
|
Chris@381
|
1263
|
Chris@381
|
1264 # Write the cross reference information
|
Chris@381
|
1265 if (@xref || @yref) {
|
Chris@381
|
1266 print HFILE "<h2 $var{'codeheader'}>Cross-Reference Information</H2>\n";
|
Chris@381
|
1267 print HFILE "<table border=\"0\" width=\"100%\">\n<tr align=\"left\">\n<th width=\"50%\">";
|
Chris@381
|
1268 if (@xref) {
|
Chris@381
|
1269 print HFILE "This $mtype{$name} calls";
|
Chris@381
|
1270 }
|
Chris@381
|
1271 print HFILE "</th>\n<th width=\"50%\">";
|
Chris@381
|
1272 if (@yref) {
|
Chris@381
|
1273 print HFILE "This $mtype{$name} is called by";
|
Chris@381
|
1274 }
|
Chris@381
|
1275 print HFILE "</th>\n</tr>\n<tr valign=\"top\"><td>";
|
Chris@381
|
1276 if (@xref) {
|
Chris@381
|
1277 print HFILE "\n<ul>\n";
|
Chris@381
|
1278 foreach $cname (sort @xref) {
|
Chris@381
|
1279 print HFILE "<li><a class=\"mfun\" href=\"$hfileindexpath{$name}$hfilerelpath{$cname}$mfilename{$cname}$var{'exthtml'}\">$mfilename{$cname}</a></li>\n";
|
Chris@381
|
1280 }
|
Chris@381
|
1281 print HFILE "</ul>\n";
|
Chris@381
|
1282 }
|
Chris@381
|
1283 print HFILE "</td><td>";
|
Chris@381
|
1284 if (@yref) {
|
Chris@381
|
1285 print HFILE "\n<ul>\n";
|
Chris@381
|
1286 foreach $cname (sort @yref) {
|
Chris@381
|
1287 print HFILE "<li><a class=\"mfun\" href=\"$hfileindexpath{$name}$hfilerelpath{$cname}$mfilename{$cname}$var{'exthtml'}\">$mfilename{$cname}</a></li>\n";
|
Chris@381
|
1288 }
|
Chris@381
|
1289 print HFILE "</ul>\n";
|
Chris@381
|
1290 }
|
Chris@381
|
1291 print HFILE "</td>\n</tr>\n</table>\n";
|
Chris@381
|
1292 print HFILE "$var{'codehr'}\n";
|
Chris@381
|
1293 }
|
Chris@381
|
1294
|
Chris@381
|
1295 # Include source text if requested
|
Chris@381
|
1296 if (($var{'includesource'} eq 'yes') && (! ($mfilename{$name} =~ /^contents$/i))) {
|
Chris@381
|
1297 print HFILE "<h2 $var{'codeheader'}>Listing of $mtype{$name} $mfilename{$name}</h2>\n";
|
Chris@381
|
1298 seek(MFILE,0,0);
|
Chris@381
|
1299 print HFILE "<pre>\n";
|
Chris@381
|
1300 $IsStillHelp = 2;
|
Chris@381
|
1301 print HFILE $functionline; # functionline from scanning of help
|
Chris@381
|
1302 while (<MFILE>) {
|
Chris@381
|
1303 if ($IsStillHelp == 2) {
|
Chris@381
|
1304 next if (/^\s*$/);
|
Chris@381
|
1305 next if (/^\s*function/);
|
Chris@381
|
1306 if (/^\s*%/) { $IsStillHelp = 1; next; }
|
Chris@381
|
1307 } elsif ($IsStillHelp == 1) {
|
Chris@381
|
1308 next if (/^\s*%/);
|
Chris@381
|
1309 $IsStillHelp = 0;
|
Chris@381
|
1310 }
|
Chris@381
|
1311
|
Chris@381
|
1312 # Substritute special characters
|
Chris@381
|
1313 $_ = &SubstituteHTMLEntities($_);
|
Chris@381
|
1314
|
Chris@381
|
1315 # check for comment in line and format with css em
|
chris@400
|
1316 s/^(.*)%(.*?)([\s\r\n]+)$/$1<em class=\"mcom\">%$2<\/em>$3/;
|
Chris@381
|
1317
|
Chris@381
|
1318 # check/create cross references
|
Chris@381
|
1319 foreach $funname (@{'all'.$name}) {
|
Chris@381
|
1320 next if $funname eq $name;
|
Chris@381
|
1321 $_ = &SubstituteName2Link($_, $funname);
|
Chris@381
|
1322 }
|
Chris@381
|
1323 print HFILE $_;
|
Chris@381
|
1324 }
|
Chris@381
|
1325 print HFILE "</pre>\n$var{'codehr'}\n";
|
Chris@381
|
1326 }
|
Chris@381
|
1327
|
Chris@381
|
1328 # Include info about author from authorfile
|
Chris@381
|
1329 &WriteFile2Handle($var{'authorfile'}, HFILE) ;
|
Chris@381
|
1330
|
Chris@381
|
1331 print HFILE "<!--navigate-->\n";
|
Chris@381
|
1332 print HFILE "<!--copyright-->\n";
|
Chris@381
|
1333 print HFILE "</body>\n</html>\n";
|
Chris@381
|
1334 close(MFILE);
|
Chris@381
|
1335 close(HFILE);
|
Chris@381
|
1336
|
Chris@381
|
1337 # Print name of finished file
|
Chris@381
|
1338 if ($opt_silent) { print "\r"; }
|
Chris@381
|
1339 print " HTML-File created: $hfile{$name}\t";
|
Chris@381
|
1340 if (!$opt_silent) { print "\n"; }
|
Chris@381
|
1341 $filescreated++;
|
Chris@381
|
1342 }
|
Chris@381
|
1343
|
Chris@381
|
1344 print "\n$PROGRAM: $indexcreated index and $filescreated files created.\n";
|
Chris@381
|
1345 }
|
Chris@381
|
1346
|
Chris@381
|
1347 #========================================================================
|
Chris@381
|
1348 # Function: CheckFileName
|
Chris@381
|
1349 # Purpose: .
|
Chris@381
|
1350 #========================================================================
|
Chris@381
|
1351 sub CheckFileName {
|
Chris@381
|
1352 local($filename, $description) = @_;
|
Chris@381
|
1353 local(*CHECKFILE);
|
Chris@381
|
1354
|
Chris@381
|
1355 open(CHECKFILE,"<$filename") || do {
|
Chris@381
|
1356 if ($description eq '') {$description = 'file';}
|
Chris@381
|
1357 # if (!$opt_silent) { print "Cannot open $description $filename: $!\n"; }
|
Chris@381
|
1358 print "Cannot open $description $filename: $!\n";
|
Chris@381
|
1359 return 1;
|
Chris@381
|
1360 };
|
Chris@381
|
1361 close(CHECKFILE);
|
Chris@381
|
1362 return 0;
|
Chris@381
|
1363
|
Chris@381
|
1364 }
|
Chris@381
|
1365
|
Chris@381
|
1366 #========================================================================
|
Chris@381
|
1367 # Function: CheckDirName
|
Chris@381
|
1368 # Purpose: .
|
Chris@381
|
1369 #========================================================================
|
Chris@381
|
1370 sub CheckDirName {
|
Chris@381
|
1371 local($dirname, $description) = @_;
|
Chris@381
|
1372 local(*CHECKDIR);
|
Chris@381
|
1373
|
Chris@381
|
1374 opendir(CHECKDIR,"$dirname") || die ("Cannot open $description directory $dirname: $!\n");
|
Chris@381
|
1375 closedir(CHECKDIR);
|
Chris@381
|
1376 }
|
Chris@381
|
1377
|
Chris@381
|
1378 #========================================================================
|
Chris@381
|
1379 # Function: WriteFile2Handle
|
Chris@381
|
1380 # Purpose: .
|
Chris@381
|
1381 #========================================================================
|
Chris@381
|
1382 sub WriteFile2Handle {
|
Chris@381
|
1383 local($filename, *WRITEFILE) = @_;
|
Chris@381
|
1384 local(*READFILE);
|
Chris@381
|
1385
|
Chris@381
|
1386 if ($filename ne '') {
|
Chris@381
|
1387 open(READFILE,"<$filename");
|
Chris@381
|
1388 @filecontents = <READFILE>;
|
Chris@381
|
1389 close(READFILE);
|
Chris@381
|
1390 print WRITEFILE "@filecontents\n";
|
Chris@381
|
1391 # if (!$opt_silent) {print " Contents of $filename added\n"};
|
Chris@381
|
1392 }
|
Chris@381
|
1393 }
|
Chris@381
|
1394
|
Chris@381
|
1395
|
Chris@381
|
1396 #========================================================================
|
Chris@381
|
1397 # Function: GetConfigFile
|
Chris@381
|
1398 # Purpose: Read user's configuration file, if such exists.
|
Chris@381
|
1399 #========================================================================
|
Chris@381
|
1400 sub GetConfigFile
|
Chris@381
|
1401 {
|
Chris@381
|
1402 local($filename) = @_;
|
Chris@381
|
1403 local(*CONFIG);
|
Chris@381
|
1404 local($value);
|
Chris@381
|
1405
|
Chris@381
|
1406 if (&CheckFileName($filename, 'configuration file')) {
|
Chris@381
|
1407 # if (!$opt_silent) { print " Proceeding using built-in defaults for configuration.\n"; }
|
Chris@381
|
1408 print " Proceeding using built-in defaults for configuration.\n";
|
Chris@381
|
1409 return 0;
|
Chris@381
|
1410 };
|
Chris@381
|
1411
|
Chris@381
|
1412 open(CONFIG,"< $filename");
|
Chris@381
|
1413 while (<CONFIG>) {
|
Chris@381
|
1414 s/#.*$//;
|
Chris@381
|
1415 next if /^\s*$/o;
|
Chris@381
|
1416
|
Chris@381
|
1417 # match keyword: process one or more arguments
|
Chris@381
|
1418 # keyword set
|
Chris@381
|
1419 if (/^\s*set\s+(\S+)\s*=\s*(.*)/) {
|
Chris@381
|
1420 # setting a configuration variable
|
Chris@381
|
1421 if (defined $var{$1}) {
|
Chris@381
|
1422 $var{$1} = $2;
|
Chris@381
|
1423 if ($debug > 3) { print "$1: $var{$1}\n"; }
|
Chris@381
|
1424 }
|
Chris@381
|
1425 else {
|
Chris@381
|
1426 print "$PROGRAM: unknown variable `$1' in configuration file\n"
|
Chris@381
|
1427 }
|
Chris@381
|
1428 } else {
|
Chris@381
|
1429 chop($_);
|
Chris@381
|
1430 print "$PROGRAM: unknown keyword in configuration file in line: `$_'\n"
|
Chris@381
|
1431 }
|
Chris@381
|
1432 }
|
Chris@381
|
1433 close CONFIG;
|
Chris@381
|
1434 1;
|
Chris@381
|
1435 }
|
Chris@381
|
1436
|
Chris@381
|
1437
|
Chris@381
|
1438 #------------------------------------------------------------------------
|
Chris@381
|
1439 # DisplayHelp - display help text using -h or -help command-line switch
|
Chris@381
|
1440 #------------------------------------------------------------------------
|
Chris@381
|
1441 sub DisplayHelp
|
Chris@381
|
1442 {
|
Chris@381
|
1443 $help=<<EofHelp;
|
Chris@381
|
1444 $PROGRAM v$VERSION - generate html documentation from Matlab m-files
|
Chris@381
|
1445
|
Chris@381
|
1446 Usage: $PROGRAM [-h] [-c config_file] [-m|dirmfiles matlab_dir] [-d|dirhtml html_dir]
|
Chris@381
|
1447 [-i yes|no] [-r yes|no] [-p yes|no] [-quiet|q] [-a authorfile]
|
Chris@381
|
1448
|
Chris@381
|
1449 $PROGRAM is a perl script that reads each matlab .m file in a directory
|
Chris@381
|
1450 to produce a corresponding .html file of help documentation and cross
|
Chris@381
|
1451 reference information. An index file is written with links to all of
|
Chris@381
|
1452 the html files produced. The options are:
|
Chris@381
|
1453
|
Chris@381
|
1454 -quiet or -q : be silent, no status information during generation
|
Chris@381
|
1455 -help or -h : display this help message
|
Chris@381
|
1456 -todo or -t : print the todo list for $PROGRAM
|
Chris@381
|
1457 -version or -v : display version
|
Chris@381
|
1458
|
Chris@381
|
1459 -configfile or -c : name of configuration file (default to $var{'configfile'}).
|
Chris@381
|
1460 -dirmfiles or -m : top level directory containing matlab files to generate html for;
|
Chris@381
|
1461 default to actual directory.
|
Chris@381
|
1462 -dirhtml or -d : top level directory for generated html files;
|
Chris@381
|
1463 default to actual directory.
|
Chris@381
|
1464
|
Chris@381
|
1465 -includesource or -i : Include matlab source in the html documentation [yes|no]
|
Chris@381
|
1466 default to yes.
|
Chris@381
|
1467 -processtree or -r : create docu for m-file directory and all subdirectories [yes|no];
|
Chris@381
|
1468 default to yes.
|
Chris@381
|
1469 -producetree or -p : create multi-level docu identical to directory structure
|
Chris@381
|
1470 of m-files [yes|no]; default to yes.
|
Chris@381
|
1471 -writecontentsm or -w: update or write contents.m files into the matlab source
|
Chris@381
|
1472 directories [yes|no]; default to no.
|
Chris@381
|
1473
|
Chris@381
|
1474 -authorfile or -a : name of file including author information, last element in html;
|
Chris@381
|
1475 default to empty.
|
Chris@381
|
1476
|
Chris@381
|
1477 The command line setting overwrite all other settings (built-in and configuration file).
|
Chris@381
|
1478 The configuration file settings overwrite the built-in settings (and not the command
|
Chris@381
|
1479 line settings).
|
Chris@381
|
1480
|
Chris@381
|
1481 Typical usages are:
|
Chris@381
|
1482 $PROGRAM
|
Chris@381
|
1483 (use default parameters from perl script, if configuration
|
Chris@381
|
1484 file is found -> generation of docu, else display of help)
|
Chris@381
|
1485
|
Chris@381
|
1486 $PROGRAM -dirmfiles matlab -dirhtml html
|
Chris@381
|
1487 (generate html documentation for all m-files in directory matlab,
|
Chris@381
|
1488 place html files in directory html, use built-in defaults for
|
Chris@381
|
1489 all other parameters, this way all m-files in the directory
|
Chris@381
|
1490 matlab and below are converted and the generated html-files are
|
Chris@381
|
1491 placed in the directory html and below producing the same
|
Chris@381
|
1492 directory structure than below matlab)
|
Chris@381
|
1493
|
Chris@381
|
1494 $PROGRAM -quiet
|
Chris@381
|
1495 (use built-in parameters from perl script, if configuration
|
Chris@381
|
1496 file is found use these settings as well, do generation,
|
Chris@381
|
1497 no display except critical errors, status of conversion and result)
|
Chris@381
|
1498
|
Chris@381
|
1499 $PROGRAM -m toolbox -dirhtml doc/html -r yes -p no
|
Chris@381
|
1500 (convert all m-files in directory toolbox and below and place
|
Chris@381
|
1501 the generated html files in directory doc/html, read all m-files
|
Chris@381
|
1502 recursively, however, the generated html files are placed in one
|
Chris@381
|
1503 directory)
|
Chris@381
|
1504
|
Chris@381
|
1505 $PROGRAM -m toolbox -dirhtml doc/html -i no -r no
|
Chris@381
|
1506 (convert all m-files in directory toolbox and place
|
Chris@381
|
1507 the generated html files in directory doc/html, do not read m-files
|
Chris@381
|
1508 recursively, do not include source code in documentation)
|
Chris@381
|
1509
|
Chris@381
|
1510 EofHelp
|
Chris@381
|
1511
|
Chris@381
|
1512 die "$help";
|
Chris@381
|
1513 }
|
Chris@381
|
1514
|
Chris@381
|
1515 #------------------------------------------------------------------------
|
Chris@381
|
1516 # DisplayTodo - display ToDo list using -t or -todo command-line switch
|
Chris@381
|
1517 #------------------------------------------------------------------------
|
Chris@381
|
1518 sub DisplayTodo
|
Chris@381
|
1519 {
|
Chris@381
|
1520 $todo=<<EofToDo;
|
Chris@381
|
1521 $PROGRAM v$VERSION - ToDo list
|
Chris@381
|
1522
|
Chris@381
|
1523 o use more than one high level directory
|
Chris@381
|
1524
|
Chris@381
|
1525 o what should/could be done here???
|
Chris@381
|
1526
|
Chris@381
|
1527 EofToDo
|
Chris@381
|
1528
|
Chris@381
|
1529 die "$todo";
|
Chris@381
|
1530 }
|
Chris@381
|
1531
|
Chris@381
|
1532
|
Chris@381
|
1533 #------------------------------------------------------------------------
|
Chris@381
|
1534 # ListVariables - list all defined variables and their values
|
Chris@381
|
1535 #------------------------------------------------------------------------
|
Chris@381
|
1536 sub ListVariables
|
Chris@381
|
1537 {
|
Chris@381
|
1538 local($value);
|
Chris@381
|
1539
|
Chris@381
|
1540 if ($debug > 0) {
|
Chris@381
|
1541 print "List of all variables and their values\n";
|
Chris@381
|
1542 foreach (sort keys %var)
|
Chris@381
|
1543 {
|
Chris@381
|
1544 if ($var{$_} eq '') {
|
Chris@381
|
1545 $value = "empty";
|
Chris@381
|
1546 } else {
|
Chris@381
|
1547 $value = $var{$_};
|
Chris@381
|
1548 }
|
Chris@381
|
1549 print " $_\n $value\n";
|
Chris@381
|
1550 }
|
Chris@381
|
1551 print "\n\n";
|
Chris@381
|
1552 }
|
Chris@381
|
1553 }
|
Chris@381
|
1554
|
Chris@381
|
1555
|
Chris@381
|
1556 __END__
|
Chris@381
|
1557 :endofperl
|