40 Remove Non-API Text
This Perl script comments out non-documentation lines. (It is not (yet) in
use.)
539b⟨* 21⟩+
≡ ⊲537a 542 ⊳
#------------------------------------------------------------------
#---
#--- ALLPROSE
#--- Copyright (C) Ralf Hemmecke (ralf@hemmecke.de)
#--- http://www.hemmecke.de/aldor
#---
#------------------------------------------------------------------
⟨global variables 298a⟩
my($lineNumber, $line);
while (<>) {chomp; push @LineBuffer, $_;}
for($lineNumber = 0; $lineNumber < scalar(@LineBuffer); $lineNumber++) {
⟨do something for one line 479a⟩
}
for $line (@LineBuffer) {print $line, "\n";}
Now, depending on the line that is currently considered, several things have to be
done. First of all, to shorten the following code, the current line is remembered.
The script remembers also in which state it currently is. In particular,
whether it is inside a +++ environment or inside a code chunk. The line
number of the \begin{+++} is remembered in the variable beginDocIndex in
order to be able to add information there when it is found in the lines that
follow.
540b⟨do something for one line 479a⟩+
≡ (478b 539b) ⊲539c
if ($line =~ /^\\begin{\+\+\+}/) {
$inDocEnvironment=1;
} elsif ($inDocEnvironment) {
if ($line =~ /^\\end{\+\+\+}/) {
$inDocEnvironment=0;
}
} elsif ($line =~ /^<<.*>>=/) {
$inCodeChunk=1;
} elsif ($inCodeChunk) {
if ($line =~ /^\@(\s*$|\s+%def)/) {
$inCodeChunk=0;
}
} else { # we are not in a code chunk and not in a DocEnvironment.
@LineBuffer[$lineNumber] = ’%’.$line;
}
Uses code 436.