[BACK]Return to doc2texi.pl CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / docs

File: [local] / OpenXM_contrib / gnuplot / docs / Attic / doc2texi.pl (download)

Revision 1.1.1.2 (vendor branch), Sat Jan 22 14:16:12 2000 UTC (24 years, 4 months ago) by maekawa
Branch: GNUPLOT
CVS Tags: maekawa-ipv6, VERSION_3_7_3, VERSION_3_7_1, RELEASE_20000124, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, RELEASE_1_1_3, RELEASE_1_1_2
Changes since 1.1.1.1: +1 -1 lines

Import gnuplot 3.7.1

#!/usr/local/bin/perl
#
# $Id: doc2texi.pl,v 1.1.1.1 1998/04/15 19:16:44 lhecking Exp $
#
# doc2texi.pl : Converts Gnuplot .doc files to Texinfo format.
#
# George Ferguson, ferguson@cs.rochester.edu, 11 Feb 1991.
#
# Usage:
#	% doc2texi.pl gnuplot.doc >gnuplot.texinfo
#	% makeinfo --fill-column 80 gnuplot.texinfo
# Creates files "gnuplot.info" and "gnuplot.info-[123]".
#

$currentBook = $currentChapter = $currentSection = $currentSubsection = 0;
$verbatim = $table = 0;

while (<>) {
    if (/^([1-4]) (.*)$/) {	# section heading
	$table = 0;
	&endVerbatim;
	$numNodes += 1;
	$nodeLevel[$numNodes] = $1;
	$nodeTitle[$numNodes] = $2;
	$nodeText[$numNodes] = "";
	if ($1 == 1) {
	    $currentBook = $numNodes;
	} elsif ($1 == 2) {
	    $currentChapter = $numNodes;
	    $nodeMenu[$currentBook] .= "* $2::\n";
	} elsif ($1 == 3) {
	    $currentSection = $numNodes;
	    if ($nodeTitle[$currentChapter] eq "set-show") {
		$nodeTitle[$numNodes] = "set $2";	# override
		$nodeMenu[$currentChapter] .= "* set $2::\n";
	    } else {
		$nodeMenu[$currentChapter] .= "* $2::\n";
	    }
	} elsif ($1 == 4) {
	    $currentSubsection = $numNodes;
	    $nodeMenu[$currentSection] .= "* $2::\n";
	}
    } elsif (/^\?(.*)$/) {				# index entry
	if ($1 ne "") {
	    $nodeText[$numNodes] .= "\@cindex $1\n";
	}
    } elsif (/^\@start table/) {				# start table
	&startVerbatim;
	$table = 1;
    } elsif (/^\@end table/) {				# end table
	$table = 0;
	&endVerbatim;
    } elsif (/^#/ || /^%/) {				# table entry
	next;
    } elsif (/^ ( ?)(.*)$/) {				# text
	if ($1 eq " ") {
	    &startVerbatim;
	} else {
	    &endVerbatim;
	}
	$text = $2;
	$text =~ s/@/@@/g;
	$text =~ s/{/\@{/g;
	$text =~ s/}/\@}/g;
 	$text =~ s/\`([^`]*)\`/\@code{$1}/g;
	$nodeText[$numNodes] .= "$text\n";
    } elsif (/^$/) {					# blank line
	&endVerbatim;
	$nodeText[$numNodes] .= "\n";
    }
}

# Print texinfo header
print "\\input texinfo\n";
print "\@setfilename gnuplot.info\n";
print "\@settitle Gnuplot: An Interactive Plotting Program\n";
print "\n";
print "\@node Top\n";
print "\@top Gnuplot";
print "\n";
print "$nodeText[1]";
print "\@menu\n";
print "$nodeMenu[1]";
print "* General Index::\n";
print "\@end menu\n";
print "\n";

# Now output all the nodes
for ($i=2; $i <= $numNodes; $i++) {
    print "\@node $nodeTitle[$i]\n";
    if ($nodeLevel[$i] == 2) {
	print "\@chapter $nodeTitle[$i]\n";
    } elsif ($nodeLevel[$i] == 3) {
	print "\@section $nodeTitle[$i]\n";
    } elsif ($nodeLevel[$i] == 4) {
	print "\@subsection $nodeTitle[$i]\n";
    }
    print "$nodeText[$i]";
    if ($nodeMenu[$i] ne "") {
	print "\@menu\n";
	print $nodeMenu[$i];
	print "\@end menu\n";
    }
    print "\n";
}
# Print texinfo trailer
print "\n";
print "\@node General Index\n";
print "\@appendix General Index\n";
print "\n";
print "\@printindex cp\n";
print "\n";
print "\@bye\n";

#######################

sub startVerbatim {
    if (!$verbatim) {
	$nodeText[$numNodes] .= "\@example\n";
	$verbatim = 1;
    }
}

sub endVerbatim {
    if ($verbatim && !$table) {
	$nodeText[$numNodes] .= "\@end example\n";
	$verbatim = 0;
    }
}