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

doc: PSIDOC_CONTINUE and PSIDOC_RESUME

parent 2eaf9fa5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4,11 +4,11 @@ CXX = g++

all: manual.pdf tutorial.pdf

manual.tex: manual.ptex
manual.tex: manual.ptex ../scripts/doc.pl
	find ../src -iname "*.h" -or -iname "*.cpp" |\
              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" |\
perl ../scripts/doc.pl tutorial.ptex

+0 −1
Original line number Diff line number Diff line
@@ -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.

\ptexPaste{InputNg_Intro}
\ptexPaste{InputNg_MyInputCheck}
\ptexPaste{InputNg_main1}
\ptexPaste{InputNg_main2}
\ptexPaste{InputNg_main3}
+2 −2
Original line number Diff line number Diff line
@@ -28,13 +28,13 @@ First, note that we need two includes from PsimagLite.
PsimagLite files are usually under src, but in some
cases subdirectories are used. Here are the includes.
\begin{lstlisting}
PSIDOC_CAPTURE
PSIDOC_CONTINUE
*/

#include "InputNg.h"
#include "InputCheckBase.h"

/* PSIDOC InputNg_MyInputCheck
/* PSIDOC_RESUME
\end{lstlisting}
InputNg has an option to check the inputs, so that
 you can define the labels that you expect to find
+34 −0
Original line number Diff line number Diff line
@@ -26,6 +26,16 @@ recursiveExpand(\%labels);

replaceLabels($file, \%labels);

printLabels(\%labels);

sub printLabels
{
	my ($labels) = @_;
	foreach my $key (keys %$labels) {
		print "$key\n";
	}
}

sub loadLines
{
	my ($lines) = @_;
@@ -112,12 +122,19 @@ sub loadLabels
	my $inCodeBlock = 0;
	my $codeBuffer = "";
	my $modifyLater = 1;
	my $hasContinue = 0;

	for (my $i = 0; $i < $nlines; ++$i) {
		$_ = $lines->[$i];
		if (/\/\* *PSIDOC_RESUME */) {
			$hasContinue = 0;
			next;
		}

		if (/\/\* *PSIDOC +(.+$)/) {
			my $rest = $1;
			chomp($rest);
			checkThatItDoesNotHaveContinue($hasContinue, "PSIDOC $rest");
			($label, $additional) = procPsidocName($rest);
			$modifyLater = 1;

@@ -132,6 +149,7 @@ sub loadLabels
		if (/\/\* PSIDOC_CODE_START +(.+$)/) {
			my $rest = $1;
            chomp($rest);
			checkThatItDoesNotHaveContinue($hasContinue, "PSIDOC_CODE_START $rest");
			$rest =~ s/\*\/ *$//;
			if ($inCodeBlock) {
				die "$0: Nested code blocks not allowed\n";
@@ -146,11 +164,13 @@ sub loadLabels
				die "$0: ERROR: Label $label is duplicate\n";
			}

			print STDERR "Opening $label\n";
			$inCodeBlock = 1;
			next;
		}

		if (/\/\* PSIDOC_CODE_END \*\//) {
			print STDERR "Closing $label\n";
			if (!$inCodeBlock) {
				die "$0: Closing code block while none is open\n";
			}
@@ -162,6 +182,7 @@ sub loadLabels
		}

		if (/\*\//) {
			next if ($hasContinue);
			if ($label ne "!DISABLED" and $modifyLater) {
				my $inlabel = $label."::";
				$buffer =~ s/PSIDOCCOPY \$/PSIDOCCOPY ${inlabel}/g;
@@ -187,6 +208,7 @@ sub loadLabels
			}

			$buffer = "";
			print STDERR "Changing $label to !DISABLED\n";
			$label = "!DISABLED";
			$modifyLater = 1;
			$additional = "";
@@ -195,6 +217,11 @@ sub loadLabels
			next;
		}

		if (/^[ \t]*PSIDOC_CONTINUE *$/) {
			$hasContinue = 1;
			next;
		}

		if ($label ne "!DISABLED") {
			$buffer .= $_."\n";
		}
@@ -210,6 +237,13 @@ sub loadLabels
	%$a = %labels;
}

sub checkThatItDoesNotHaveContinue
{
	my ($hasContinue, $txt) = @_;
	return if ($hasContinue == 0);
	die "$0: Cannot use $txt when has continue\n";
}

sub procPsidocName
{
	my ($nameLike) = @_;