Mercurial > hg > octave-lyh
annotate scripts/mkdoc.pl @ 16394:a53f56e16627
doc: Update texinfo @detailmenu to include Java chapter.
* doc/interpreter/octave.texi: Update texinfo @detailmenu to include Java
chapter.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 29 Mar 2013 12:14:52 -0700 |
parents | a52b03df22cb |
children | 3f4091dddc13 |
rev | line source |
---|---|
14617
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
1 #! /usr/bin/perl -w |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
2 # |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
3 # Copyright (C) 2012 Rik Wehbring |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
4 # |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
5 # This file is part of Octave. |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
6 # |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
7 # Octave is free software; you can redistribute it and/or modify it |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
8 # under the terms of the GNU General Public License as published by the |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
9 # Free Software Foundation; either version 3 of the License, or (at |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
10 # your option) any later version. |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
11 # |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
12 # Octave is distributed in the hope that it will be useful, but WITHOUT |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
15 # for more details. |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
16 # |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU General Public License |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
18 # along with Octave; see the file COPYING. If not, see |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
19 # <http://www.gnu.org/licenses/>. |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
20 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
21 ## Expecting arguments in this order: |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
22 ## |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
23 ## SRCDIR SRCDIR-FILES ... -- LOCAL-FILES ... |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
24 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
25 unless (@ARGV >= 2) { die "Usage: $0 srcdir m_filename1 ..." ; } |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
26 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
27 $srcdir = shift (@ARGV) . '/'; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
28 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
29 print <<__END_OF_MSG__; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
30 ### DO NOT EDIT! |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
31 ### |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
32 ### This file is generated automatically from Octave source files. |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
33 ### Edit source files directly and run make to update this file. |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
34 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
35 __END_OF_MSG__ |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
36 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
37 MFILE: foreach $m_fname (@ARGV) |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
38 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
39 if ($m_fname eq "--") |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
40 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
41 $srcdir = "./"; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
42 next MFILE; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
43 } |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
44 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
45 $full_fname = $srcdir . $m_fname; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
46 next MFILE unless ( $full_fname =~ m{(.*)/(@|)([^/]*)/(.*)\.m} ); |
14744
a52b03df22cb
maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents:
14644
diff
changeset
|
47 if ($2) |
a52b03df22cb
maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents:
14644
diff
changeset
|
48 { $fcn = "$2$3/$4"; } |
a52b03df22cb
maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents:
14644
diff
changeset
|
49 else |
a52b03df22cb
maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents:
14644
diff
changeset
|
50 { $fcn = $4; } |
14617
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
51 |
14644
f49e47ab83ca
maint: Rename mygethelp function to gethelp in scripts/mkdoc.pl
Rik <octave@nomad.inbox5.com>
parents:
14617
diff
changeset
|
52 @help_txt = gethelp ($fcn, $full_fname); |
14617
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
53 next MFILE if ($help_txt[0] eq ""); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
54 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
55 print "$fcn\n"; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
56 print "\@c $fcn scripts/$m_fname\n"; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
57 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
58 foreach $_ (@help_txt) |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
59 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
60 s/^\s+\@/\@/ unless $in_example; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
61 s/^\s+\@group/\@group/; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
62 s/^\s+\@end\s+group/\@end group/; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
63 $in_example = (/\s*\@example\b/ .. /\s*\@end\s+example\b/); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
64 print $_; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
65 } |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
66 } |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
67 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
68 ################################################################################ |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
69 # Subroutines |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
70 ################################################################################ |
14644
f49e47ab83ca
maint: Rename mygethelp function to gethelp in scripts/mkdoc.pl
Rik <octave@nomad.inbox5.com>
parents:
14617
diff
changeset
|
71 sub gethelp |
14617
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
72 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
73 ($fcn, $fname) = @_[0..1]; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
74 open (FH, $fname) or return ""; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
75 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
76 do |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
77 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
78 @help_txt = (); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
79 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
80 ## Advance to non-blank line |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
81 while (defined ($_ = <FH>) and /^\s*$/) {;} |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
82 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
83 if (! /^\s*(?:#|%)/ or eof (FH)) |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
84 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
85 ## No comment block found. Return empty string |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
86 close (FH); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
87 return ""; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
88 } |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
89 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
90 ## Extract help text stopping when comment block ends |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
91 do |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
92 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
93 ## Remove comment characters at start of line |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
94 s/^\s*(?:#|%){1,2} ?//; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
95 push (@help_txt, $_); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
96 } until (! defined ($_ = <FH>) or ! /^\s*(?:#|%)/); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
97 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
98 } until ($help_txt[0] !~ /^(?:Copyright|Author)/); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
99 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
100 close (FH); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
101 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
102 return @help_txt; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
103 } |