annotate scripts/mkdoc.pl @ 16088:b29b10fbb744 stable release-3-6-4

Version 3.6.4 released. * configure.ac (AC_INIT): Version is now 3.6.4. (OCTAVE_RELEASE_DATE): Now 2013-02-21.
author John W. Eaton <jwe@octave.org>
date Thu, 21 Feb 2013 15:17:54 -0500
parents 5b3e56d588b1
children 3f4091dddc13
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15828
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
1 #! /usr/bin/perl -w
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
2 #
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
3 # Copyright (C) 2012 Rik Wehbring
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
4 #
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
5 # This file is part of Octave.
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
6 #
41a05ee9021a 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
41a05ee9021a 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
41a05ee9021a 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
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
10 # your option) any later version.
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
11 #
41a05ee9021a 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
41a05ee9021a 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
41a05ee9021a 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
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
15 # for more details.
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
16 #
41a05ee9021a 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
41a05ee9021a 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
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
19 # <http://www.gnu.org/licenses/>.
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
20
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
21 ## Expecting arguments in this order:
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
22 ##
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
23 ## SRCDIR SRCDIR-FILES ... -- LOCAL-FILES ...
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
24
41a05ee9021a 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 ..." ; }
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
26
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
27 $srcdir = shift (@ARGV) . '/';
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
28
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
29 print <<__END_OF_MSG__;
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
30 ### DO NOT EDIT!
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
31 ###
41a05ee9021a 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.
41a05ee9021a 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.
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
34
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
35 __END_OF_MSG__
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
36
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
37 MFILE: foreach $m_fname (@ARGV)
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
38 {
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
39 if ($m_fname eq "--")
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
40 {
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
41 $srcdir = "./";
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
42 next MFILE;
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
43 }
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
44
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
45 $full_fname = $srcdir . $m_fname;
41a05ee9021a 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} );
15830
5b3e56d588b1 maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents: 15829
diff changeset
47 if ($2)
5b3e56d588b1 maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents: 15829
diff changeset
48 { $fcn = "$2$3/$4"; }
5b3e56d588b1 maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents: 15829
diff changeset
49 else
5b3e56d588b1 maint: Use Octave 2-space indent for helper Perl scripts.
Rik <octave@nomad.inbox5.com>
parents: 15829
diff changeset
50 { $fcn = $4; }
15828
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
51
15829
425c075e3c70 maint: Rename mygethelp function to gethelp in scripts/mkdoc.pl
Rik <octave@nomad.inbox5.com>
parents: 15828
diff changeset
52 @help_txt = gethelp ($fcn, $full_fname);
15828
41a05ee9021a 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 "");
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
54
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
55 print "$fcn\n";
41a05ee9021a 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";
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
57
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
58 foreach $_ (@help_txt)
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
59 {
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
60 s/^\s+\@/\@/ unless $in_example;
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
61 s/^\s+\@group/\@group/;
41a05ee9021a 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/;
41a05ee9021a 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/);
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
64 print $_;
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
65 }
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
66 }
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
67
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
68 ################################################################################
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
69 # Subroutines
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
70 ################################################################################
15829
425c075e3c70 maint: Rename mygethelp function to gethelp in scripts/mkdoc.pl
Rik <octave@nomad.inbox5.com>
parents: 15828
diff changeset
71 sub gethelp
15828
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
72 {
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
73 ($fcn, $fname) = @_[0..1];
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
74 open (FH, $fname) or return "";
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
75
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
76 do
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
77 {
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
78 @help_txt = ();
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
79
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
80 ## Advance to non-blank line
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
81 while (defined ($_ = <FH>) and /^\s*$/) {;}
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
82
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
83 if (! /^\s*(?:#|%)/ or eof (FH))
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
84 {
41a05ee9021a 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
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
86 close (FH);
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
87 return "";
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
88 }
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
89
41a05ee9021a 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
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
91 do
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
92 {
41a05ee9021a 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
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
94 s/^\s*(?:#|%){1,2} ?//;
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
95 push (@help_txt, $_);
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
96 } until (! defined ($_ = <FH>) or ! /^\s*(?:#|%)/);
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
97
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
98 } until ($help_txt[0] !~ /^(?:Copyright|Author)/);
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
99
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
100 close (FH);
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
101
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
102 return @help_txt;
41a05ee9021a doc: Use Perl to create DOCSTRINGS in scripts directory.
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
103 }