STY2DTX(1)

πŸ“¦
version 76924 Β· 2 versions
  • 76924 Β· arch rolling, debian bookworm, debian trixie, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 2021.20220204 Β· ubuntu jammy
, in arch rolling, debian bookworm, debian trixie, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– sty2dtx(1) πŸ’–

ok bestie, gather round, because this one is sty2dtx, a little Perl script from the User Contributed Perl Documentation section of your man pages, and honestly? it's giving glow-up arc for your LaTeX files. ✨


🌸 NAME 🌸

sty2dtx β€” no cap, it converts a LaTeX .sty file to a documented .dtx file. that's it. that's the whole job. iconic. πŸŽ€


πŸ¦‹ VERSION πŸ¦‹

Version: v2.4 - 2022/10/18 β€” yeah she's a 2022 girlie but she still slays πŸ’…


if something's broken, that last one is literally where you go. do not come for me, come for the issue tracker 🫢


Copyright (c) 2010-2022 Martin Scharrer <martin.scharrer@web.de>

ok so legally speaking, and I am being fr fr here: 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 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 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. that's the dramatic part, keep it. πŸ’€ see the GNU General Public License for more details.

you should have received a copy of the GNU General Public License along with this program. if not β€” and this is your sign β€” see https://www.gnu.org/licenses/.


πŸ’œ DESCRIPTION πŸ’œ

So what does she actually DO. She takes your .sty file (a LaTeX package) and turns it into .dtx format (documented LaTeX source) by wrapping those macro definitions in macro and macrocode environments. the macro name? auto-inserted as the argument to the macro environment. no manual labor, we love to see it 😌

and if there's code lines hanging around outside of macro definitions? those get wrapped in macrocode environments only. empty lines get removed entirely (they were not serving).

ngl, real talk: this script is not meant to be fool proof or 100% accurate. it's a good start for converting undocumented style files into .dtx files β€” a starting point, not a miracle worker. set your expectations accordingly bestie πŸ™ˆ

✨ Basic Usage ✨

perl sty2dtx.pl infile [infile ...] outfile

or

perl sty2dtx.pl < file.sty > file.dtx

πŸ” Supported Definitions πŸ”

These macro definitions get detected when they're at the start of a line β€” and yes, they 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

And these environment definitions get detected when they're at the start of a line:

\newenvironment{name}  \renewenvironemnt{name}  \provideenvironment{name}

Now the rules, bestie, because there ARE rules: the macro and environment definition must either end at the same line or end with a "}" on its own on a line. that's the deal. 🀝


🌈 USAGE 🌈

sty2dtx [<options>] [--<VAR>=<VALUE> ...] [--] [<infile(s)>] [<outfile>]

πŸŽ€ Files πŸŽ€

  • can be "-" for STDIN or STDOUT, which is the default if no files are given
  • multiple input files are merged to one output file

🧚 Variables 🧚

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),

πŸ’… Options πŸ’…

  • -h β€” Print this help text
  • -H β€” Print extended help
  • -V β€” Print version and copyright
  • -v β€” Be verbose
  • -o output β€” Use given file as output
  • -O β€” Overwrite already existing output file(s)
  • -B β€” Use basename of single input file for output file
  • -I β€” Also create .ins (install) file
  • -c β€” Only use code section (like v1.0)
  • -r β€” Remove existing macro, macrocode, etc. environments.
  • -R β€” Do not remove existing macro, macrocode, etc. environments.
  • -i ins-file β€” Create .ins file with given name
  • -t template β€” Use this file as template instead of the default one
  • -T template β€” Use this file as template for the .ins file
  • -e file β€” Export default .dtx template to file and exit
  • -E file β€” Export default .ins template to file and exit
  • -D β€” Use current date as file date
  • -F file β€” Read more options and variables from file.
  • -N β€” Do not read default config file; must be the first option

πŸ“ Config files πŸ“

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 "%" or "#" are ignored. (those are the comment girlies, let them be πŸ’œ)

⭐ Examples ⭐

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 me@there.com mypkg.sty mypkg.dtx

Produce DTX file for a class:

sty2dtx.pl --type class mycls.sty mycls.dtx

πŸ‘‘ AUTHOR πŸ‘‘

Martin Scharrer

E-mail: martin.scharrer@web.de

WWW: <http://www.scharrer-online.de>


and that's the whole page bestie!! perl v5.30.0, dated 2022-10-18 β€” so if you ever see that footer floating around, that's this exact girl. go forth and document your style files, you main character. πŸ¦‹βœ¨πŸŽ€