From 3233d950f8aaf764441b77b3f158a45f581df79e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 7 Nov 2012 23:47:40 +0000 Subject: sty2dtx (7nov12) git-svn-id: svn://tug.org/texlive/trunk@28206 c570f23f-e606-0410-a88d-b1316a301751 --- .../texk/texlive/linked_scripts/sty2dtx/sty2dtx.pl | 599 +++++++++++++++------ 1 file changed, 442 insertions(+), 157 deletions(-) (limited to 'Build/source/texk') diff --git a/Build/source/texk/texlive/linked_scripts/sty2dtx/sty2dtx.pl b/Build/source/texk/texlive/linked_scripts/sty2dtx/sty2dtx.pl index 5c0730ca5bb..e68b667141c 100755 --- a/Build/source/texk/texlive/linked_scripts/sty2dtx/sty2dtx.pl +++ b/Build/source/texk/texlive/linked_scripts/sty2dtx/sty2dtx.pl @@ -1,45 +1,59 @@ #!/usr/bin/env perl use strict; use warnings; -################################################################################ -# $Id: sty2dtx.pl 2125 2011-02-02 15:25:40Z martin $ -################################################################################ -my $COPYRIGHT = << 'EOT'; - Copyright (c) 2010-2011 Martin Scharrer +use File::Basename qw(dirname); - 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. +=head1 NAME - 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. See the - GNU General Public License for more details. +sty2dtx -- Converts a LaTeX .sty file to a documented .dtx file - You should have received a copy of the GNU General Public License - along with this program. If not, see . +=head1 VERSION + +Version: v2.3 + +=head1 COPYRIGHT + +Copyright (c) 2010-2012 Martin Scharrer + +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. 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, see . + + +=head1 DESCRIPTION + +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. + + +=head2 Basic Usage -EOT -################################################################################ -my $DESCRIPTION = << 'EOT'; - 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. - - Usage: perl sty2dtx.pl infile [infile ...] outfile - or + +or + perl sty2dtx.pl < file.sty > file.dtx +=head2 Supported Definitions + +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): - 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 @@ -49,83 +63,183 @@ my $DESCRIPTION = << 'EOT'; \providecommand\name \providecommand*\name \@namedef{\name} \@namedef\name - The following environment definitions are detected when they are at the start - of a line: +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 '}' on its own on a line. +The macro and environment definition must either end at the same line or with +a 'C<}>' on its own on a line. -EOT -################################################################################ -my $VERSION = "v2.1 " . substr( '$Date: 2011-02-02 15:25:40 +0000 (Wed, 02 Feb 2011) $', 7, 10 ); -$VERSION =~ tr/-/\//; -my $TITLE = << "EOT"; - sty2dtx -- Converts a LaTeX .sty file to a documented .dtx file - Version: $VERSION -EOT -sub usage { - print << "EOT"; -sty2dtx.pl [] [--= ...] [--] [ ...] [] -Version: $VERSION -EOT - print << 'EOT'; -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: - can be defined using --= or -- and will be used for - substitutions in the template file. - Common variables: +=head1 USAGE + + sty2dtx [] [--= ...] [--] [] [] + +=head2 Files + +=over 2 + +=item * + can be 'C<->' for STDIN or STDOUT, which is the default if no files are given + +=item * + multiple input files are merged to one output file + +=back + +=head2 Variables + +Variables can be defined using + + --= + +or + + -- + +and will be used for substitutions in the template file. + +=head3 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 : 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) - -i : Create .ins file with given name - -t