Mercurial > forge
annotate admin/make_index @ 2676:019a7290e0fd octave-forge
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
author | adb014 |
---|---|
date | Sat, 14 Oct 2006 05:10:07 +0000 |
parents | 6548c639892b |
children | 9da47715addc |
rev | line source |
---|---|
213 | 1 #!/usr/bin/env perl |
2 # | |
3 # Albert Danial Mar 21 2002 | |
4 # | |
5 # Creates .html files documenting all the functions in octave and | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
6 # octave-forge. |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
7 |
213 | 8 use strict; |
9 use File::Find; | |
10 use File::Basename; | |
11 use Text::Wrap; | |
12 use FileHandle; | |
267 | 13 use IPC::Open3; |
224 | 14 use POSIX ":sys_wait_h"; |
213 | 15 |
1776
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
16 ## Local configuration; the OCTAVE directory should contain |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
17 # src/DOCSTRINGS (which is a build product) and scripts/. |
2497 | 18 my $OCTAVE = "../octave"; |
1776
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
19 my $tmpdir = "/tmp"; # temp directory |
2487 | 20 my $catdir = "www/doc"; # output directory |
1776
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
21 |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
22 ## Commands to grab the last few defs from octave |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
23 ## Use the first def if you want to extract from |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
24 ## a locally compiled version, or the second if you |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
25 ## want to use the installed version. |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
26 #my $OCTAVECMD = "LD_LIBRARY_PATH=$OCTAVE/src/:$OCTAVE/liboctave:$OCTAVE/libcruft $OCTAVE/src/octave -q"; |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
27 #my $OCTAVEINIT = "path='.:$OCTAVE/src//:$OCTAVE/scripts//'; suppress_verbose_help_message = 1;"; |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
28 my $OCTAVECMD = "octave -q"; |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
29 my $OCTAVEINIT = "suppress_verbose_help_message = 1;"; |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
30 |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
31 # Links to octave/octave-forge web CVS |
1545
f6a4d072a146
[for David Bateman] use viewcvs rather than cvsweb
pkienzle
parents:
1475
diff
changeset
|
32 my $OCTAVECVS = "http://www.octave.org/cgi-bin/viewcvs.cgi/~checkout~/octave"; |
2615
d48a2accb8d8
Fix the octave-forge CVS address so the checkout link actually works
adb014
parents:
2607
diff
changeset
|
33 my $FORGECVS = "http://octave.cvs.sourceforge.net/octave/octave-forge/"; |
1776
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
34 |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
35 #my $script = basename($0); |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
36 |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
37 my $forgebar = qq~<center> |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
38 <A href="http://octave.sourceforge.net">Home</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
39 <A href="http://sourceforge.net/projects/octave/">Summary</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
40 <A href="http://sourceforge.net/forum/?group_id=2888">Forums</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
41 <A href="http://sourceforge.net/bugs/?group_id=2888">Bugs</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
42 <A href="http://sourceforge.net/support/?group_id=2888">Support</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
43 <A href="http://sourceforge.net/patch/?group_id=2888">Patches</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
44 <A href="http://sourceforge.net/mail/?group_id=2888">Lists</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
45 <A href="http://sourceforge.net/pm/?group_id=2888">Tasks</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
46 <A href="http://sourceforge.net/docman/?group_id=2888">Docs</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
47 <A href="http://sourceforge.net/survey/?group_id=2888">Surveys</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
48 <A href="http://sourceforge.net/news/?group_id=2888">News</A> | |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
49 <A href="http://sourceforge.net/cvs/?group_id=2888">CVS</A> | |
1776
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
50 <A href="http://sourceforge.net/project/showfiles.php?group_id=2888">Files</A> |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
51 </center> |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
52 ~; |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
53 |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
54 my $forgelink = qq~ |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
55 <hr><center> |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
56 <small>Hosted by</small> <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=2888&type=4" width="125" height="37" border="0" alt="SourceForge.net Logo" /></a> |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
57 </center> |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
58 ~; |
213 | 59 |
265
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
60 # initialize the indexing variables |
213 | 61 my %index_by_TB_cat = (); # i_TB_cat{toolbox}{category} = list of functions |
62 my %index_by_function = (); # i_function{function} =[ [toolbox_1,category_1], | |
225 | 63 # [toolbox_2,category_2],..] |
213 | 64 my %TB_description = (); |
234
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
65 my %index_notes = (); # index_notes{function} = comment |
2666
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
66 my %index_by_package = (); # i_package{package} = list of functions |
265
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
67 |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
68 # find and load all indices |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
69 my @index_files = (); |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
70 find(\&index_files, "."); |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
71 sub index_files { # {{{1 populates global array @files |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
72 return unless -f and /INDEX$/; # INDEX files |
2607 | 73 return if ($File::Find::dir =~ /packages$/); |
280 | 74 my $path = "$File::Find::dir/$_"; |
75 $path =~ s|^[.]/||; | |
2676
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
76 my $noinstall = sprintf("%s/NOINSTALL", $path); |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
77 if (! -e $noinstall) { |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
78 push @index_files, $path; |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
79 } |
265
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
80 } # 1}}} |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
81 foreach my $f ( @index_files ) { |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
82 load_index($f, |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
83 \%index_by_TB_cat, |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
84 \%TB_description, |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
85 \%index_by_function); |
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
86 } |
213 | 87 |
1475
4602d2d9b1f8
Windows/OS X have case-insensitive file names, so move INDEX out of the
pkienzle
parents:
1430
diff
changeset
|
88 # XXX FIXME XXX should die if the index is empty |
4602d2d9b1f8
Windows/OS X have case-insensitive file names, so move INDEX out of the
pkienzle
parents:
1430
diff
changeset
|
89 # die "No INDEX in current directory" if !-e "INDEX"; |
278
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
90 my $summary = !-e "admin/make_index"; # if not in the root, just summarize |
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
91 my $include_octave = !$summary; # only include octave if not summarizing |
225 | 92 |
264 | 93 # locate all C++ and m-files in octave-forge, and all m-files in octave |
94 # don't need C++ files from octave because we have DOCSTRINGS | |
213 | 95 my @m_files = (); |
96 my @C_files = (); | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
97 find(\&cc_and_m_files, "$OCTAVE/scripts") if $include_octave; |
1112
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
98 find(\&cc_and_m_files, "$OCTAVE/src") if $include_octave; |
2168
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
99 # or just use $OCTAVE/{src,scripts}/DOCSTRINGS .... |
2140
63b242a71651
make octave versions of function precede octave-forge versions. Some fixes to indexing
adb014
parents:
2000
diff
changeset
|
100 find(\&cc_and_m_files, "."); |
264 | 101 sub cc_and_m_files { # {{{1 populates global array @files |
1112
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
102 return unless -f and /\.(m|cc|l|y)$/; # .m and .cc files (lex & yacc too!) |
280 | 103 my $path = "$File::Find::dir/$_"; |
104 $path =~ s|^[.]/||; | |
2676
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
105 my $noinstall = sprintf("%s/NOINSTALL", $path); |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
106 if (! -e $noinstall) { |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
107 if (/\.m$/) { |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
108 push @m_files, $path; |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
109 } else { |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
110 push @C_files, $path; |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
111 } |
264 | 112 } |
113 } # 1}}} | |
114 | |
213 | 115 my %function_description = (); |
116 my %octave_forge_function = (); | |
117 my @uncategorized = (); | |
282 | 118 my @skipped = (); |
213 | 119 my %n_appearances = (); |
225 | 120 my $n_functions = 0; |
329 | 121 my @shadow_paths = ('FIXES', 'extra/NaN', 'extra/Windows', 'extra/ver20'); |
122 my @shadowed = (); | |
264 | 123 |
124 # grab help from C++ files | |
213 | 125 foreach my $f ( @C_files ) { |
126 if ( open(IN,$f) ) { | |
127 while (<IN>) { | |
128 # skip to the next function | |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
129 next unless /^\s*DEF(UN[ (]|UN_MAPPER|UN_DLD|CMD|VAR|CONST)/; |
213 | 130 |
1112
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
131 # print "looking at $_"; |
213 | 132 # extract function name to pattern space |
133 /\((\w*)\s*,/; | |
134 # remember function name | |
135 my $function = $1; | |
1112
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
136 # print " found function $function\n"; |
2000
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
137 |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
138 # skip to second , to skip default string options of DEFVAR |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
139 # comment if third or higher arg |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
140 # XXX FIXME XXX What about if the string arg includes , |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
141 # XXX FIXME XXX What if second , is not on first line!! |
2140
63b242a71651
make octave versions of function precede octave-forge versions. Some fixes to indexing
adb014
parents:
2000
diff
changeset
|
142 # Special cases |
63b242a71651
make octave versions of function precede octave-forge versions. Some fixes to indexing
adb014
parents:
2000
diff
changeset
|
143 # * for DEFCONST (I, Complex (0., 1.), |
63b242a71651
make octave versions of function precede octave-forge versions. Some fixes to indexing
adb014
parents:
2000
diff
changeset
|
144 s/\(\w*\s*,\s*Complex\s*\(\s*[0-9.]*\s*,\s*[0-9.]*\s*\),//; |
63b242a71651
make octave versions of function precede octave-forge versions. Some fixes to indexing
adb014
parents:
2000
diff
changeset
|
145 # * for macro containing DEFUN_DLD |
63b242a71651
make octave versions of function precede octave-forge versions. Some fixes to indexing
adb014
parents:
2000
diff
changeset
|
146 s/\w*\s*\(\w*\s*,\s*"/"/; |
63b242a71651
make octave versions of function precede octave-forge versions. Some fixes to indexing
adb014
parents:
2000
diff
changeset
|
147 # Main case |
2000
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
148 s/\(\w*\s*,.*?,//; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
149 |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
150 # If we have nothing but a newline, skip |
2140
63b242a71651
make octave versions of function precede octave-forge versions. Some fixes to indexing
adb014
parents:
2000
diff
changeset
|
151 $_ = <IN> if /^\s*DEF(UN[ (]|UN_MAPPER|UN_DLD|CMD|VAR|CONST)\s*,*\s*\n/; |
2000
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
152 |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
153 # if line contains \w+_DOC_STRING we have a macro for the |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
154 # help text |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
155 my $desc; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
156 if (/\w+_DOC_STRING/) { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
157 my $macro = $_; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
158 $macro =~ s/^.*?\s*(\w*_DOC_STRING).*$/$1/; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
159 $macro =~ s/\n//; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
160 |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
161 my $line; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
162 if ( open(IN2, $f) ) { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
163 while ($line = <IN2>) { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
164 next unless $line =~ /^\#\s*define\s+$macro\s+\"/; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
165 $desc = $line; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
166 $desc =~ s/^\#\s*define\s+$macro\s+\"(.*\n)$/$1/; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
167 while ($desc !~ /[^\\]\"/ && $desc !~ /^\"/) { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
168 $desc =~ s/\\\s*\n//; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
169 # join with the next line |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
170 $desc .= <IN2>; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
171 } |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
172 $desc = "" if $desc =~ /^\"/; # chop everything if it was "" |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
173 $desc =~ s/\\n/\n/g; # insert fake line ends |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
174 $desc =~ s/([^\"])\".*$/$1/; # chop everything after final '"' |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
175 $desc =~ s/\\\"/\"/; # convert \"; XXX FIXME XXX \\" |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
176 last; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
177 } |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
178 close (IN2); |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
179 } else { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
180 print STDERR "Could not open file ($f): $!\n"; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
181 } |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
182 } else { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
183 # skip to next line if comment doesn't start on this line |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
184 # XXX FIXME XXX maybe we want a loop here? |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
185 $_ = <IN> unless /\"/; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
186 # skip to the beginning of the comment string by |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
187 # chopping everything up to opening " |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
188 $desc = $_; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
189 $desc =~ s/^[^\"]*\"//; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
190 |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
191 # join lines until you get the end of the comment string |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
192 # plus a bit more. You need the "plus a bit more" because |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
193 # C compilers allow implicitly concatenated string constants |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
194 # "A" "B" ==> "AB". |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
195 while ($desc !~ /[^\\]\"\s*[\,\)]/ && $desc !~ /^\"/) { |
213 | 196 # if line ends in '\', chop it and the following '\n' |
197 $desc =~ s/\\\s*\n//; | |
198 # join with the next line | |
199 $desc .= <IN>; | |
200 # eliminate consecutive quotes, being careful to ignore | |
201 # preceding slashes. XXX FIXME XXX what about \\" ? | |
202 $desc =~ s/([^\\])\"\s*\"/$1/; | |
2000
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
203 } |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
204 $desc = "" if $desc =~ /^\"/; # chop everything if it was "" |
1430
8aabe04712c8
make_index fix for help strings with macros like load or fft
adb014
parents:
1112
diff
changeset
|
205 |
2000
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
206 # Now check for text included in help messages as macros |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
207 # XXX FIXME XXX These macros are often compile dependent, so |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
208 # how to we get the correct version of the macro in this case |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
209 # without actually compiling the code??? |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
210 while ($desc =~ /[^\\]\"\s*\S+\s*[^\\]\"/) { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
211 my $macro = $desc; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
212 # Deal with issues of multiple macros... |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
213 # $macro =~ s/^.*[^\\]\"\s*(\S+?)\s*[^\\]\".*$/$1/; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
214 ($macro) = ($macro =~ /[^\\]\"\s*(\S+?)\s*\".*$/); |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
215 $macro =~ s/\n//; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
216 my $macro_defn; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
217 my $line; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
218 if ( open(IN2, $f) ) { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
219 while ($line = <IN2>) { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
220 next unless $line =~ /^\#\s*define\s+$macro\s+\"/; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
221 $macro_defn = $line; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
222 $macro_defn =~ s/^\#\s*define\s+$macro\s+\"(.*)\n$/$1/; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
223 while ($macro_defn !~ /[^\\]\"/ && $macro_defn !~ /^\"/) { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
224 $macro_defn =~ s/\\\s*\n//; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
225 # join with the next line |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
226 $macro_defn .= <IN2>; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
227 } |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
228 $macro_defn = "" if $macro_defn =~ /^\"/; # chop everything if it was "" |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
229 $macro_defn =~ s/\\n/\n/g; # insert fake line ends |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
230 $macro_defn =~ s/([^\"])\".*$/$1/; # chop everything after final '"' |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
231 $macro_defn =~ s/\\\"/\"/; # convert \"; XXX FIXME XXX \\" |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
232 last; |
1430
8aabe04712c8
make_index fix for help strings with macros like load or fft
adb014
parents:
1112
diff
changeset
|
233 } |
2000
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
234 close (IN2); |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
235 } else { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
236 print STDERR "Could not open file ($f): $!\n"; |
1430
8aabe04712c8
make_index fix for help strings with macros like load or fft
adb014
parents:
1112
diff
changeset
|
237 } |
2000
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
238 $desc =~ s/\"\s*$macro\s*\"/$macro_defn/; |
1430
8aabe04712c8
make_index fix for help strings with macros like load or fft
adb014
parents:
1112
diff
changeset
|
239 } |
8aabe04712c8
make_index fix for help strings with macros like load or fft
adb014
parents:
1112
diff
changeset
|
240 } |
8aabe04712c8
make_index fix for help strings with macros like load or fft
adb014
parents:
1112
diff
changeset
|
241 |
213 | 242 $desc =~ s/\\n/\n/g; # insert fake line ends |
243 $desc =~ s/([^\"])\".*$/$1/; # chop everything after final '"' | |
244 $desc =~ s/\\\"/\"/; # convert \"; XXX FIXME XXX \\" | |
1112
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
245 # print " description: $desc"; |
213 | 246 |
247 # register the function with a brief description | |
2168
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
248 register_function($function,$desc,$f,0); |
213 | 249 } |
250 close (IN); | |
251 } else { | |
252 print STDERR "Could not open file ($f): $!\n"; | |
253 } | |
254 } | |
255 | |
264 | 256 # grab help from m-files (octave-forge and octave) |
213 | 257 foreach my $f ( @m_files ) { |
258 my $desc = extract_description($f); | |
259 my $function = basename($f, ('.m')); | |
260 die "Null function?? [$f]\n" unless $function; | |
2168
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
261 register_function($function,$desc,$f,0); |
213 | 262 } |
263 | |
264 | 264 # grab help from octave's DOCSTRINGS |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
265 if ( !$include_octave ) { |
278
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
266 # skip DOCSTRINGS if just summary |
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
267 } |
213 | 268 else { |
2168
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
269 |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
270 if (open (IN,"$OCTAVE/src/DOCSTRINGS")) { |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
271 process_docstrings(); |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
272 } else { |
213 | 273 print STDERR "could not open $OCTAVE/src/DOCSTRINGS !\n"; |
2168
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
274 } |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
275 if (open (IN,"$OCTAVE/scripts/DOCSTRINGS")) { |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
276 process_docstrings(); |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
277 } else { |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
278 print STDERR "could not open $OCTAVE/scripts/DOCSTRINGS !\n"; |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
279 } |
213 | 280 } |
281 | |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
282 # Desperate last measure. Try help <func> within octave. Good for getting |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
283 # keyword and operator descriptions |
1776
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
284 print "Perl hacker: please make the following faster\n"; |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
285 # XXX FIXME XXX, we shouldn't respawn a new octave process each time !!! |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
286 foreach my $TB ( toolbox_list()) { |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
287 foreach my $cat ( cat_list($TB) ) { |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
288 foreach my $func ( cat_funcs($TB,$cat) ) { |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
289 if (! defined $function_description{$func}[1] && ! defined $index_notes{$func} ) { |
1776
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
290 open3(*Writer, *Reader, *Errer, $OCTAVECMD) or die "Could not run octave"; |
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
291 print Writer $OCTAVEINIT; |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
292 print Writer "help $func; 1"; close(Writer); |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
293 my @lines = <Reader>; close(Reader); |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
294 my @err = <Errer>; close(Errer); |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
295 waitpid(-1,&WNOHANG); |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
296 |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
297 # Display errors, if any |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
298 if (@err) { |
1776
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
299 print "help $func\n>>> @err"; |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
300 } else { |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
301 my $body = join("",@lines); |
2140
63b242a71651
make octave versions of function precede octave-forge versions. Some fixes to indexing
adb014
parents:
2000
diff
changeset
|
302 if ($body =~ /help: `(.*)' not found/ || $body =~ /help: sorry,/) { |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
303 # do nothing |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
304 } else { |
1776
c96e26aa8fd0
Allow preinstalled octave to fill in missing function definitions.
pkienzle
parents:
1770
diff
changeset
|
305 print "help $func\n"; |
2000
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
306 |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
307 my $start; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
308 if ($body =~ /^\n\*\*\*/) { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
309 # clipping assuming ops/keywords only |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
310 $start = index($body,"$func") + 1 + length($func); |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
311 } else { |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
312 # first lines till \n\n will be octave tell us the type |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
313 # of variable/funtion and where it is found |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
314 $start = index($body,"\n\n") + 2; |
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
315 } |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
316 my $stop = index($body,"ans ="); |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
317 $body = substr($body,$start,$stop-$start); |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
318 register_function($func,$body,$OCTAVE,0); |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
319 } |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
320 } |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
321 } |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
322 } |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
323 } |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
324 } |
278
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
325 |
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
326 # print a summary table rather than generating the html |
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
327 if ( $summary ) { |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
328 write_ascii("% "); |
278
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
329 } |
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
330 else { |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
331 write_html(); |
278
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
332 } |
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
333 |
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
334 |
282 | 335 if (@skipped) { |
336 print "skipped ", scalar(@skipped), " functions "; | |
337 my $rs = $,; $, = "\n "; | |
338 print " ", sort(@skipped); $, = $rs; | |
339 print "\n"; | |
340 } | |
278
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
341 |
710
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
342 print_missing(); |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
343 |
213 | 344 if (@uncategorized) { |
280 | 345 print scalar(@uncategorized), " uncategorized functions "; |
346 print "(out of ", $n_functions, " total)"; | |
347 my $rs = $,; $, = "\n "; | |
348 print " ", sort(@uncategorized); $, = $rs; | |
225 | 349 print "\n"; |
224 | 350 # print wrap("\t", "\t", join(" ", sort @uncategorized)), "\n"; |
213 | 351 } |
352 | |
329 | 353 if (@shadowed) { |
354 print "unexpected shadowing of ", scalar(@shadowed), " Octave functions"; | |
355 my $rs = $,; $, = "\n "; | |
356 print " ", sort(@shadowed); $, = $rs; | |
357 print "\n"; | |
358 # print wrap("\t", "\t", join(" ", sort @shadowed)), "\n"; | |
359 } | |
360 | |
2168
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
361 sub process_docstrings { |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
362 my $function = ""; |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
363 my $desc = ""; |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
364 while (<IN>) { |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
365 if (/^\037/) { |
2606
54054a31a45e
Only treat DOCSTRING entry if we haven't already found the function
adb014
parents:
2599
diff
changeset
|
366 if ($n_appearances{$function} == 0) { |
54054a31a45e
Only treat DOCSTRING entry if we haven't already found the function
adb014
parents:
2599
diff
changeset
|
367 register_function($function,$desc,$OCTAVE,1) unless $function eq ""; |
54054a31a45e
Only treat DOCSTRING entry if we haven't already found the function
adb014
parents:
2599
diff
changeset
|
368 } |
2168
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
369 $function = $_; |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
370 $function =~ s/^\037//; |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
371 $function =~ s/\n$//; |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
372 $desc = ""; |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
373 } else { |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
374 $desc .= $_; |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
375 } |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
376 } |
2606
54054a31a45e
Only treat DOCSTRING entry if we haven't already found the function
adb014
parents:
2599
diff
changeset
|
377 if ($n_appearances{$function} == 0) { |
54054a31a45e
Only treat DOCSTRING entry if we haven't already found the function
adb014
parents:
2599
diff
changeset
|
378 register_function($function,$desc,$OCTAVE,1) unless $function eq ""; |
54054a31a45e
Only treat DOCSTRING entry if we haven't already found the function
adb014
parents:
2599
diff
changeset
|
379 } |
2168
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
380 close(IN); |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
381 } |
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
382 |
213 | 383 sub first_sentence { # {{{1 |
384 # grab the first real sentence from the function documentation | |
385 my ($desc) = @_; | |
386 my $retval = ''; | |
387 my $line; | |
388 my $next; | |
389 my @lines; | |
390 | |
267 | 391 my $trace = 0; |
392 # $trace = 1 if $desc =~ /Levenberg/; | |
213 | 393 return "" unless defined $desc; |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
394 if ($desc =~ /^\s*-[*]- texinfo -[*]-/) { |
267 | 395 |
396 # help text contains texinfo. Strip the indicator and run it | |
397 # through makeinfo. (XXX FIXME XXX this needs to be a function) | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
398 $desc =~ s/^\s*-[*]- texinfo -[*]-\s*//; |
329 | 399 my $cmd = "makeinfo --fill-column 1600 --no-warn --no-validate --no-headers --force --ifinfo"; |
267 | 400 open3(*Writer, *Reader, *Errer, $cmd) or die "Could not run info"; |
213 | 401 print Writer "\@macro seealso {args}\n\n\@noindent\nSee also: \\args\\.\n\@end macro\n"; |
402 print Writer "$desc"; close(Writer); | |
403 @lines = <Reader>; close(Reader); | |
267 | 404 my @err = <Errer>; close(Errer); |
224 | 405 waitpid(-1,&WNOHANG); |
267 | 406 |
407 # Display source and errors, if any | |
408 if (@err) { | |
409 my $n = 1; | |
410 foreach $line ( split(/\n/,$desc) ) { | |
411 printf "%2d: %s\n",$n++,$line; | |
412 } | |
413 print ">>> @err"; | |
414 } | |
415 | |
416 # Print trace showing formatted output | |
213 | 417 # print "<texinfo--------------------------------\n"; |
418 # print @lines; | |
419 # print "--------------------------------texinfo>\n"; | |
267 | 420 |
421 # Skip prototype and blank lines | |
213 | 422 while (1) { |
267 | 423 return "" unless @lines; |
213 | 424 $line = shift @lines; |
425 next if $line =~ /^\s*-/; | |
237 | 426 next if $line =~ /^\s*$/; |
213 | 427 last; |
428 } | |
267 | 429 |
213 | 430 } else { |
267 | 431 |
213 | 432 # print "<plain--------------------------------\n"; |
267 | 433 # print $desc; |
213 | 434 # print "--------------------------------plain>\n"; |
267 | 435 |
436 # Skip prototype and blank lines | |
437 @lines = split(/\n/,$desc); | |
213 | 438 while (1) { |
439 return "" if ($#lines < 0); | |
440 $line = shift @lines; | |
267 | 441 next if $line =~ /^\s*[Uu][Ss][Aa][Gg][Ee]/; # skip " usage " |
2000
1ce8e644c3a9
allow help as only a macro. ignore first lines when calling octave help
adb014
parents:
1985
diff
changeset
|
442 next if $line =~ /^\s*-/; # skip " -- blah" |
267 | 443 |
444 $line =~ s/^\s*\w+\s*://; # chop " blah : " | |
445 print "strip blah: $line\n" if $trace; | |
446 $line =~ s/^\s*[Ff]unction\s+//; # chop " function " | |
447 print "strip function $line\n" if $trace; | |
448 $line =~ s/^\s*\[.*\]\s*=\s*//; # chop " [a,b] = " | |
449 print "strip []= $line\n" if $trace; | |
450 $line =~ s/^\s*\w+\s*=\s*//; # chop " a = " | |
451 print "strip a= $line\n" if $trace; | |
452 $line =~ s/^\s*\w+\s*\([^\)]*\)\s*//; # chop " f(x) " | |
453 print "strip f(x) $line\n" if $trace; | |
454 $line =~ s/^\s*[;:]\s*//; # chop " ; " | |
455 print "strip ; $line\n" if $trace; | |
456 | |
457 $line =~ s/^\s*[[:upper:]][[:upper:]0-9_]+//; # chop " BLAH" | |
458 print "strip BLAH $line\n" if $trace; | |
459 $line =~ s/^\s*\w*\s*[-]+\s+//; # chop " blah --- " | |
460 print "strip blah --- $line\n" if $trace; | |
461 $line =~ s/^\s*\w+ *\t\s*//; # chop " blah <TAB> " | |
462 print "strip blah <TAB> $line\n" if $trace; | |
463 $line =~ s/^\s*\w+\s\s+//; # chop " blah " | |
464 print "strip blah <NL> $line\n" if $trace; | |
465 | |
466 # next if $line =~ /^\s*\[/; # skip [a,b] = f(x) | |
467 # next if $line =~ /^\s*\w+\s*(=|\()/; # skip a = f(x) OR f(x) | |
468 next if $line =~ /^\s*or\s*$/; # skip blah \n or \n blah | |
213 | 469 next if $line =~ /^\s*$/; # skip blank line |
267 | 470 next if $line =~ /^\s?!\//; # skip # !/usr/bin/octave |
213 | 471 # XXX FIXME XXX should be testing for unmatched () in proto |
472 # before going to the next line! | |
473 last; | |
474 } | |
475 } | |
476 | |
267 | 477 # Try to make a complete sentence, including the '.' |
478 if ( "$line " !~ /[^.][.]\s/ && $#lines >= 0) { | |
213 | 479 my $next = $lines[0]; |
480 $line =~ s/\s*$//; # trim trailing blanks on last | |
481 $next =~ s/^\s*//; # trim leading blanks on next | |
267 | 482 $line .= " $next" if "$next " =~ /[^.][.]\s/; # ends the sentence |
213 | 483 } |
267 | 484 |
485 # Tidy up the sentence. | |
213 | 486 chomp $line; # trim trailing newline, if there is one |
267 | 487 $line =~ s/^\s*//; # trim leading blanks on line |
488 $line =~ s/([^.][.])\s.*$/$1/; # trim everything after the sentence | |
213 | 489 print "Skipping:\n$desc---\n" if $line eq ""; |
267 | 490 |
491 # And return it. | |
213 | 492 return $line; |
267 | 493 |
213 | 494 } # 1}}} |
329 | 495 sub shadow_path { # {{{1 |
496 # shadow_path($f) returns true if $f is on a known Octave shadow path | |
497 my ($file) = @_; | |
498 $file =~ s|/[^/]*$||; | |
499 my @matches = grep(/^$file$/,@shadow_paths); | |
500 # print "looking for $file in @shadow_paths\n"; | |
501 # print "returns ",@matches,"\n"; | |
1112
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
502 return scalar(@matches) > 0 || $file =~ /alternatives$/; |
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
503 |
329 | 504 } # 1}}} |
213 | 505 sub register_function { # {{{1 |
506 # register the function and its one-line description | |
507 my ($function, # in $index{toolbox}{category} = [functions] | |
508 $desc, # in $toolbox_desc{toolbox} = description | |
224 | 509 $file, |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
510 $replace_shadow, |
213 | 511 ) = @_; |
512 ++$n_appearances{$function}; | |
513 if ($n_appearances{$function} > 1) { | |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
514 if ($replace_shadow != 0) { |
2168
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
515 push @shadowed, "$file:$function" if $file =~ /^$OCTAVE/ |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
516 and !shadow_path($function_description{$function}[0]); |
2168
9e2e3714b627
Better reporting of shadowed functions; better support for DOCSTRINGS
pkienzle
parents:
2140
diff
changeset
|
517 # print "$file:$function appeared previously\n"; |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
518 } |
224 | 519 } else { |
520 ++$n_functions; | |
213 | 521 } |
2666
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
522 if (! ($file =~ /^$OCTAVE/)) { |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
523 $octave_forge_function{$function} = 1; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
524 my $package = $file; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
525 $package =~ s|^\s*([^/]+/[^/]+/).*$|$1|; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
526 if ($package =~ /^\s*$/) { |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
527 printf("%-12s %-20s %s\n", $function, $file, $package); |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
528 } |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
529 push @{$index_by_package{$package}}, $function; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
530 } |
264 | 531 if (!defined $index_by_function{$function}) { |
282 | 532 my $entry = $file; |
533 $entry = "$file: $function" if $file !~ /[.]m$/; | |
534 if ($function =~ /__/ || $file =~ /test/ | |
2580
211c0aebba29
Start fixing the main INDEX file and making a clearer split with the octave core functions
adb014
parents:
2512
diff
changeset
|
535 || $function =~ /^[Cc]ontents?$/ |
211c0aebba29
Start fixing the main INDEX file and making a clearer split with the octave core functions
adb014
parents:
2512
diff
changeset
|
536 || $function =~ /pre_install/ || $function =~ /post_install/) { |
282 | 537 push @skipped, $entry; |
538 } else { | |
539 push @uncategorized, $entry; | |
280 | 540 } |
213 | 541 } |
264 | 542 |
543 my $oneline = first_sentence($desc); | |
278
042ee9410f80
Summary of the current directory if not run from the root
pkienzle
parents:
267
diff
changeset
|
544 #printf "%30s %s\n", $function, $oneline; |
1759
ffb76ce36061
Don't replace help text for existing functions. That is help of *.cc versions preferred to *.m versions (cf dispatch)
adb014
parents:
1756
diff
changeset
|
545 if ($replace_shadow == 0 && defined @function_description{$function}) { |
ffb76ce36061
Don't replace help text for existing functions. That is help of *.cc versions preferred to *.m versions (cf dispatch)
adb014
parents:
1756
diff
changeset
|
546 @function_description{$function} = [ $function_description{$function}[0], $oneline, $desc ]; |
ffb76ce36061
Don't replace help text for existing functions. That is help of *.cc versions preferred to *.m versions (cf dispatch)
adb014
parents:
1756
diff
changeset
|
547 } elsif (!defined @function_description{$function}) { |
1756
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
548 @function_description{$function} = [ $file, $oneline, $desc ]; |
10090d51b02a
Update make_index to check for DEFCONST, also use DOCSTRINGS for text of help even if function is found elsewhere to allow for help string defined as macros, and call help in octave to find operators and keywords
adb014
parents:
1755
diff
changeset
|
549 } |
267 | 550 # push @function_description{$function}}, "$file\n$oneline\n$desc"; |
264 | 551 #printf "%-12s %-20s %s\n", $function, |
552 # $index_by_function{$function}[0], | |
553 # $index_by_function{$function}[1]; | |
213 | 554 } # 1}}} |
555 sub extract_description { # {{{1 | |
556 # grab the entire documentation comment from an m-file | |
557 my ($file) = @_; | |
558 my $retval = ''; | |
264 | 559 |
213 | 560 if( open( IN, "$file")) { |
561 # skip leading blank lines | |
562 while (<IN>) { | |
563 last if /\S/; | |
564 } | |
565 if( m/\s*[%\#][\s\#%]* Copyright/) { | |
566 # next block is copyright statement, skip it | |
567 while (<IN>) { | |
568 last unless /^\s*[%\#]/; | |
569 } | |
570 } | |
267 | 571 # Skip everything until the next comment block |
572 while ( !/^\s*[\#%]/ ) { | |
213 | 573 $_ = <IN>; |
574 last if not defined $_; | |
575 } | |
267 | 576 # Return the next comment block as the documentation |
577 while (/^\s*[\#%]/) { | |
213 | 578 s/^[\s%\#]*//; # strip leading comment characters |
579 s/[\cM\s]*$//; # strip trailing spaces. | |
580 $retval .= "$_\n"; | |
267 | 581 $_ = <IN>; |
582 last if not defined $_; | |
213 | 583 } |
584 close(IN); | |
585 return $retval; | |
586 } | |
587 else { | |
588 print STDERR "Could not open file ($file): $!\n"; | |
589 } | |
590 } # 1}}} | |
591 sub load_index { # {{{1 | |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
592 my ($file) = @_; # in |
265
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
593 my $toolbox = "extra"; |
213 | 594 my $category = ""; |
595 my $description = ""; | |
596 my $function = ""; | |
597 open(IN, $file) or die "Cannot read $file: $!\n"; | |
264 | 598 my %map; # simple macros for use in notes |
599 while (<IN>) { | |
213 | 600 next if /^\s*$/; # skip blank lines |
225 | 601 next if /^\s*\#/; # skip comment lines |
213 | 602 chomp; |
603 if (/^(.*?)\s*>>\s*(.*?)$/) { | |
234
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
604 # toolbox lines contain "word >> description" |
213 | 605 $toolbox = $1; |
606 $description = $2; | |
607 $category = ""; | |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
608 $TB_description{$toolbox} = $description; |
234
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
609 } elsif (/^\s*\$(\w+)\s*=\s*(\S.*\S)\s*$/) { |
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
610 # define a variable as "$var = expansion" |
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
611 $map{$1} = $2; |
213 | 612 } elsif (/^(\w.*?)\s*$/) { |
234
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
613 # category lines start in the left most column |
213 | 614 $category = $1; |
1755 | 615 } elsif (/^\s+(\S.*[^=~!><])=\s*(\S.*\S)\s*$/) { |
880
391d6cb29a47
fix single character " x = description" INDEX entries
pkienzle
parents:
876
diff
changeset
|
616 # Process "function = notes" explicit descriptions |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
617 $function = $1; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
618 $description = $2; |
234
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
619 |
880
391d6cb29a47
fix single character " x = description" INDEX entries
pkienzle
parents:
876
diff
changeset
|
620 # We used ...(\S.*)=... rather than (\S.*\S)\s*= to allow for |
391d6cb29a47
fix single character " x = description" INDEX entries
pkienzle
parents:
876
diff
changeset
|
621 # single character function names, but that means we may have |
391d6cb29a47
fix single character " x = description" INDEX entries
pkienzle
parents:
876
diff
changeset
|
622 # to trim some extra spaces of the function name. Single |
391d6cb29a47
fix single character " x = description" INDEX entries
pkienzle
parents:
876
diff
changeset
|
623 # character descriptions get the treatment they deserve. |
391d6cb29a47
fix single character " x = description" INDEX entries
pkienzle
parents:
876
diff
changeset
|
624 $function =~ s/\s+$//; |
391d6cb29a47
fix single character " x = description" INDEX entries
pkienzle
parents:
876
diff
changeset
|
625 |
391d6cb29a47
fix single character " x = description" INDEX entries
pkienzle
parents:
876
diff
changeset
|
626 # expand all $var in the description |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
627 my @parts = split('\$', $description); |
234
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
628 foreach my $i ( 1 .. $#parts ) { |
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
629 $parts[$i] =~ /^(\w+)(\W.*)$/ or $parts[$i] =~ /^(\w+)()$/; |
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
630 $parts[$i] = "$map{$1}$2"; |
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
631 } |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
632 $description = join("",@parts); |
264 | 633 |
880
391d6cb29a47
fix single character " x = description" INDEX entries
pkienzle
parents:
876
diff
changeset
|
634 # record the function->description mapping |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
635 $index_notes{$function} = $description; |
234
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
636 die "Function $function (line $.) has no category" unless $category; |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
637 push @{$index_by_TB_cat{$toolbox}{$category}}, $function; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
638 push @{$index_by_function{$function}}, [$toolbox, $category]; |
234
e331450e76fd
pass 3: allows function descirptions in the index file.
pkienzle
parents:
225
diff
changeset
|
639 } else { |
224 | 640 s/^\s+//; |
641 my @list = split /\s+/; | |
642 while ($#list >= 0) { | |
643 $function = shift @list; | |
644 die "Function $function (line $.) has no category" unless $category; | |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
645 push @{$index_by_TB_cat{$toolbox}{$category}}, $function; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
646 push @{$index_by_function{$function}}, [$toolbox, $category]; |
264 | 647 |
224 | 648 } |
213 | 649 } |
650 } | |
651 close(IN); | |
652 } # 1}}} | |
653 sub write_html { # {{{1 | |
265
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
654 # make empty html directories |
1475
4602d2d9b1f8
Windows/OS X have case-insensitive file names, so move INDEX out of the
pkienzle
parents:
1430
diff
changeset
|
655 unlink <$catdir/*.html>; |
4602d2d9b1f8
Windows/OS X have case-insensitive file names, so move INDEX out of the
pkienzle
parents:
1430
diff
changeset
|
656 unlink <$catdir/f/*.html>; |
4602d2d9b1f8
Windows/OS X have case-insensitive file names, so move INDEX out of the
pkienzle
parents:
1430
diff
changeset
|
657 mkdir "$catdir"; |
4602d2d9b1f8
Windows/OS X have case-insensitive file names, so move INDEX out of the
pkienzle
parents:
1430
diff
changeset
|
658 mkdir "$catdir/f"; |
265
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
659 |
2487 | 660 #write_main(); |
661 #write_forgebar(); | |
662 write_index(); | |
296 | 663 write_alphabetic_navbar(); |
664 write_TBnavbar(); | |
665 foreach ( toolbox_list() ) { | |
2487 | 666 #write_TBnavbar($_); |
296 | 667 write_TBdetails($_); |
668 } | |
2666
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
669 foreach ( package_list() ) { |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
670 write_package_details($_); |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
671 } |
296 | 672 |
673 # Write one file for each letter. | |
674 # | |
675 | |
676 my $Letter = chr(0); | |
677 foreach my $func ( indexed_funcs() ) { | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
678 # The source file |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
679 |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
680 my $body = long_desc($func); |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
681 if ($body ne "") { |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
682 # XXX FIXME XXX this will die if the punctuation is too wild |
2487 | 683 open FUNC, ">$catdir/f/$func.in" or die "Could not open $func.in"; |
684 print FUNC "__DOC_HEADER__([[[Function Reference: $func]]])"; | |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
685 print FUNC "<table width=100%><tr><td align=left><b>$func</b>\n"; |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
686 # The toolboxes to which it belongs |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
687 foreach my $pair ( @{$index_by_function{$func}} ) { |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
688 my ( $TB, $cat ) = @{$pair}; |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
689 print FUNC " ", cat_ref_up($TB, $cat, "[$TB]"), "\n"; |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
690 } |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
691 print FUNC " <td align=right>", download_ref($func), "</table>\n"; |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
692 print FUNC "$body\n"; |
2487 | 693 print FUNC "__TRAILER__"; |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
694 close FUNC; |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
695 } |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
696 |
296 | 697 # Check if need to go to the next letter |
698 # This is particularly complicated because we | |
699 # want to include all punctuation in the | |
700 my $next = uc(substr($func, 0, 1)); | |
701 if ($next ne $Letter) { | |
702 if ($Letter =~ /[A-Y]/) { | |
2487 | 703 print OUT "</dl>\n__TRAILER__\n"; |
296 | 704 close OUT; |
705 } else { | |
706 print OUT "</dl>\n"; | |
707 } | |
708 if ($Letter =~ /[\0A-Y]/) { | |
709 my $head = ""; | |
710 if ( $next =~ /[A-Z]/ ) { | |
711 $head = $next; | |
712 } elsif ( $next lt "A" ) { | |
713 $head = "A"; | |
714 } else { | |
715 $head = "Z"; | |
716 } | |
2487 | 717 my $file = ">$catdir/$head.in"; |
296 | 718 open(OUT, $file) or die "Cannot write $file"; |
2487 | 719 print OUT "__DOC_HEADER__([[[Function Reference: $head]]])"; |
296 | 720 } |
721 $Letter = $next; | |
2487 | 722 print OUT "<h2><a name=\"$Letter\">$Letter</a></h2>\n"; |
296 | 723 print OUT "<dl>\n"; |
724 } | |
725 | |
726 # Function reference | |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
727 print OUT "<dt><table width=100%><tr><td align=left><b>",func_ref($func,$func),"</b>\n"; |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
728 # The toolboxes to which it belongs |
296 | 729 foreach my $pair ( @{$index_by_function{$func}} ) { |
730 my ( $TB, $cat ) = @{$pair}; | |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
731 print OUT " ", cat_ref($TB, $cat, "[$TB]"), "\n"; |
296 | 732 } |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
733 print OUT " <td align=right>", download_ref($func), "</table>\n"; |
296 | 734 |
735 | |
736 # column 3: the function description | |
737 # XXX FIXME XXX multiple functions??? | |
738 print OUT " <dd>",html_desc($func),"\n"; | |
739 } | |
740 | |
2487 | 741 print OUT "</dl>\n__TRAILER__\n"; |
296 | 742 close(OUT); |
743 } # 1}}} | |
744 sub writenav { # 1{{{ | |
745 my ($cat) = @_; | |
746 | |
747 } # 1}}} | |
748 sub write_main { # {{{1 | |
1475
4602d2d9b1f8
Windows/OS X have case-insensitive file names, so move INDEX out of the
pkienzle
parents:
1430
diff
changeset
|
749 open(OUT,">$catdir/index.html") or die "Could not open $catdir/index.html"; |
296 | 750 print OUT <<EOF; |
751 <HTML><HEAD> | |
752 <TITLE>Octave-forge combined index</TITLE> | |
753 </HEAD> | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
754 <FRAMESET rows="50, *"> |
296 | 755 <FRAME src="forgebar.html" noresize frameborder="0"> |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
756 <FRAMESET cols="33%, 67%"> |
296 | 757 <FRAME name=navbar src="categorical.html"> |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
758 <FRAMESET rows="50, *"> |
296 | 759 <FRAME src="alphabetic.html"> |
760 <FRAME name=content src="intro.html"> | |
761 </FRAMESET> | |
762 </FRAMESET> | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
763 <NOFRAMES> |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
764 $forgebar |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
765 <H1>Octave-Forge Combined Index</H1> |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
766 <ul> |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
767 <li><A HREF="categorical.html">Categorical index</a> |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
768 <li><A HREF="alphabetic.html">Alphabetic index</a> |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
769 </ul> |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
770 </NOFRAMES> |
296 | 771 </FRAMESET> |
772 </HTML> | |
773 EOF | |
774 close OUT; | |
775 } # 1}}} | |
776 sub write_forgebar { | |
1475
4602d2d9b1f8
Windows/OS X have case-insensitive file names, so move INDEX out of the
pkienzle
parents:
1430
diff
changeset
|
777 open(OUT,">$catdir/forgebar.html") or die "Could not open index/forgebar.html"; |
296 | 778 print OUT <<EOF; |
779 <html><title>Octave Forge site navigator</title> | |
780 <base target=_top> | |
781 <body> | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
782 $forgebar |
296 | 783 </body></html> |
784 EOF | |
785 } | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
786 sub download_ref { |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
787 # download_ref($func,$desc) returns a link to download $func described by $desc |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
788 my ($func) = @_; |
296 | 789 |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
790 my $path = $function_description{$func}[0]; |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
791 if ($path ne "" && $path !~ /^$OCTAVE/) { |
1112
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
792 return "[<a href=\"$FORGECVS$path\?rev=HEAD\&content-type=text/plain\">octave-forge/$path</a>]"; |
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
793 } elsif ($path =~ /^$OCTAVE/) { |
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
794 $path =~ s/^$OCTAVE//; |
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
795 return "[<a href=\"$OCTAVECVS$path\?rev=HEAD\&content-type=text/plain\">octave$path</a>]"; |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
796 } else { |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
797 return ""; |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
798 } |
296 | 799 } |
2487 | 800 sub write_index { # 1{{{ |
801 open(OUT,">$catdir/index.in") or die "Could not open $catdir/index.in"; | |
296 | 802 print OUT <<EOF; |
2487 | 803 __DOC_HEADER__([[[Function Reference]]]) |
804 <p>This page contains the documentation for individual functions provided by | |
2512
b517790ca56e
The text on the function reference main page corresponds to the new drop-down menus
hauberg
parents:
2511
diff
changeset
|
805 Octave and Octave-Forge. The documentation can either be accessed by category or alphabetically. |
b517790ca56e
The text on the function reference main page corresponds to the new drop-down menus
hauberg
parents:
2511
diff
changeset
|
806 Simply use the drop-down menus at the top of the page.</p> |
2487 | 807 __TRAILER__ |
296 | 808 EOF |
809 close OUT; | |
810 } # 1}}} | |
811 sub write_TBnavbar { # 1{{{ | |
812 my $openTB = shift; | |
2487 | 813 my $file = "menu"; |
296 | 814 $file = "nav$openTB" if $openTB ne ""; |
2487 | 815 open(OUT,">$catdir/$file.include") or die "Could not open $catdir/$file.include"; |
816 | |
2511
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
817 #print OUT "<a href=\"__BASE_ADDRESS__/index.html\">Home</a>\n"; |
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
818 print OUT "<select name=\"dropdowncat\" size=\"1\" onChange=\"javascript:goto_url(docform.dropdowncat.value)\">\n"; |
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
819 print OUT "<option value=\"-1\">Categories</option>\n"; |
2487 | 820 |
2676
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
821 foreach my $TB (toolbox_list_sorted_by_desc()) { |
2511
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
822 print OUT "<option value=\"__BASE_ADDRESS__/doc/$TB.html\">$TB_description{$TB}</option>\n"; |
296 | 823 } |
2511
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
824 print OUT "</select>\n"; |
296 | 825 close OUT; |
826 } # 1}}} | |
827 sub write_TBdetails { # 1{{{ | |
828 my $TB = shift; | |
2487 | 829 my $file = "$catdir/$TB.in"; |
296 | 830 |
831 open(OUT, ">$file") or die "Cannot write $file: $!\n"; | |
832 print OUT <<EOF; | |
2487 | 833 __DOC_HEADER__([[[$TB]]]) |
834 <h2>$TB_description{$TB}</h2> | |
296 | 835 EOF |
836 | |
837 # summary list of categories | |
838 print OUT "<ul>\n"; | |
839 foreach my $cat ( cat_list($TB) ) { | |
840 my $anchor = cat_anchor($cat); | |
841 print OUT " <li><a href=\"#$anchor\">$cat</a></li>\n"; | |
842 } | |
843 print OUT "</ul>\n"; | |
844 | |
845 # Each category has a table of its functions and their descriptions. | |
846 foreach my $cat ( cat_list($TB) ) { | |
847 my $anchor = cat_anchor($cat); | |
2487 | 848 print OUT "<h3><a name=\"$anchor\">$cat</a></h3>\n"; |
296 | 849 print OUT "<dl>\n"; |
850 foreach my $func ( cat_funcs($TB,$cat) ) { | |
851 | |
852 # column 1: the function (x-ref to full description in | |
853 # cvs-tree's html file) | |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
854 print OUT "<dt><table width=100%><tr><td align=left><b>",func_ref($func,$func),"</b>\n"; |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
855 print OUT " <td align=right>", download_ref($func), "</table>\n"; |
296 | 856 |
857 # column 2: the description, if it exists | |
858 # | |
859 print OUT "<dd>",html_desc($func),"\n"; | |
860 } | |
861 print OUT "</dl>\n"; | |
862 } | |
2487 | 863 print OUT "__TRAILER__\n"; |
296 | 864 close(OUT); |
865 } # 1}}} | |
2666
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
866 sub write_package_details { # 1{{{ |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
867 my $packdir = shift; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
868 my $package; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
869 my $title; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
870 my $desc = sprintf("%s/DESCRIPTION", $packdir); |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
871 open(IN, $desc) or die "Cannot read $desc: $!\n"; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
872 while(<IN>) { |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
873 if (/^[Nn]ame:/) { |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
874 chomp; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
875 s/^[Nn]ame:\s*//; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
876 s/\s*$//; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
877 $package = lc($_); |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
878 } elsif (/^[Tt]itle:/) { |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
879 chomp; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
880 s/^[Tt]itle:\s*//; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
881 s/\s*$//; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
882 $title = $_; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
883 } |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
884 } |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
885 close(IN); |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
886 my $file = "$catdir/funref_$package.in"; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
887 |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
888 open(OUT, ">$file") or die "Cannot write $file: $!\n"; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
889 print OUT <<EOF; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
890 __HEADER__([[[$title]]]) |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
891 EOF |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
892 print OUT "<dl>\n"; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
893 foreach my $func ( pack_list($packdir) ) { |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
894 |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
895 # column 1: the function (x-ref to full description in |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
896 # cvs-tree's html file) |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
897 print OUT "<dt><table width=100%><tr><td align=left><b>",func_ref($func,$func),"</b>\n"; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
898 print OUT " <td align=right>", download_ref($func), "</table>\n"; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
899 |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
900 # column 2: the description, if it exists |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
901 # |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
902 print OUT "<dd>",html_desc($func),"\n"; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
903 } |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
904 print OUT "</dl>\n"; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
905 print OUT "__TRAILER__\n"; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
906 close(OUT); |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
907 } # 1}}} |
296 | 908 sub write_alphabetic_navbar { # 1{{{ |
2487 | 909 open(OUT,">$catdir/alphabetic.include") or die "Could not open $catdir/alphabetic.include"; |
910 | |
296 | 911 my $A_to_Z = ""; |
912 foreach (first_letters (indexed_funcs())) { | |
2511
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
913 $A_to_Z .= letter_option($_) . "\n"; |
296 | 914 } |
2511
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
915 my $select = "<select name=\"dropdownalpha\" size=\"1\" onChange=\"javascript:goto_url(docform.dropdownalpha.value)\">"; |
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
916 $select .= "\n<option value=\"-1\">Alphabetical</option>\n"; |
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
917 print OUT $select . $A_to_Z . "\n</select>\n"; |
296 | 918 close OUT; |
919 } # 1}}} | |
920 sub oldnavbar { # 1{{{ | |
921 my $max_TB_across_top = 7; | |
922 my $all_toolboxes = "<center>\n"; | |
923 my $n = 0; | |
265
e49d918cb803
Split main.idx into individual subdirectories to make it more manageable
pkienzle
parents:
264
diff
changeset
|
924 |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
925 foreach my $TB (toolbox_list()) { |
213 | 926 ++$n; |
927 if ($n > $max_TB_across_top) { | |
928 $n = 0; | |
929 $all_toolboxes .= "<a href=\"$TB.html\">$TB</a> <br> "; | |
930 } else { | |
931 $all_toolboxes .= "<a href=\"$TB.html\">$TB</a> | "; | |
932 } | |
933 } | |
934 $all_toolboxes =~ s/\s+\|\s*$//; # strip last pipe separator | |
935 $all_toolboxes .= "<br><br>"; | |
936 my $A_to_Z = ""; | |
296 | 937 foreach (first_letters (indexed_funcs())) { |
938 $A_to_Z .= letter_ref($_); | |
939 $A_to_Z .= " | "; | |
213 | 940 } |
941 $A_to_Z =~ s/\s+\|\s*$//; # strip last pipe separator | |
942 my $all_toolboxes_A_Z = $all_toolboxes . "$A_to_Z </center>\n"; | |
943 $all_toolboxes .= "</center>\n"; | |
264 | 944 |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
945 } # 1}}} |
710
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
946 sub print_missing { |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
947 my $printmissing = 1; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
948 foreach my $TB ( toolbox_list() ) { |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
949 my $printTB = 1; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
950 foreach my $cat ( cat_list($TB) ) { |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
951 my $printcat = 1; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
952 foreach my $func ( cat_funcs($TB,$cat) ) { |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
953 if (! defined $function_description{$func}[1] && ! defined $index_notes{$func} ) { |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
954 print "missing functions:" if $printmissing; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
955 print "\n [$TB]" if $printTB; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
956 print "\n $cat\n >" if $printcat; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
957 print " $func"; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
958 $printTB = 0; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
959 $printcat = 0; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
960 $printmissing = 0; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
961 } |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
962 } |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
963 } |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
964 } |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
965 print "\n" unless $printmissing; |
208ab6af6cb3
List missing and unnoted functions so that INDEX can be checked for extra
pkienzle
parents:
654
diff
changeset
|
966 } |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
967 sub write_ascii { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
968 # output all toolboxes as a contents.m file |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
969 my ($prefix) = @_; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
970 my $indent = 16 - 3 - length($prefix); |
213 | 971 |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
972 # XXX FIXME XXX add an option to spit out contents.m |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
973 # XXX FIXME XXX what if there is no toolbox? |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
974 # XXX FIXME XXX preserve category order |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
975 foreach my $TB ( toolbox_list() ) { |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
976 print wrap($prefix,$prefix,$TB_description{$TB}),"\n$prefix\n"; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
977 foreach my $cat ( cat_list($TB) ) { |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
978 print wrap($prefix,$prefix,$cat), "\n"; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
979 foreach my $func ( cat_funcs($TB,$cat) ) { |
295 | 980 my $entry = sprintf("%-*s %s",$indent,$func,ascii_desc($func)); |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
981 print wrap("$prefix","$prefix\t\t"," $entry"), "\n"; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
982 } |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
983 print "$prefix\n"; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
984 } |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
985 } |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
986 } # 1}}} |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
987 sub cat_ref { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
988 # cat_ref($TB,$cat,$ref) returns an html link to $cat described by $ref |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
989 my ($TB,$cat,$ref) = @_; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
990 my $anchor = cat_anchor($cat); |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
991 return "<a href=\"$TB.html#$anchor\">$ref</a>"; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
992 } # 1}}} |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
993 sub cat_ref_up { # 1{{{ |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
994 # cat_ref($TB,$cat,$ref) returns an html link to $cat described by $ref |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
995 my ($TB,$cat,$ref) = @_; |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
996 my $anchor = cat_anchor($cat); |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
997 return "<a href=\"../$TB.html#$anchor\">$ref</a>"; |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
998 } # 1}}} |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
999 sub cat_anchor { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1000 # cat_anchor($cat) returns the anchor word generated for category $cat |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1001 my ($cat) = @_; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1002 $cat =~ s/\W+//g; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1003 return $cat; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1004 } # 1}}} |
295 | 1005 sub func_ref { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1006 # func_ref($func) returns an html link to $func described by $ref |
295 | 1007 my ($func,$ref) = @_; |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1008 if ( defined $function_description{$func}[2] && |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1009 $function_description{$func}[2] ne "") { |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1010 return "<a href=\"f/$func.html\">$ref</a>"; |
295 | 1011 } elsif ( $ref ne $func ) { |
1012 # XXX FIXME XXX do we want "$ref ($func)"? Check how it is called. | |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1013 return $ref; |
295 | 1014 } else { |
1015 return $ref; | |
1016 } | |
1017 } # 1}}} | |
1018 sub split_long_name { # 1{{{ | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1019 # html magic to break long variable/function names |
296 | 1020 # XXX FIXME XXX this function is probably not used |
295 | 1021 my ( $nicefunc ) = @_; |
1022 # $nicefunc =~ s/([^_])_([^_])/$1_ $2/g; | |
1023 return $nicefunc; | |
1024 } # 1}}} | |
296 | 1025 sub first_letters { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1026 # return a list of all first letters in the arguments |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1027 # The argument list must come sorted with a case-insensitive sort. |
296 | 1028 my $Letter = chr(0); |
1029 my @ret = (); | |
1030 foreach my $name ( @_ ) { | |
1031 # Check if need to go to the next letter | |
1032 if (uc(substr($name, 0, 1)) ne $Letter) { | |
1033 $Letter = uc(substr($name, 0, 1)); | |
1034 push @ret, $Letter; | |
1035 } | |
1036 } | |
1037 return @ret; | |
1038 } # 1}}} | |
1039 sub letter_file { # 1{{{ | |
1040 return "$_.html" if /[A-Z]/; | |
1041 return "A.html" if $_ lt "A"; | |
1042 return "Z.html"; | |
1043 } # 1}}} | |
1044 sub letter_ref { # 1{{{ | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1045 # letter_ref($letter) returns a link to the letter |
296 | 1046 return "<a href=\"" . letter_file($_) . "#$_\">$_</a>"; |
1047 } # 1}}} | |
2511
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
1048 sub letter_option { # 1{{{ |
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
1049 # letter_option($letter) returns a link to the letter |
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
1050 return "<option value=\"__BASE_ADDRESS__/doc/" . letter_file($_) . "#$_\">$_</option>"; |
b0b8a45dc50e
Added a new navigation bar for the function reference
hauberg
parents:
2497
diff
changeset
|
1051 } # 1}}} |
295 | 1052 sub ascii_desc { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1053 # ascii_desc($func) returns a decription of $func using ascii markup |
295 | 1054 my ( $func ) = @_; |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1055 if (! defined $function_description{$func}[1] ) { |
295 | 1056 my $notes = $index_notes{$func}; |
1057 $notes = "<missing>" if $notes eq ""; | |
1058 # convert "<a link>desc</a>" to "desc (link)" | |
1059 $notes =~ s|<a href=\"?([^>]*)\"?>([^<]*)</a>|$2 ($1)|g; | |
1060 # strip all remaining html formatting | |
1061 $notes =~ s|<[^>]*>||g; | |
1062 return $notes; | |
1063 } else { | |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1064 my $desc = $function_description{$func}[1]; |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1065 if ($desc eq "") { |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1066 return "<no description>"; |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1067 } else { |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1068 return $desc; |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1069 } |
295 | 1070 } |
1071 } #}}} | |
1072 sub html_desc { # 1{{{ | |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1073 # html_desc($func) returns a description of $func using html markup |
295 | 1074 my ( $func ) = @_; |
881 | 1075 my $notes = $index_notes{$func}; |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1076 if (! defined $function_description{$func}[1] ) { |
295 | 1077 $notes = "not implemented" if $notes eq ""; |
1078 # shut of the bold italics during "code" formatting | |
296 | 1079 $notes =~ s|<code>|</i><code>|g; |
1080 $notes =~ s|</code>|</code><i>|g; | |
1112
8cae3cf4d756
Transform "use <code>fn</code>" to "use <f>fn</f>", and make it link to fn.
pkienzle
parents:
881
diff
changeset
|
1081 $notes =~ s|<f>(\w+)</f>|</i><code><a href="f/$1.html">$1</a></code><i>|g; |
296 | 1082 return "<i>$notes</i>"; |
295 | 1083 } else { |
881 | 1084 print "ignoring $func = $notes\n" if $notes ne ""; |
301
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1085 my $desc = $function_description{$func}[1]; |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1086 if ($desc eq "") { |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1087 return "<i>no description</i>"; |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1088 } else { |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1089 return $desc; |
b31d50953186
fix "not implemented"; include full path to source; just include toolbox handle
pkienzle
parents:
299
diff
changeset
|
1090 } |
295 | 1091 } |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1092 } # 1}}} |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1093 sub long_desc { |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1094 my ( $func ) = @_; |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1095 my $body = $function_description{$func}[2]; |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1096 if ($body =~ /^\s*-[*]- texinfo -[*]-/) { |
329 | 1097 $body = info2html($func, $body); |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1098 } elsif ($body ne "") { |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1099 $body = "<pre>$body</pre>"; |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1100 } |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1101 return $body |
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1102 } # 1}}} |
329 | 1103 sub info2html_texi2html { # 1{{{ |
1104 # run body through texi2html to produce html | |
1105 my ( $func, $body ) = @_; | |
1106 $body =~ s/^\s*-[*]- texinfo -[*]-//; | |
1107 open(SRC, ">$func.texi"); | |
1108 print SRC "\@macro seealso {args}\n\n\@noindent\nSee also: \\args\\.\n\@end macro\n"; | |
1109 print SRC "BEGINCUT $body ENDCUT"; | |
1110 close SRC; | |
1111 system ("texi2html -expand info $tmpdir/$func.texi"); | |
1112 open(SRC, "<$func.html"); | |
1113 my @lines = <SRC>; | |
1114 close SRC; | |
1115 $body = join("",@lines); | |
1116 my $start = index($body,"BEGINCUT") + 8; | |
1117 my $stop = index($body,"ENDCUT"); | |
1118 $body = substr($body,$start,$stop-$start); | |
1119 unlink "$func.texi", "$func.html"; | |
1120 } # 1}}} | |
1121 sub info2html { # 1{{{ | |
1122 # run body through makeinfo to produce html | |
1123 my ( $func, $body ) = @_; | |
1124 $body =~ s/^\s*-[*]- texinfo -[*]-//; | |
876 | 1125 my $cmd = "makeinfo --fill-column 80 --no-warn --no-validate --force --html --ifinfo -o -"; |
329 | 1126 open3(*Writer, *Reader, *Errer, $cmd) or die "Could not run info"; |
2599 | 1127 #SH# print Writer "\@macro seealso {args}\n\n\@noindent\nSee also: \\args\\.\n\@end macro\n"; |
1128 print Writer "\@macro seealso{args}\n m4_changequote(`, ')\n seealso(\\args\\)\n m4_changequote([[[, ]]])\n\@end macro\n"; | |
329 | 1129 # I have no idea why but makeinfo is introducing some weirdness with <p> |
1130 # at the front of the document. The following works for my particular | |
1131 # version but I have little hope for it working in general | |
1132 print Writer "-CUT HERE $body"; close(Writer); | |
1133 my @lines = <Reader>; close(Reader); | |
1134 my @err = <Errer>; close(Errer); | |
1135 waitpid(-1,&WNOHANG); | |
1136 # strip everything before <body> and after </body> | |
1137 $body = join("",@lines); | |
1138 my $start = index($body,"CUT HERE") + 8; | |
1139 my $stop = index($body,"</body"); | |
1140 $body = substr($body,$start,$stop-$start); | |
1141 $body =~ s|\@var\{([^\}]*)\}|<var>$1</var>|g; | |
1142 return $body; | |
1143 } # 1}}} | |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1144 sub toolbox_list { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1145 # toolbox_list() returns an ordered list of toolboxes. |
295 | 1146 return sort { uc($a) cmp uc($b) } keys %index_by_TB_cat; |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1147 } # 1}}} |
2676
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
1148 sub toolbox_list_sorted_by_desc { # 1{{{ |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
1149 # toolbox_list_sorted_by_desc() returns an ordered list of toolboxes. |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
1150 return sort { uc($TB_description{$a}) cmp uc($TB_description{$b}) } keys %index_by_TB_cat; |
019a7290e0fd
Respect NOINSTALL tags when indexing functions. Sort categories alphabetically
adb014
parents:
2666
diff
changeset
|
1151 } # 1}}} |
2666
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
1152 sub package_list { # 1{{{ |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
1153 # package_list() returns an ordered list of package directories. |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
1154 return sort { uc($a) cmp uc($b) } keys %index_by_package; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
1155 } # 1}}} |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1156 sub cat_list { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1157 # cat_list($TB) returns an ordered list of categories in a toolbox $TB. |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1158 my ($TB) = @_; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1159 return sort keys %{$index_by_TB_cat{$TB}}; |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1160 } # 1}}} |
2666
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
1161 sub pack_list { # 1{{{ |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
1162 # pack_list($package) returns an ordered list of functions in a package directory. |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
1163 my ($package) = @_; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
1164 return sort @{$index_by_package{$package}}; |
6548c639892b
Create a seperate page list only the contents of a package alphabetically
adb014
parents:
2615
diff
changeset
|
1165 } # 1}}} |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1166 sub cat_funcs { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1167 # cat_funcs($TB,$cat) returns an ordered list of functions in $TB,$cat |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1168 my ($TB,$cat) = @_; |
295 | 1169 return sort { uc($a) cmp uc($b) } @{$index_by_TB_cat{$TB}{$cat}} |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1170 } # 1}}} |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1171 sub indexed_funcs { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1172 # indexed_funcs() returns an ordered list of all functions in the index |
295 | 1173 return sort { uc($a) cmp uc($b) } keys %index_by_function; |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1174 } # 1}}} |
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1175 sub forge_funcs { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1176 # forge_funcs() returns an ordered list of functions only found in octave forge |
295 | 1177 return sort { uc($a) cmp uc($b) } keys %octave_forge_function; |
293
cc2526f5c33b
start function interface to data structures rather than direct reference
pkienzle
parents:
282
diff
changeset
|
1178 } # 1}}} |
295 | 1179 sub scanned_funcs { # 1{{{ |
299
343ca1be61fc
generate extended descriptions; include download reference
pkienzle
parents:
296
diff
changeset
|
1180 # scanned_funcs() returns an ordered list of all functions found in m-files and oct-files |
295 | 1181 return sort { uc($a) cmp uc($b) } %function_description; |
213 | 1182 } # 1}}} |
1183 __END__ | |
1184 This program is free software; you can redistribute it and/or modify | |
1185 it under the terms of the GNU General Public License as published by | |
1186 the Free Software Foundation; either version 2 of the License, or | |
1187 (at your option) any later version. | |
1188 This program is distributed in the hope that it will be useful, | |
1189 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
1190 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
1191 GNU General Public License for more details. | |
1192 You should have received a copy of the GNU General Public License | |
1193 along with this program; if not, write to the Free Software | |
1194 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
1195 This program is granted to the public domain. | |
1196 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
1197 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
1198 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
1199 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
1200 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
1201 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
1202 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
1203 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
1204 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
1205 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
1206 SUCH DAMAGE. |