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

Annotation of OpenXM_contrib/gnuplot/docs/doc2texi.pl, Revision 1.1.1.1

1.1       maekawa     1: #!/usr/local/bin/perl
                      2: #
                      3: # $Id: doc2texi.pl,v 1.5 1996/12/08 12:29:25 drd Exp $
                      4: #
                      5: # doc2texi.pl : Converts Gnuplot .doc files to Texinfo format.
                      6: #
                      7: # George Ferguson, ferguson@cs.rochester.edu, 11 Feb 1991.
                      8: #
                      9: # Usage:
                     10: #      % doc2texi.pl gnuplot.doc >gnuplot.texinfo
                     11: #      % makeinfo --fill-column 80 gnuplot.texinfo
                     12: # Creates files "gnuplot.info" and "gnuplot.info-[123]".
                     13: #
                     14:
                     15: $currentBook = $currentChapter = $currentSection = $currentSubsection = 0;
                     16: $verbatim = $table = 0;
                     17:
                     18: while (<>) {
                     19:     if (/^([1-4]) (.*)$/) {    # section heading
                     20:        $table = 0;
                     21:        &endVerbatim;
                     22:        $numNodes += 1;
                     23:        $nodeLevel[$numNodes] = $1;
                     24:        $nodeTitle[$numNodes] = $2;
                     25:        $nodeText[$numNodes] = "";
                     26:        if ($1 == 1) {
                     27:            $currentBook = $numNodes;
                     28:        } elsif ($1 == 2) {
                     29:            $currentChapter = $numNodes;
                     30:            $nodeMenu[$currentBook] .= "* $2::\n";
                     31:        } elsif ($1 == 3) {
                     32:            $currentSection = $numNodes;
                     33:            if ($nodeTitle[$currentChapter] eq "set-show") {
                     34:                $nodeTitle[$numNodes] = "set $2";       # override
                     35:                $nodeMenu[$currentChapter] .= "* set $2::\n";
                     36:            } else {
                     37:                $nodeMenu[$currentChapter] .= "* $2::\n";
                     38:            }
                     39:        } elsif ($1 == 4) {
                     40:            $currentSubsection = $numNodes;
                     41:            $nodeMenu[$currentSection] .= "* $2::\n";
                     42:        }
                     43:     } elsif (/^\?(.*)$/) {                             # index entry
                     44:        if ($1 ne "") {
                     45:            $nodeText[$numNodes] .= "\@cindex $1\n";
                     46:        }
                     47:     } elsif (/^\@start table/) {                               # start table
                     48:        &startVerbatim;
                     49:        $table = 1;
                     50:     } elsif (/^\@end table/) {                         # end table
                     51:        $table = 0;
                     52:        &endVerbatim;
                     53:     } elsif (/^#/ || /^%/) {                           # table entry
                     54:        next;
                     55:     } elsif (/^ ( ?)(.*)$/) {                          # text
                     56:        if ($1 eq " ") {
                     57:            &startVerbatim;
                     58:        } else {
                     59:            &endVerbatim;
                     60:        }
                     61:        $text = $2;
                     62:        $text =~ s/@/@@/g;
                     63:        $text =~ s/{/\@{/g;
                     64:        $text =~ s/}/\@}/g;
                     65:        $text =~ s/\`([^`]*)\`/\@code{$1}/g;
                     66:        $nodeText[$numNodes] .= "$text\n";
                     67:     } elsif (/^$/) {                                   # blank line
                     68:        &endVerbatim;
                     69:        $nodeText[$numNodes] .= "\n";
                     70:     }
                     71: }
                     72:
                     73: # Print texinfo header
                     74: print "\\input texinfo\n";
                     75: print "\@setfilename gnuplot.info\n";
                     76: print "\@settitle Gnuplot: An Interactive Plotting Program\n";
                     77: print "\n";
                     78: print "\@node Top\n";
                     79: print "\@top Gnuplot";
                     80: print "\n";
                     81: print "$nodeText[1]";
                     82: print "\@menu\n";
                     83: print "$nodeMenu[1]";
                     84: print "* General Index::\n";
                     85: print "\@end menu\n";
                     86: print "\n";
                     87:
                     88: # Now output all the nodes
                     89: for ($i=2; $i <= $numNodes; $i++) {
                     90:     print "\@node $nodeTitle[$i]\n";
                     91:     if ($nodeLevel[$i] == 2) {
                     92:        print "\@chapter $nodeTitle[$i]\n";
                     93:     } elsif ($nodeLevel[$i] == 3) {
                     94:        print "\@section $nodeTitle[$i]\n";
                     95:     } elsif ($nodeLevel[$i] == 4) {
                     96:        print "\@subsection $nodeTitle[$i]\n";
                     97:     }
                     98:     print "$nodeText[$i]";
                     99:     if ($nodeMenu[$i] ne "") {
                    100:        print "\@menu\n";
                    101:        print $nodeMenu[$i];
                    102:        print "\@end menu\n";
                    103:     }
                    104:     print "\n";
                    105: }
                    106: # Print texinfo trailer
                    107: print "\n";
                    108: print "\@node General Index\n";
                    109: print "\@appendix General Index\n";
                    110: print "\n";
                    111: print "\@printindex cp\n";
                    112: print "\n";
                    113: print "\@bye\n";
                    114:
                    115: #######################
                    116:
                    117: sub startVerbatim {
                    118:     if (!$verbatim) {
                    119:        $nodeText[$numNodes] .= "\@example\n";
                    120:        $verbatim = 1;
                    121:     }
                    122: }
                    123:
                    124: sub endVerbatim {
                    125:     if ($verbatim && !$table) {
                    126:        $nodeText[$numNodes] .= "\@end example\n";
                    127:        $verbatim = 0;
                    128:     }
                    129: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>