diff options
author | Karl Berry <karl@freefriends.org> | 2007-08-16 00:36:22 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-08-16 00:36:22 +0000 |
commit | e8a50aed5d15bb07b077c572f74b697de13dd259 (patch) | |
tree | 655e386dc7e1a3c56c933fa1dcb570a45c2d8290 /Master/texmf-dist/doc/latex/makedtx/makedtx.pl | |
parent | 633e589696b3070094a313c5cddd484571a3ea7b (diff) |
makedtx 0.93b (15aug07)
git-svn-id: svn://tug.org/texlive/trunk@4739 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/makedtx/makedtx.pl')
-rw-r--r-- | Master/texmf-dist/doc/latex/makedtx/makedtx.pl | 132 |
1 files changed, 91 insertions, 41 deletions
diff --git a/Master/texmf-dist/doc/latex/makedtx/makedtx.pl b/Master/texmf-dist/doc/latex/makedtx/makedtx.pl index 7aba9c5454c..ea0825c6409 100644 --- a/Master/texmf-dist/doc/latex/makedtx/makedtx.pl +++ b/Master/texmf-dist/doc/latex/makedtx/makedtx.pl @@ -3,27 +3,31 @@ # File : makedtx # Author : Dr Nicola Talbot # Date : 29 Oct 2004 -# Last Modified : 11 Feb 2005 -# Version : 0.9b +# Last Modified : 2 Aug 2007 +# Version : 0.93b # usage : makedtx [options] -src <expr>=><expr> -doc <filename> <basename> # # -h : help message # -src <expr>=><expr> : e.g. -src "(foo)src\.(bar)=>$1.$2" will add foosrc.bar to <basename>.dtx to be extracted to foo.bar # -doc <filename> : file containing documentation. +# -prefinale <string> : text to add to dtx file just before \Finale (added to version 0.91b) # <basename> : create <basename>.dtx and <basename>.ins use Getopt::Long; -$version = "0.9b"; +$version = "0.93b"; # process command line options %optctl = (); -&GetOptions(\%optctl, "h", "help", "v", "src=s@", "doc=s", "dir=s", "op=s", "askforoverwrite!", "ins!", - "preamble=s", "postamble=s", "setambles=s@", "macrocode=s@", - "author=s", "date=s", "stopeventually=s") or syntaxerror(); +&GetOptions(\%optctl, "h", "help", "v", "src=s@", "doc=s", +"dir=s", "op=s", "askforoverwrite!", "ins!", +"preamble=s", "postamble=s", "setambles=s@", "macrocode=s@", +"author=s", "date=s", "stopeventually=s", +"prefinale=s", "codetitle=s", "comment=s@", +"version") or &syntaxerror(); $srcdir = "."; $patternop = "="; @@ -32,8 +36,10 @@ $noins = 0; $askforoverwrite = 0; $preamble = ""; $postamble = ""; -$author = ($ENV{'USER'} || "Unknown"); +$author = (getpwuid($<))[6] || 'Unknown'; $stopeventually = ""; +$prefinale = ""; +$codetitle = "The Code"; ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); @@ -43,7 +49,11 @@ foreach $setting (keys %optctl) { if (($setting eq "h") || ($setting eq "help")) { - help(); + &help(); + } + elsif ($setting eq "version") + { + die "makedtx version $version\n"; } elsif ($setting eq "doc") { @@ -101,6 +111,18 @@ foreach $setting (keys %optctl) { $stopeventually = $optctl{$setting}; } + elsif ($setting eq "prefinale") + { + $prefinale = $optctl{$setting}; + } + elsif ($setting eq "codetitle") + { + $codetitle = $optctl{$setting}; + } + elsif ($setting eq "comment") + { + @comment = @{ $optctl{$setting} }; + } } if ($preamble eq "") @@ -116,19 +138,19 @@ if ($preamble eq "") if ($docsrc eq "") { print "No document source specified (missing -doc)\n"; - syntaxerror(); + &syntaxerror(); } if ($#ARGV != 0) { print "No basename specified\n"; - syntaxerror(); + &syntaxerror(); } if ($#source == -1) { print "No source code specified (missing -src)\n"; - syntaxerror(); + &syntaxerror(); } $basename = $ARGV[0]; @@ -143,7 +165,7 @@ if ($verbose) open DOC, $docsrc or die "Can't open '$docsrc'\n"; print DTX "\%\\iffalse\n"; -print DTX "\% $basename.dtx generated using $0 version $version (c) Nicola Talbot\n"; +print DTX "\% $basename.dtx generated using makedtx version $version (c) Nicola Talbot\n"; print DTX "\% Command line args:\n"; foreach $setting (keys %optctl) @@ -171,11 +193,14 @@ foreach $setting (keys %optctl) } else { - print DTX "\% -", $setting, " \"", $optctl{$setting}, "\"\n"; + $val = $optctl{$setting}; + $val=~s/\\/\\\\/g; + print DTX "\% -", $setting, " \"", $val, "\"\n"; } } print DTX "\% $basename\n"; + print DTX "\% Created on $year/", $mon+1, "/$mday $hour:", $min<10?"0$min" : $min,"\n"; print DTX "\%\\fi\n"; print DTX "\%\\iffalse\n"; @@ -223,7 +248,7 @@ while (<DOC>) { $beginline = $1; - ($group,$restofline,$done) = getnextgroup($2); + ($group,$restofline,$done) = &getnextgroup($2); $startline = $.; @@ -235,7 +260,7 @@ while (<DOC>) $restofline = $restofline . $nextline; - ($group,$restofline,$done) = getnextgroup($restofline); + ($group,$restofline,$done) = &getnextgroup($restofline); } else { @@ -247,7 +272,7 @@ while (<DOC>) $beginline = $beginline . $group; - ($group,$restofline,$done) = getnextgroup($restofline); + ($group,$restofline,$done) = &getnextgroup($restofline); while (!$done) { @@ -257,7 +282,7 @@ while (<DOC>) $restofline = $restofline . $nextline; - ($group,$restofline,$done) = getnextgroup($restofline); + ($group,$restofline,$done) = &getnextgroup($restofline); } else { @@ -316,7 +341,7 @@ while (<DOC>) { $beginline = $1; - ($group,$restofline,$done) = getnextgroup($2); + ($group,$restofline,$done) = &getnextgroup($2); $startline = $.; @@ -328,7 +353,7 @@ while (<DOC>) $restofline = $restofline . $nextline; - ($group,$restofline,$done) = getnextgroup($restofline); + ($group,$restofline,$done) = &getnextgroup($restofline); } else { @@ -340,7 +365,7 @@ while (<DOC>) $beginline = $beginline . $group; - ($group,$restofline,$done) = getnextgroup($restofline); + ($group,$restofline,$done) = &getnextgroup($restofline); while (!$done) { @@ -350,7 +375,7 @@ while (<DOC>) $restofline = $restofline . $nextline; - ($group,$restofline,$done) = getnextgroup($restofline); + ($group,$restofline,$done) = &getnextgroup($restofline); } else { @@ -384,7 +409,7 @@ if ($stopfound==0) print DTX "\%\\StopEventually{$stopeventually}\n"; } -print DTX "\%\\section{The Code}\n"; +print DTX "\%\\section{$codetitle}\n"; @srcdirfile = glob("$srcdir/*"); @@ -398,14 +423,14 @@ foreach $source (@source) { print "-src $source argument invalid (no output file specified)\n"; - syntaxerror(); + &syntaxerror(); } if (not ($remainder eq "")) { print "-src $source argument invalid (too many => specified)\n"; - syntaxerror(); + &syntaxerror(); } foreach $srcdirfile (@srcdirfile) @@ -429,11 +454,24 @@ foreach $source (@source) open SRC, $thisinfile or die "Can't open $thisinfile\n"; + print DTX "\%\\iffalse\n"; print DTX "\% \\begin{macrocode}\n"; print DTX "\%<*$thisoutfile>\n"; print DTX "\% \\end{macrocode}\n"; + print DTX "\%\\fi\n"; $macrocode = 0; + $comment = 0; + + foreach $expr (@comment) + { + if ($thisoutfile =~ m/$expr/) + { + print DTX "\%\\iffalse\n"; + + $comment = 1; + } + } foreach $expr (@macrocode) { @@ -455,9 +493,16 @@ foreach $source (@source) print DTX "\% \\end{macrocode}\n"; } + if ($comment == 1) + { + print DTX "\%\\fi\n"; + } + + print DTX "\%\\iffalse\n"; print DTX "\% \\begin{macrocode}\n"; print DTX "\%</$thisoutfile>\n"; print DTX "\% \\end{macrocode}\n"; + print DTX "\%\\fi\n"; close SRC; @@ -466,6 +511,7 @@ foreach $source (@source) } } +print DTX "\%$prefinale\n" if ($prefinale); print DTX "\%\\Finale\n"; print DTX "\\endinput\n"; @@ -475,7 +521,7 @@ if (!$noins) { open INS, ">$basename.ins" or die "Can't open '$basename.ins'\n"; - print INS "\% $basename.ins generated using $0 version $version $year/",$mon+1,"/$mday $hour:", $min<10?"0$min":$min,"\n"; + print INS "\% $basename.ins generated using makedtx version $version $year/",$mon+1,"/$mday $hour:", $min<10?"0$min":$min,"\n"; print INS "\\input docstrip\n\n"; print INS "\\preamble\n"; @@ -562,18 +608,18 @@ if (!$noins) sub syntaxerror { - die "Syntax : $0 [options] <basename>\nUse -h for help\n"; + die "Syntax : makedtx [options] <basename>\nUse -h for help\n"; } sub help { - print "$0 Help\n\n"; + print "makedtx Help\n\n"; print "Current Version : $version\n\n"; - print "usage : $0 [options] -src \"<expr>=><expr>\" -doc <filename> <basename>\n\n"; + print "usage : makedtx [options] -src \"<expr>=><expr>\" -doc <filename> <basename>\n\n"; - print "$0 can be used to construct a LaTeX2e dtx and ins file from\n"; + print "makedtx can be used to construct a LaTeX2e dtx and ins file from\n"; print "the specified source code. The final command line argument\n"; print "<basename> should be used to specify the basename of the dtx\n"; print "and ins files.\n\n"; @@ -596,15 +642,19 @@ sub help print "-op <character> : set the pattern matching operator (default '$patternop')\n"; print "-askforoverwrite : set askforoverwrite switch in INS file to true\n"; print "-noaskforoverwrite : set askforoverwrite switch in INS file to false (default)\n"; - print "-preamble <text> : set the preamble. Standard one inserted if omitted\n"; - print "-postamble <text> : set the postamble.\n"; + print "-preamble <text> : set the preamble. Standard one inserted if omitted\n"; + print "-postamble <text> : set the postamble.\n"; print "-setambles \"<pattern>=><text>\" : set pre- and postambles to <text> if file matches pattern\n"; - print "-author <text> : name of author (inserted into standard preamble. User name inserted if omitted)\n"; - print "-date <text> : copyright date\n"; - print "-ins : create the ins file (default)\n"; - print "-noins : don't create the ins file\n"; - print "-h : help message\n"; - print "-v : verbose\n\n"; + print "-author <text> : name of author (inserted into standard preamble. User name inserted if omitted)\n"; + print "-date <text> : copyright date\n"; + print "-ins : create the ins file (default)\n"; + print "-noins : don't create the ins file\n"; + print "-prefinale <text> : add <text> immediately prior to \\Finale\n"; + print "-macrocode <expr> : surround any file which matches <expr> in a macrocode environment\n"; + print "-comment <expr> : surround any file which matches <expr> with \\iffalse \\fi pair\n"; + print "-codetitle <text> : The title for the documented code section (default: The Code)\n"; + print "-h : help message\n"; + print "-v : verbose\n\n"; print "Examples:\n\n"; @@ -614,7 +664,7 @@ sub help print "called foo.sty. The dtx file should be called foo.dtx and the ins file\n"; print " should be called foo.ins\n\n"; - print "$0 -src \"foosrc\\.sty=>foo.sty\" -doc foodoc.tex foo\n\n"; + print "makedtx -src \"foosrc\\.sty=>foo.sty\" -doc foodoc.tex foo\n\n"; print "Example 2:\n"; print "Documenation is in bardoc.tex\n"; @@ -623,11 +673,11 @@ sub help print "version should be called bar.bst. The dtx file should be called bar.dtx and\n"; print "the ins file should be called bar.ins\n\n"; - print "$0 -src \"barsrc\\.sty=>bar.sty\" -src \"barsrc\\.bst=>bar.bst\" -doc bardoc.tex bar\n\n"; + print "makedtx -src \"barsrc\\.sty=>bar.sty\" -src \"barsrc\\.bst=>bar.bst\" -doc bardoc.tex bar\n\n"; print "Or\n\n"; - print "$0 -src \"barsrc\\.(bst|sty)=>bar.\$1\" -doc bardoc.tex bar\n\n"; + print "makedtx -src \"barsrc\\.(bst|sty)=>bar.\$1\" -doc bardoc.tex bar\n\n"; die; } @@ -648,7 +698,7 @@ sub getnextgroup { my($curline) = @_; - $curline = eatinitialspaces($curline); + $curline = &eatinitialspaces($curline); # check to see if current string is blank |