Mercurial > octave
comparison scripts/mkdoc.pl @ 18943:714ce8ca71ea
mkdoc.pl: Tweaks to make code easier to understand for non-Perl experts.
* mkdoc.pl: Use label when short-circuiting out of loop with next.
Use GNU indendation style for if blocks. Explicitly use variable $_ in foreach
loop for those unaware of Perl's default variable.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 18 Jul 2014 09:16:27 -0700 |
parents | 29fc1736a6be |
children | 0e1f5a750d00 |
comparison
equal
deleted
inserted
replaced
18942:3136e3f8e631 | 18943:714ce8ca71ea |
---|---|
38 ### This file is generated automatically from Octave source files. | 38 ### This file is generated automatically from Octave source files. |
39 ### Edit source files directly and run make to update this file. | 39 ### Edit source files directly and run make to update this file. |
40 | 40 |
41 __END_OF_MSG__ | 41 __END_OF_MSG__ |
42 | 42 |
43 foreach my $m_fname (@ARGV) | 43 MFILE: foreach my $m_fname (@ARGV) |
44 { | 44 { |
45 if ($m_fname eq "--") | 45 if ($m_fname eq "--") |
46 { | 46 { |
47 $srcdir = getcwd (); | 47 $srcdir = getcwd (); |
48 next; | 48 next MFILE; |
49 } | 49 } |
50 | 50 |
51 my $full_fname = File::Spec->catfile ($srcdir, $m_fname); | 51 my $full_fname = File::Spec->catfile ($srcdir, $m_fname); |
52 my @paths = File::Spec->splitdir ($full_fname); | 52 my @paths = File::Spec->splitdir ($full_fname); |
53 next if @paths < 3 | 53 if (@paths < 3 |
54 || $paths[-2] eq "private" # skip private directories | 54 || $paths[-2] eq "private" # skip private directories |
55 || $paths[-1] !~ s/\.m$//i; # skip non m files and remove extension | 55 || $paths[-1] !~ s/\.m$//i) # skip non m-files, and remove extension |
56 { next MFILE; } | |
56 | 57 |
57 ## @classes will have @class/method as their function name | 58 ## @classes will have @class/method as their function name |
58 my $fcn = $paths[-2] =~ m/^@/ ? File::Spec->catfile (@paths[-2, -1]) | 59 my $fcn = $paths[-2] =~ m/^@/ ? File::Spec->catfile (@paths[-2, -1]) |
59 : $paths[-1]; | 60 : $paths[-1]; |
60 | 61 |
61 my @help_txt = gethelp ($fcn, $full_fname); | 62 my @help_txt = gethelp ($fcn, $full_fname); |
62 next unless @help_txt; | 63 next MFILE unless @help_txt; |
63 | 64 |
64 print "\x{1d}$fcn\n"; | 65 print "\x{1d}$fcn\n"; |
65 print "\@c $fcn " . File::Spec->catfile ("scripts", $m_fname) . "\n"; | 66 print "\@c $fcn ", File::Spec->catfile ("scripts", $m_fname), "\n"; |
66 | 67 |
67 foreach (@help_txt) | 68 foreach $_ (@help_txt) |
68 { | 69 { |
69 my $in_example = (m/\s*\@example\b/ .. m/\s*\@end\s+example\b/); | 70 my $in_example = (m/\s*\@example\b/ .. m/\s*\@end\s+example\b/); |
70 s/^\s+\@/\@/ unless $in_example; | 71 s/^\s+\@/\@/ unless $in_example; |
71 s/^\s+(\@(?:end)\s+(group|example))/$1/; | 72 s/^\s+(\@(?:end)\s+(group|example))/$1/; |
72 print $_; | 73 print $_; |