Commit 3d5b4c78 authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

doc: PSIDOC_CONTINUE and PSIDOC_RESUME

parent 2eaf9fa5
...@@ -4,11 +4,11 @@ CXX = g++ ...@@ -4,11 +4,11 @@ CXX = g++
all: manual.pdf tutorial.pdf all: manual.pdf tutorial.pdf
manual.tex: manual.ptex manual.tex: manual.ptex ../scripts/doc.pl
find ../src -iname "*.h" -or -iname "*.cpp" |\ find ../src -iname "*.h" -or -iname "*.cpp" |\
perl ../scripts/doc.pl manual.ptex perl ../scripts/doc.pl manual.ptex
tutorial.tex: tutorial.ptex ../src/*h ../drivers/*cpp tutorial.tex: tutorial.ptex ../src/*h ../drivers/*cpp ../scripts/doc.pl
find ../src ../drivers -iname "*.h" -or -iname "*.cpp" |\ find ../src ../drivers -iname "*.h" -or -iname "*.cpp" |\
perl ../scripts/doc.pl tutorial.ptex perl ../scripts/doc.pl tutorial.ptex
......
...@@ -118,7 +118,6 @@ again the example should be able to compile without it; it won't run ...@@ -118,7 +118,6 @@ again the example should be able to compile without it; it won't run
though, but display a message saying that the GSL is needed. though, but display a message saying that the GSL is needed.
\ptexPaste{InputNg_Intro} \ptexPaste{InputNg_Intro}
\ptexPaste{InputNg_MyInputCheck}
\ptexPaste{InputNg_main1} \ptexPaste{InputNg_main1}
\ptexPaste{InputNg_main2} \ptexPaste{InputNg_main2}
\ptexPaste{InputNg_main3} \ptexPaste{InputNg_main3}
......
...@@ -28,13 +28,13 @@ First, note that we need two includes from PsimagLite. ...@@ -28,13 +28,13 @@ First, note that we need two includes from PsimagLite.
PsimagLite files are usually under src, but in some PsimagLite files are usually under src, but in some
cases subdirectories are used. Here are the includes. cases subdirectories are used. Here are the includes.
\begin{lstlisting} \begin{lstlisting}
PSIDOC_CAPTURE PSIDOC_CONTINUE
*/ */
#include "InputNg.h" #include "InputNg.h"
#include "InputCheckBase.h" #include "InputCheckBase.h"
/* PSIDOC InputNg_MyInputCheck /* PSIDOC_RESUME
\end{lstlisting} \end{lstlisting}
InputNg has an option to check the inputs, so that InputNg has an option to check the inputs, so that
you can define the labels that you expect to find you can define the labels that you expect to find
......
...@@ -26,6 +26,16 @@ recursiveExpand(\%labels); ...@@ -26,6 +26,16 @@ recursiveExpand(\%labels);
replaceLabels($file, \%labels); replaceLabels($file, \%labels);
printLabels(\%labels);
sub printLabels
{
my ($labels) = @_;
foreach my $key (keys %$labels) {
print "$key\n";
}
}
sub loadLines sub loadLines
{ {
my ($lines) = @_; my ($lines) = @_;
...@@ -112,12 +122,19 @@ sub loadLabels ...@@ -112,12 +122,19 @@ sub loadLabels
my $inCodeBlock = 0; my $inCodeBlock = 0;
my $codeBuffer = ""; my $codeBuffer = "";
my $modifyLater = 1; my $modifyLater = 1;
my $hasContinue = 0;
for (my $i = 0; $i < $nlines; ++$i) { for (my $i = 0; $i < $nlines; ++$i) {
$_ = $lines->[$i]; $_ = $lines->[$i];
if (/\/\* *PSIDOC_RESUME */) {
$hasContinue = 0;
next;
}
if (/\/\* *PSIDOC +(.+$)/) { if (/\/\* *PSIDOC +(.+$)/) {
my $rest = $1; my $rest = $1;
chomp($rest); chomp($rest);
checkThatItDoesNotHaveContinue($hasContinue, "PSIDOC $rest");
($label, $additional) = procPsidocName($rest); ($label, $additional) = procPsidocName($rest);
$modifyLater = 1; $modifyLater = 1;
...@@ -132,6 +149,7 @@ sub loadLabels ...@@ -132,6 +149,7 @@ sub loadLabels
if (/\/\* PSIDOC_CODE_START +(.+$)/) { if (/\/\* PSIDOC_CODE_START +(.+$)/) {
my $rest = $1; my $rest = $1;
chomp($rest); chomp($rest);
checkThatItDoesNotHaveContinue($hasContinue, "PSIDOC_CODE_START $rest");
$rest =~ s/\*\/ *$//; $rest =~ s/\*\/ *$//;
if ($inCodeBlock) { if ($inCodeBlock) {
die "$0: Nested code blocks not allowed\n"; die "$0: Nested code blocks not allowed\n";
...@@ -146,11 +164,13 @@ sub loadLabels ...@@ -146,11 +164,13 @@ sub loadLabels
die "$0: ERROR: Label $label is duplicate\n"; die "$0: ERROR: Label $label is duplicate\n";
} }
print STDERR "Opening $label\n";
$inCodeBlock = 1; $inCodeBlock = 1;
next; next;
} }
if (/\/\* PSIDOC_CODE_END \*\//) { if (/\/\* PSIDOC_CODE_END \*\//) {
print STDERR "Closing $label\n";
if (!$inCodeBlock) { if (!$inCodeBlock) {
die "$0: Closing code block while none is open\n"; die "$0: Closing code block while none is open\n";
} }
...@@ -162,6 +182,7 @@ sub loadLabels ...@@ -162,6 +182,7 @@ sub loadLabels
} }
if (/\*\//) { if (/\*\//) {
next if ($hasContinue);
if ($label ne "!DISABLED" and $modifyLater) { if ($label ne "!DISABLED" and $modifyLater) {
my $inlabel = $label."::"; my $inlabel = $label."::";
$buffer =~ s/PSIDOCCOPY \$/PSIDOCCOPY ${inlabel}/g; $buffer =~ s/PSIDOCCOPY \$/PSIDOCCOPY ${inlabel}/g;
...@@ -187,6 +208,7 @@ sub loadLabels ...@@ -187,6 +208,7 @@ sub loadLabels
} }
$buffer = ""; $buffer = "";
print STDERR "Changing $label to !DISABLED\n";
$label = "!DISABLED"; $label = "!DISABLED";
$modifyLater = 1; $modifyLater = 1;
$additional = ""; $additional = "";
...@@ -195,6 +217,11 @@ sub loadLabels ...@@ -195,6 +217,11 @@ sub loadLabels
next; next;
} }
if (/^[ \t]*PSIDOC_CONTINUE *$/) {
$hasContinue = 1;
next;
}
if ($label ne "!DISABLED") { if ($label ne "!DISABLED") {
$buffer .= $_."\n"; $buffer .= $_."\n";
} }
...@@ -210,6 +237,13 @@ sub loadLabels ...@@ -210,6 +237,13 @@ sub loadLabels
%$a = %labels; %$a = %labels;
} }
sub checkThatItDoesNotHaveContinue
{
my ($hasContinue, $txt) = @_;
return if ($hasContinue == 0);
die "$0: Cannot use $txt when has continue\n";
}
sub procPsidocName sub procPsidocName
{ {
my ($nameLike) = @_; my ($nameLike) = @_;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment