summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ydoc/ydoc-code.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-04-10 21:56:52 +0000
committerKarl Berry <karl@freefriends.org>2010-04-10 21:56:52 +0000
commit5406b8e0ea1d596600f773e766975256e4087c51 (patch)
tree74d244f62ddcc29123ecef56e914cc0fd7bd6de3 /Master/texmf-dist/tex/latex/ydoc/ydoc-code.sty
parent4f711ec63a6c65e74a08a634bc886ee54b2140fe (diff)
new latex package ydoc (10apr10)
git-svn-id: svn://tug.org/texlive/trunk@17793 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/ydoc/ydoc-code.sty')
-rw-r--r--Master/texmf-dist/tex/latex/ydoc/ydoc-code.sty199
1 files changed, 199 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/ydoc/ydoc-code.sty b/Master/texmf-dist/tex/latex/ydoc/ydoc-code.sty
new file mode 100644
index 00000000000..2581ec83ec3
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/ydoc/ydoc-code.sty
@@ -0,0 +1,199 @@
+%%
+%% This is file `ydoc-code.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% ydoc.dtx (with options: `code')
+%%
+%% Copyright (c) 2010 by Martin Scharrer <martin@scharrer-online.de>
+%% WWW: http://latex.scharrer-online.de/
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Martin Scharrer.
+%%
+%% This work consists of the files ydoc.dtx and ydoc.ins
+%% and the derived file ydoc.cls, ydoc.sty, ydoc-code.sty,
+%% ydoc-expl.sty and ydoc-desc.sty.
+%%
+\RequirePackage{svn-prov}[2010/04/03]
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+\ProvidesPackageSVN
+ [ydoc-code]
+ {$Id: ydoc.dtx 1847 2010-04-10 10:57:11Z martin $}
+ [v0.1alpha]
+ [ydoc package to document macro code]
+\RequirePackage{xcolor}
+\definecolor{macroimpl}{rgb}{0.0,0.0,0.4}
+\@ifundefined{ydocwrite}{%
+ \newwrite\ydocwrite
+}{}
+\@ifundefined{ydocfname}{%
+ \def\ydocfname{\jobname.cod}%
+}{}
+\def\ydoc@catcodes{%
+ \let\do\@makeother
+ \dospecials
+ \catcode`\\=\active
+ \catcode`\^^M=\active
+ \catcode`\ =\active
+}
+\def\macrocode{%
+ \par\noindent
+ \begingroup
+ \ydoc@catcodes
+ \macro@code
+}
+\def\endmacrocode{}
+\begingroup
+\endlinechar\m@ne
+\@firstofone{%
+\catcode`\|=0\relax
+\catcode`\(=1\relax
+\catcode`\)=2\relax
+\catcode`\*=14\relax
+\catcode`\{=12\relax
+\catcode`\}=12\relax
+\catcode`\ =12\relax
+\catcode`\%=12\relax
+\catcode`\\=\active
+\catcode`\^^M=\active
+\catcode`\ =\active
+}*
+|gdef|macro@code#1^^M% \end{macrocode}(*
+|endgroup|expandafter|macro@@code|expandafter(|ydoc@removeline#1|noexpand|lastlinemacro^^M)*
+)*
+|gdef|ydoc@removeline#1^^M(|noexpand|firstlinemacro)*
+|gdef|ydoc@defspecialmacros(*
+|def^^M(|noexpand|newlinemacro)*
+|def (|noexpand|spacemacro)*
+|def\(|noexpand|bslashmacro)*
+)*
+|gdef|ydoc@defrevspecialmacros(*
+|def|newlinemacro(|noexpand^^M)*
+|def|spacemacro(|noexpand )*
+|def|bslashmacro(|noexpand\)*
+)*
+|endgroup
+\def\macro@@code#1{%
+ {\ydoc@defspecialmacros
+ \xdef\themacrocode{#1}}%
+ \PrintMacroCode
+ \end{macrocode}%
+}
+\def\newlinemacro{\\\null}
+\def\spacemacro{\ }
+\def\bslashmacro{\char92}
+\def\lastlinemacro#1{}
+\def\firstlinemacro{\linenumberbox}
+\def\newlinemacro{\\\linenumberbox}
+\newcounter{linenumber}
+\def\linenumberbox{%
+ \hbox to 1.25em{}%
+ \llap{%
+ \stepcounter{linenumber}%
+ {\footnotesize\color{gray}\thelinenumber~}%
+ }%
+}
+\def\PrintMacroCode{%
+ \begingroup
+ \ttfamily
+ \noindent\themacrocode
+ \endgroup
+}
+\RequirePackage{listings}
+\def\PrintMacroCode{%
+ \begingroup
+ \let\firstlinemacro\empty
+ \let\lastlinemacro\empty
+ \def\newlinemacro{^^J}%
+ \let\bslashmacro\bslash
+ \let\spacemacro\space
+ \immediate\openout\ydocwrite=\ydocfname\relax
+ \immediate\write\ydocwrite{\themacrocode}%
+ \immediate\closeout\ydocwrite
+ \@nameuse{ydoc@countbslashes}%
+ \ydoclistingssettings
+ \let\input\@input
+ \lstinputlisting{\ydocfname}%
+ \endgroup
+}
+\def\ydoclistingssettings{%
+ \lstset{%
+ language=[latex]tex,basicstyle=\ttfamily,
+ numbers=left,numberstyle=\tiny\color{gray},firstnumber=last,
+ breaklines,prebreak={\mbox{\tiny$\swarrow$}}%
+ }%
+}
+\def\macro@impl@args[#1]{%
+ \begingroup
+ \parindent=10pt\relax
+ \let\macro@impl@argcnt\@tempcnta
+ \let\macro@impl@curarg\@tempcntb
+ \macro@impl@argcnt=#1\relax
+ \macro@impl@curarg=0\relax
+ \ifnum\macro@impl@curarg<\macro@impl@argcnt\relax
+ \expandafter\macro@impl@arg
+ \else
+ \expandafter\macro@impl@endargs
+ \fi
+}
+\def\macro@impl@endargs{%
+ \endgroup
+ \unskip\par\noindent\ignorespaces
+}
+\def\macro@impl@argline#1#2{%
+ \par{\texttt{\##1}:~#2}%
+}
+\def\macro@impl@arg#1{%
+ \advance\macro@impl@curarg by\@ne\relax
+ \macro@impl@argline{\the\macro@impl@curarg}{#1}%
+ \ifnum\macro@impl@curarg<\macro@impl@argcnt\relax
+ \expandafter\macro@impl@arg
+ \else
+ \expandafter\macro@impl@endargs
+ \fi
+}
+\def\macro#1{%
+ \PrintMacroImplName{#1}%
+ \@ifnextchar[%]
+ {\macro@impl@args}%
+ {}%
+}
+\def\endmacro{}
+\def\environment#1{%
+ \PrintEnvImplName{#1}%
+ \@ifnextchar[%]
+ {\macro@impl@args}%
+ {}%
+}
+\def\endenvironment{}
+\def\PrintMacroImplName#1{%
+ \par\bigskip\noindent
+ \hbox{\hspace*{\descindent}\fbox{{\implstyle{\string#1}}}}%
+ \par\medskip\noindent
+}
+\def\PrintEnvImplName#1{%
+ \par\bigskip\noindent
+ \hbox{\hspace*{\descindent}\fbox{{\implstyle{#1}}}}%
+ \par\medskip
+}
+\def\implstyle{\ttfamily\bfseries\color{macroimpl}}
+{%
+\@firstofone{%
+ \catcode`\\=12
+ \gdef\bslash
+}{\}
+}%}
+\endinput
+%%
+%% End of file `ydoc-code.sty'.