To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / extra / soundsoftware / matlab-docs.pl @ 389:0bc92382a86b

History | View | Annotate | Download (64.2 KB)

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