Mercurial > octave
changeset 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 | 3136e3f8e631 |
children | 91f626902d17 |
files | scripts/mkdoc.pl |
diffstat | 1 files changed, 12 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/mkdoc.pl Thu Jul 17 19:51:21 2014 -0700 +++ b/scripts/mkdoc.pl Fri Jul 18 09:16:27 2014 -0700 @@ -40,31 +40,32 @@ __END_OF_MSG__ -foreach my $m_fname (@ARGV) +MFILE: foreach my $m_fname (@ARGV) { if ($m_fname eq "--") - { - $srcdir = getcwd (); - next; - } + { + $srcdir = getcwd (); + next MFILE; + } my $full_fname = File::Spec->catfile ($srcdir, $m_fname); my @paths = File::Spec->splitdir ($full_fname); - next if @paths < 3 - || $paths[-2] eq "private" # skip private directories - || $paths[-1] !~ s/\.m$//i; # skip non m files and remove extension + if (@paths < 3 + || $paths[-2] eq "private" # skip private directories + || $paths[-1] !~ s/\.m$//i) # skip non m-files, and remove extension + { next MFILE; } ## @classes will have @class/method as their function name my $fcn = $paths[-2] =~ m/^@/ ? File::Spec->catfile (@paths[-2, -1]) : $paths[-1]; my @help_txt = gethelp ($fcn, $full_fname); - next unless @help_txt; + next MFILE unless @help_txt; print "\x{1d}$fcn\n"; - print "\@c $fcn " . File::Spec->catfile ("scripts", $m_fname) . "\n"; + print "\@c $fcn ", File::Spec->catfile ("scripts", $m_fname), "\n"; - foreach (@help_txt) + foreach $_ (@help_txt) { my $in_example = (m/\s*\@example\b/ .. m/\s*\@end\s+example\b/); s/^\s+\@/\@/ unless $in_example;