Converts a latex .sty file to a documented .dtx file
Version: v2.3
Copyright (c) 2010-2012 Martin Scharrer <[email protected]>
This program is free software: you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of \s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See the \s-1GNU\s0 General Public License for more details.
You should have received a copy of the \s-1GNU\s0 General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Converts a .sty file (LaTeX package) to .dtx format (documented LaTeX source), by surrounding macro definitions with 'macro' and 'macrocode' environments. The macro name is automatically inserted as an argument to the 'macro' environemnt. Code lines outside macro definitions are wrapped only in 'macrocode' environments. Empty lines are removed. The script is not thought to be fool proof and 100% accurate but rather as a good start to convert undocumented style files to .dtx files.
perl sty2dtx.pl infile [infile ...] outfile
or
perl sty2dtx.pl < file.sty > file.dtx
The following macro definitions are detected when they are at the start of a line (can be prefixed by \global, \long, \protected and/or \outer):
\def \edef \gdef \xdef \newcommand{\name} \newcommand*{\name} \newcommand\name \newcommand*\name \renewcommand{\name} \renewcommand*{\name} \renewcommand\name \renewcommand*\name \providecommand{\name} \providecommand*{\name} \providecommand\name \providecommand*\name \@namedef{\name} \@namedef\name
The following environment definitions are detected when they are at the start of a line:
\newenvironment{name} \renewenvironemnt{name} \provideenvironment{name}
The macro and environment definition must either end at the same line or with a '\*(C`}\*(C'' on its own on a line.
sty2dtx [<options>] [--<VAR>=<VALUE> ...] [--] [<infile(s)>] [<outfile>]
can be '\*(C`-\*(C'' for \s-1STDIN\s0 or \s-1STDOUT\s0, which is the default if no files are given
multiple input files are merged to one output file
Variables can be defined using
--<VAR>=<VALUE>
or
--<VAR> <VALUE>
and will be used for substitutions in the template file.
Common variables:
author, email, maintainer, year (for copyright), version, date, description (of package/class), type (either 'package' default or 'class'), filebase (automatically set from output or input file name),
A default config file either named 'sty2dtx.cfg' or '.sty2dtx.cfg' is searched in the current directory, the users home directory and the directory of this script, in this order. The first one found is loaded. If none is found the 'texmf' tree is searched for a 'sty2dtx.cfg' config file. As with -F files the config file should contain one option or variable per line. Lines starting with '\*(C`%\*(C'' or '\*(C`#\*(C'' are ignored.
Produce 'file.dtx' from 'file.sty':
sty2dtx.pl < file.sty > file.dtx
or
sty2dtx.pl file.sty file.dtx
or
sty2dtx.pl -B file.sty
Produce 'file.dtx' and 'file.ins' from 'file.sty':
sty2dtx.pl -I file.sty file.dtx
or
sty2dtx.pl file.sty -i file.sty file.dtx
or
sty2dtx.pl -IB file.sty
Set custom variable values:
sty2dtx.pl --author Me --email [email protected] mypkg.sty mypkg.dtx
Produce \s-1DTX\s0 file for a class:
sty2dtx.pl --type class mycls.sty mycls.dtx
Martin Scharrer
E-mail: [email protected]
\s-1WWW:\s0 http://www.scharrer-online.de <http://www.scharrer-online.de>