Mercurial > octave-libgccjit
annotate scripts/mkdoc.pl @ 18938:18e46285a608
Skip private functions when building DOCSTRING (bug #42791).
* scripts/mkdoc.pl: the DOCSTRING being built are used as cache for functions
such as 'lookfor()', even if they are private functions. This change skips
those, effectively removing them from lookfor results.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Thu, 17 Jul 2014 16:25:30 +0100 |
parents | d63878346099 |
children | b0960d4afe5f |
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 # |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17256
diff
changeset
|
3 # Copyright (C) 2012-2013 Rik Wehbring |
14617
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 ... |
18938
18e46285a608
Skip private functions when building DOCSTRING (bug #42791).
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
24 use File::Spec; |
14617
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
25 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
26 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
|
27 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
28 $srcdir = shift (@ARGV) . '/'; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
29 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
30 print <<__END_OF_MSG__; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
31 ### DO NOT EDIT! |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
32 ### |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
33 ### 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
|
34 ### 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
|
35 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
36 __END_OF_MSG__ |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
37 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
38 MFILE: foreach $m_fname (@ARGV) |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
39 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
40 if ($m_fname eq "--") |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
41 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
42 $srcdir = "./"; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
43 next MFILE; |
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 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
46 $full_fname = $srcdir . $m_fname; |
18938
18e46285a608
Skip private functions when building DOCSTRING (bug #42791).
Carnë Draug <carandraug@octave.org>
parents:
17744
diff
changeset
|
47 next MFILE if ((File::Spec->splitdir($full_fname))[-2] eq "private"); |
14617
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
48 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
|
49 if ($2) |
a52b03df22cb
maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents:
14644
diff
changeset
|
50 { $fcn = "$2$3/$4"; } |
a52b03df22cb
maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents:
14644
diff
changeset
|
51 else |
a52b03df22cb
maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents:
14644
diff
changeset
|
52 { $fcn = $4; } |
14617
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
53 |
14644
f49e47ab83ca
maint: Rename mygethelp function to gethelp in scripts/mkdoc.pl
Rik <octave@nomad.inbox5.com>
parents:
14617
diff
changeset
|
54 @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
|
55 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
|
56 |
17256
ee1d19174316
doc: Use 0x1d as record separator for joint compatibility with Texinfo 4.x and 5.x.
Rik <rik@octave.org>
parents:
17242
diff
changeset
|
57 print "\x{1d}$fcn\n"; |
14617
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
58 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
|
59 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
60 foreach $_ (@help_txt) |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
61 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
62 s/^\s+\@/\@/ unless $in_example; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
63 s/^\s+\@group/\@group/; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
64 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
|
65 $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
|
66 print $_; |
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 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
70 ################################################################################ |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
71 # Subroutines |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
72 ################################################################################ |
14644
f49e47ab83ca
maint: Rename mygethelp function to gethelp in scripts/mkdoc.pl
Rik <octave@nomad.inbox5.com>
parents:
14617
diff
changeset
|
73 sub gethelp |
14617
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
74 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
75 ($fcn, $fname) = @_[0..1]; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
76 open (FH, $fname) or return ""; |
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 do |
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 @help_txt = (); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
81 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
82 ## Advance to non-blank line |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
83 while (defined ($_ = <FH>) and /^\s*$/) {;} |
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 if (! /^\s*(?:#|%)/ or eof (FH)) |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
86 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
87 ## 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
|
88 close (FH); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
89 return ""; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
90 } |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
91 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
92 ## 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
|
93 do |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
94 { |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
95 ## 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
|
96 s/^\s*(?:#|%){1,2} ?//; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
97 push (@help_txt, $_); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
98 } until (! defined ($_ = <FH>) or ! /^\s*(?:#|%)/); |
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 } until ($help_txt[0] !~ /^(?:Copyright|Author)/); |
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 close (FH); |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
103 |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
104 return @help_txt; |
8ffb01c3a27a
doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff
changeset
|
105 } |