diff options
author | Karl Berry <karl@freefriends.org> | 2018-02-21 23:30:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-02-21 23:30:25 +0000 |
commit | db6b6d35b031d5c4294428a844e30b8d2d5dce9c (patch) | |
tree | 091ad8d81024624632dd315b1b94b53c7d85524c /Master/texmf-dist/source | |
parent | 3908d5ba9809b4ede985cb626410781fdf499ee1 (diff) |
makedtx (21feb18)
git-svn-id: svn://tug.org/texlive/trunk@46702 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/support/makedtx/makedtx.dtx | 316 | ||||
-rw-r--r-- | Master/texmf-dist/source/support/makedtx/makedtx.ins | 20 |
2 files changed, 206 insertions, 130 deletions
diff --git a/Master/texmf-dist/source/support/makedtx/makedtx.dtx b/Master/texmf-dist/source/support/makedtx/makedtx.dtx index eaefdfe11df..8bf2eff18f1 100644 --- a/Master/texmf-dist/source/support/makedtx/makedtx.dtx +++ b/Master/texmf-dist/source/support/makedtx/makedtx.dtx @@ -1,18 +1,25 @@ %\iffalse -% makedtx.dtx generated using makedtx version 0.94b (c) Nicola Talbot +% makedtx.dtx generated using makedtx version 1.2 (c) Nicola Talbot % Command line args: -% -macrocode ".*\.p.*l" -% -src "creatdtx.(.*)=>creatdtx.\1" -% -src "makedtx=>makedtx.pl" -% -author "Nicola Talbot" +% -src "CHANGES\.org$=>CHANGES.org" +% -src "makedtx-version\.tex$=>makedtx-version.tex" +% -src "latexmkrc\.pl$=>latexmkrc.pl" +% -src "createdtx\.sty$=>createdtx.sty" +% -src "makedtx\.pl$=>makedtx.pl" +% -author "Nicola L.C. Talbot" +% -doc "makedtx.tex" +% -setambles "\.pl$=>\nopreamble\nopostamble" +% -macrocode "makedtx\.pl$" +% -macrocode "CHANGES\.org$" +% -macrocode "makedtx-version\.tex$" +% -macrocode "latexmkrc\.pl$" % -v "1" -% -dir "source" -% -setambles ".*\.p.*l=>\nopreamble\nopostamble" -% -comment ".*\.p.*l" -% -doc "manual.tex" -% -codetitle "creatdtx.sty code" +% -comment "makedtx\.pl$" +% -comment "CHANGES\.org$" +% -comment "makedtx-version\.tex$" +% -comment "latexmkrc\.pl$" % makedtx -% Created on 2007/8/19 14:16 +% Created on 2018/2/21 16:13 %\fi %\iffalse %<*package> @@ -35,11 +42,11 @@ %\fi % \iffalse % Doc-Source file to use with LaTeX2e -% Copyright (C) 2007 Nicola Talbot, all rights reserved. +% Copyright (C) 2018 Nicola L.C. Talbot, all rights reserved. % \fi % \iffalse %<*driver> -\documentclass[a4paper]{ltxdoc} +\documentclass[a4paper,english]{ltxdoc} \usepackage[colorlinks, bookmarks, @@ -47,6 +54,9 @@ bookmarksopen, pdfauthor={Nicola Talbot}, pdftitle={makedtx : a Perl script to help create a DTX file from source code}]{hyperref} +\usepackage{createdtx} +\usepackage{datetime2} +\DTMsetstyle{english} \renewcommand{\usage}[1]{\textit{\hyperpage{#1}}} @@ -64,18 +74,20 @@ \CheckSum{8} \newcommand{\PDFLaTeX}{PDF\LaTeX} +\DTMsavedate{makedtx-date}{2018-02-19} - +\input{makedtx-version} \begin{document} \DocInput{makedtx.dtx} \end{document} %</driver> %\fi -%\title{makedtx v0.94b : a Perl script to help create a DTX +% +%\title{makedtx \version : a Perl script to help create a DTX %file from source code} %\author{Nicola Talbot\\ %\url{http://theoval.cmp.uea.ac.uk/~nlct/}} -%\date{19th August 2007} +%\date{\DTMusedate{makedtx-date}} %\maketitle % %\tableofcontents @@ -334,6 +346,13 @@ %source code is inserted into a \texttt{macrocode} environment in the %DTX file. % +%Please note that the source code is supposed to be text insensitive to end of line format, as a matter of fact +%\texttt{makedtx.pl} will convert all end of lines of this source code to LF's. +% +%Please note also that only the source files given by the \switch{src} switch are considered, the +%\switch{macrocode} switch by itself does not cause the source file to be insterted into the DTX file, it only +%affects \emph{how} it is inserted. +% %\item[\switch{comment} \texttt{"}\meta{expr}\texttt{"}] %\changes{0.93}{2007/08/02}{comment switch added}% %If the source file matches the Perl regular expression given by @@ -412,7 +431,7 @@ % % \end{macrocode} %\end{verbatim} %Now let's make some (very brief) documentation. Let's call the file, -%say \texttt{manual.tex}\footnote{Note: if you want to use +%say \texttt{manual.tex}\footnote{Note: if you want to use %\latextohtml\ on this document, you will need to use, e.g., %\cs{verb}\texttt{!\cs{today}!} instead of %\texttt{\symbol{124}\cs{today}\symbol{124}} since it doesn't recognise @@ -713,7 +732,7 @@ %\end{verbatim} %then if you pass the following switch to \texttt{makedtx.pl}: %\begin{itemize} -%\item \verb'-src "abcsrc\.([styb]+)=>abc.\1"' +%\item \verb'-src "abcsrc\.([styb]+)=>abc.\1"' %will be equivalent to: %\begin{verbatim} %-src "abcsrc.sty=>abc.sty" -src "abcsrc.bst=>abc.bst" @@ -759,98 +778,106 @@ %\PrintIndex} % % -% -% -%\section{creatdtx.sty code} +%\section{The Code} %\iffalse % \begin{macrocode} -%<*creatdtx.perl> +%<*CHANGES.org> % \end{macrocode} %\fi %\iffalse % \begin{macrocode} -# creatdtx.perl LaTeX2HTML file corresponding to creatdtx.sty package -# author : Nicola Talbot -# date : 2nd August 2007 +* version 1.2 2018/02/19 -package main; ++ Under MSW use envvar USERNAME rather than getpwuid for getting + author default value ++ User Perl I/O layers in order to have LF EOL on output, and accept + both LF and CRLF on input ++ Create a test bench --- add a testmode option so that date in output + is fixed and output is comparable to a reference value. ++ Fix perl warning about escaping { in regexp. ++ Semi-colonize end of here-documents as recommended in Perl Manual. ++ Fix --version cli argument, so that version is flushed to stdout + before script exits. ++ Automate packaging -print " [creatdtx v0.93b (N.L.C. Talbot)]"; -sub do_cmd_meta -{ - &do_cmd_emph(@_); -} +* version 0.94 (2007/08/19) : -sub do_cmd_cs{ - local($_) = @_; - local($name); ++ Default preamble changed to one which conforms with the + LaTeX Project Public License (LPPL) ++ license switch added - $name = &missing_braces unless - (s/$next_pair_pr_rx/$name=$2;''/eo); +* version 0.93 (2007/08/02) : - "<TT>\$name</TT>$_"; -} - -sub do_cmd_marg{ - local($_) = @_; - local($arg); ++ version switch added ++ comment switch added ++ codetitle switch added - $arg = &missing_braces unless - (s/$next_pair_pr_rx/$arg=$2;''/eo); +* version 0.91 (2006/07/21) : - "<TT>{</TT><EM>$arg</EM><TT>}</TT>$_"; -} ++ prefinale switch added -sub do_cmd_oarg{ - local($_) = @_; - local($arg); +* version 0.9 (2005/02/11) : - $arg = &missing_braces unless - (s/$next_pair_pr_rx/$arg=$2;''/eo); ++ Initial beta release +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%</CHANGES.org> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*makedtx-version.tex> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +\newcommand*\version{v1.2} +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%</makedtx-version.tex> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*latexmkrc.pl> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +$dvi_mode = 0; +$pdf_mode = 1; - "<TT>[</TT><EM>$arg</EM><TT>]</TT>$_"; +@default_files=(); +foreach $file (glob('makedtx.{dtx,tex}')) +{ + if(-e $file){ + @default_files=($file); + break; + } } -sub do_cmd_parg{ - local($_) = @_; - local($arg); - - $arg = &missing_braces unless - (s/$next_pair_pr_rx/$arg=$2;''/eo); - - "<TT>(</TT><EM>$arg</EM><TT>)</TT>$_"; +$makeindex= "makeindex -s gind.ist %O -o %D %S"; + +# 1. For glossaries using glossary package --- \changes generatated by the ltxdoc \changes directive +add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' ); +sub makeglo2gls { + system("makeindex -s gglo.ist -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" ); } - -&ignore_commands( <<_IGNORED_CMDS_); -ifmakedtx # {} -StopEventually # {} -OnlyDescription -RecordChanges -PrintChanges -EnableCrossRefs -CodelineIndex -GetFileInfo # {} -CheckSum # {} -DescribeMacro # {} -DescribeEnvironment # {} -DoNotIndex # {} -changes # {} # {} # {} -DeleteShortVerb # {} -MakeShortVerb # {} -_IGNORED_CMDS_ - -1; % \end{macrocode} %\fi %\iffalse % \begin{macrocode} -%</creatdtx.perl> +%</latexmkrc.pl> % \end{macrocode} %\fi %\iffalse % \begin{macrocode} -%<*creatdtx.sty> +%<*createdtx.sty> % \end{macrocode} %\fi % This is the code for the \texttt{creatdtx} package. This @@ -869,9 +896,11 @@ _IGNORED_CMDS_ \providecommand{\StopEventually}{} \renewcommand{\StopEventually}[1]{#1} % \end{macrocode} -%\iffalse +\iffalse Local Variables:\fi +\iffalse mode: DocTeX\fi +\iffalse End:\fi%\iffalse % \begin{macrocode} -%</creatdtx.sty> +%</createdtx.sty> % \end{macrocode} %\fi %\iffalse @@ -886,48 +915,62 @@ _IGNORED_CMDS_ # File : makedtx # Author : Nicola L. C. Talbot # Date : 29 Oct 2004 -# Last Modified : 19 Aug 2007 -# Version : 0.94b +# Last Modified : 2017-04-08 +# Version : 1.2 # 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) +# -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.94b"; +$version = "1.2"; # process command line options %optctl = (); +# v1.1 added section switch &GetOptions(\%optctl, "h", "help", "v", "src=s@", "doc=s", "dir=s", "op=s", "askforoverwrite!", "ins!", -"preamble=s", "postamble=s", "setambles=s@", "macrocode=s@", +"preamble=s", "postamble=s", "setambles=s@", "testmode", "macrocode=s@", "author=s", "date=s", "stopeventually=s", "prefinale=s", "codetitle=s", "comment=s@", -"version", "license=s") or &syntaxerror(); +"version", "license=s", "section=s") or &syntaxerror(); $srcdir = "."; $patternop = "="; $verbose = 0; $noins = 0; +$testmode = 0; $askforoverwrite = 0; $preamble = ""; $postamble = ""; -$author = (getpwuid($<))[6] || 'Unknown'; +my $author; +if ($^O =~ m/MSWin/) +{ + $author = $ENV{"USERNAME"}; + if ($author eq ""){ $author = 'Unknown';} +} +else +{ + $author = (getpwuid($<))[6] || 'Unknown'; +} $stopeventually = ""; $prefinale = ""; $codetitle = "The Code"; +$section = "section"; $license = "lppl"; ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); $year = $year + 1900; +$copyright_date = $year; +$creation_date = "$year/" . ($mon+1) . "/$mday $hour:" . ($min<10?"0$min" : $min); foreach $setting (keys %optctl) { @@ -937,7 +980,8 @@ foreach $setting (keys %optctl) } elsif ($setting eq "version") { - die "makedtx version $version\n"; + print "makedtx version $version\n"; + exit 0; } elsif ($setting eq "doc") { @@ -989,7 +1033,7 @@ foreach $setting (keys %optctl) } elsif ($setting eq "date") { - $year = $optctl{$setting}; + $copyright_date = $optctl{$setting}; } elsif ($setting eq "stopeventually") { @@ -1003,6 +1047,20 @@ foreach $setting (keys %optctl) { $codetitle = $optctl{$setting}; } + elsif ($setting eq "section") + { + $section = $optctl{$setting}; + } + elsif ($setting eq "testmode") + { + $testmode = $optctl{$setting}; + if($testmode) + { + $version = "x.y"; + $copyright_date = "YYYY"; + $creation_date = "YYYY/MM/DD hh:mm"; + } + } elsif ($setting eq "comment") { @comment = @{ $optctl{$setting} }; @@ -1033,7 +1091,7 @@ if ($#source == -1) &syntaxerror(); } -open DTX, ">$basename.dtx" or die "Can't open '$basename.dtx'\n"; +open DTX, ">:unix","$basename.dtx" or die "Can't open '$basename.dtx'\n"; if ($verbose) { @@ -1084,7 +1142,7 @@ foreach $source (@source) $file{$thisinfile} = $thisoutfile; $derivedfiles[$numoutput]{'in'} = $thisinfile; - $derivedfiles[$numoutput]{'out'} = $thisoutfile; + $derivedfiles[$numoutput]{'out'} = $thisoutfile; $outputfiles[$numoutput] = $thisoutfile; $numoutput++; @@ -1096,14 +1154,15 @@ if ($preamble eq "") { if ($license eq "lppl") { - $preamble = <<_END_LICENSE +# v1.2 fixed typo in preamble + $preamble = <<_END_LICENSE; $basename.dtx - Copyright $year $author + Copyright $copyright_date $author This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 - of this license of (at your option) any later version. + of this license or (at your option) any later version. The latest version of this license is in http://www.latex-project.org/lppl.txt and version 1.3 or later is part of all distributions of LaTeX @@ -1117,10 +1176,10 @@ _END_LICENSE } elsif ($license eq 'bsd') { - $preamble = <<_END_LICENSE + $preamble = <<_END_LICENSE; $basename.dtx - Copyright (c) $year $author + Copyright (c) $copyright_date $author All rights reserved. Redistribution and use in source and binary forms, with or without @@ -1149,10 +1208,10 @@ _END_LICENSE } elsif ($license eq 'gpl') { - $preamble = <<_END_LICENSE + $preamble = <<_END_LICENSE; $basename.dtx - Copyright (c) $year $author + Copyright (c) $copyright_date $author This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1177,58 +1236,65 @@ _END_LICENSE } $preamble .= " This work consists of the files " - . "$basename.dtx and $basename.ins and the derived " - . ($numoutput > 1 ? "files" : "file") + . "$basename.dtx and $basename.ins and the derived " + . ($numoutput > 1 ? "files" : "file") . " " . join(', ', @outputfiles) . ".\n"; } -open DOC, $docsrc or die "Can't open '$docsrc'\n"; +open DOC, '<:crlf',$docsrc or die "Can't open '$docsrc'\n"; print DTX "\%\\iffalse\n"; print DTX "\% $basename.dtx generated using makedtx version $version (c) Nicola Talbot\n"; print DTX "\% Command line args:\n"; +@cmdline_args = (); foreach $setting (keys %optctl) { if ($setting eq "src") { foreach $source (@source) { - print DTX "\% -src \"$source\"\n"; + push @cmdline_args ,"-src \"$source\""; } } elsif ($setting eq "setambles") { foreach $setamble (@setambles) { - print DTX "\% -setambles \"$setamble\"\n"; + push @cmdline_args ,"-setambles \"$setamble\""; } } elsif ($setting eq "macrocode") { foreach $macrocode (@macrocode) { - print DTX "\% -macrocode \"$macrocode\"\n"; + push @cmdline_args ,"-macrocode \"$macrocode\""; } } elsif ($setting eq "comment") { foreach $comment (@comment) { - print DTX "\% -comment \"$comment\"\n"; + push @cmdline_args ,"-comment \"$comment\""; } } else { $val = $optctl{$setting}; $val=~s/\\/\\\\/g; - print DTX "\% -", $setting, " \"", $val, "\"\n"; + push @cmdline_args ,("-" . $setting . " \"" . $val . "\""); } } +if($testmode){ + @cmdline_args = sort @cmdline_args; +} +foreach $arg (@cmdline_args){ + print DTX "\% ", $arg , "\n"; +} print DTX "\% $basename\n"; -print DTX "\% Created on $year/", $mon+1, "/$mday $hour:", $min<10?"0$min" : $min,"\n"; +print DTX "\% Created on $creation_date\n"; print DTX "\%\\fi\n"; print DTX "\%\\iffalse\n"; print DTX "\%<*package>\n"; @@ -1252,7 +1318,7 @@ print DTX "\%\\fi\n"; print DTX "\% \\iffalse\n"; print DTX "\% Doc-Source file to use with LaTeX2e\n"; -print DTX "\% Copyright (C) $year $author, all rights reserved.\n"; +print DTX "\% Copyright (C) $copyright_date $author, all rights reserved.\n"; print DTX "\% \\fi\n"; # driver @@ -1264,7 +1330,7 @@ $indoc=0; while (<DOC>) { - s/\\usepackage{creatdtx}//; + s/\\usepackage\{creatdtx}//; $restofline = $_; @@ -1324,7 +1390,7 @@ while (<DOC>) print DTX $line; - if ($line=~/\\begin{document}/) + if ($line=~/\\begin\{document}/) { $indoc = 1; @@ -1344,12 +1410,12 @@ print DTX "\%"; while (<DOC>) { - if (/\\begin{verbatim}/) + if (/\\begin\{verbatim}/) { $inverb=1; } - if (/\\end{verbatim}/) + if (/\\end\{verbatim}/) { $inverb=0; } @@ -1415,11 +1481,11 @@ while (<DOC>) $line = $beginline . $restofline; - if (($line=~/\\end{document}/) and not $inverb) + if (($line=~/\\end\{document}/) and not $inverb) { $indoc=0; - $line=~s/\\end{document}//; + $line=~s/\\end\{document}//; } $line=~s/\n/\n\%/mg; @@ -1436,7 +1502,12 @@ if ($stopfound==0) print DTX "\%\\StopEventually{$stopeventually}\n"; } -print DTX "\%\\section{$codetitle}\n"; +# v1.0 added check +if ($codetitle) +{ + # v1.1 added section + print DTX "\%\\$section\{$codetitle\}\n"; +} for (my $idx = 0; $idx <= $#derivedfiles; $idx++) { @@ -1448,7 +1519,7 @@ for (my $idx = 0; $idx <= $#derivedfiles; $idx++) print "$srcdirfile -> $_ \n"; } - open SRC, $thisinfile or die "Can't open $thisinfile\n"; + open SRC, "<:crlf", $thisinfile or die "Can't open $thisinfile\n"; print DTX "\%\\iffalse\n"; print DTX "\% \\begin{macrocode}\n"; @@ -1511,9 +1582,9 @@ close DTX; if (!$noins) { - open INS, ">$basename.ins" or die "Can't open '$basename.ins'\n"; + open INS, ">:unix","$basename.ins" or die "Can't open '$basename.ins'\n"; - print INS "\% $basename.ins generated using makedtx version $version $year/",$mon+1,"/$mday $hour:", $min<10?"0$min":$min,"\n"; + print INS "\% $basename.ins generated using makedtx version $version $creation_date\n"; print INS "\\input docstrip\n\n"; print INS "\\preamble\n"; @@ -1646,6 +1717,7 @@ sub help 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 "-section <cs> : The sectioning command to use for the documented code section (default: 'section')\n"; print "-license <license> : use the given license for the preamble.\n"; print " Known licenses: lppl (default), bsd, gpl.\n"; print "-h : help message\n"; diff --git a/Master/texmf-dist/source/support/makedtx/makedtx.ins b/Master/texmf-dist/source/support/makedtx/makedtx.ins index 0f28af11859..d636d8ed0b4 100644 --- a/Master/texmf-dist/source/support/makedtx/makedtx.ins +++ b/Master/texmf-dist/source/support/makedtx/makedtx.ins @@ -1,14 +1,14 @@ -% makedtx.ins generated using makedtx version 0.94b 2007/8/19 14:16 +% makedtx.ins generated using makedtx version 1.2 2018/2/21 16:13 \input docstrip \preamble makedtx.dtx - Copyright 2007 Nicola Talbot + Copyright 2018 Nicola L.C. Talbot This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 - of this license of (at your option) any later version. + of this license or (at your option) any later version. The latest version of this license is in http://www.latex-project.org/lppl.txt and version 1.3 or later is part of all distributions of LaTeX @@ -16,17 +16,21 @@ This work has the LPPL maintenance status `maintained'. - The Current Maintainer of this work is Nicola Talbot. + The Current Maintainer of this work is Nicola L.C. Talbot. - This work consists of the files makedtx.dtx and makedtx.ins and the derived files creatdtx.perl, creatdtx.sty, makedtx.pl. + This work consists of the files makedtx.dtx and makedtx.ins and the derived files CHANGES.org, makedtx-version.tex, latexmkrc.pl, createdtx.sty, makedtx.pl. \endpreamble \askforoverwritefalse -\generate{\file{creatdtx.perl}{\nopreamble\nopostamble\from{makedtx.dtx}{creatdtx.perl}} -\file{creatdtx.sty}{\usepreamble\defaultpreamble -\usepostamble\defaultpostamble\from{makedtx.dtx}{creatdtx.sty,package}} +\generate{\file{CHANGES.org}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{makedtx.dtx}{CHANGES.org,package}} +\file{makedtx-version.tex}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{makedtx.dtx}{makedtx-version.tex,package}} +\file{latexmkrc.pl}{\nopreamble\nopostamble\from{makedtx.dtx}{latexmkrc.pl}} +\file{createdtx.sty}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{makedtx.dtx}{createdtx.sty,package}} \file{makedtx.pl}{\nopreamble\nopostamble\from{makedtx.dtx}{makedtx.pl}} } |