%% %% This is file `ydoc-desc.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% ydoc.dtx (with options: `desc') %% %% Copyright (c) 2010-2011 by Martin Scharrer %% 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-desc] {$Id: ydoc.dtx 2163 2011-02-16 17:19:27Z martin $} [v0.4alpha] [ydoc package to describe macros, environments, options etc.] \RequirePackage{hyperref} \hypersetup{colorlinks=true,pdfborder=0 0 0,pdfborderstyle={}} \RequirePackage{shortvrb} \RequirePackage{xcolor} \definecolor{macrodesc}{rgb}{0.0,0.0,0.8} \definecolor{macroimpl}{rgb}{0.0,0.0,0.4} \definecolor{meta}{rgb}{0.0,0.4,0.4} \definecolor{scriptcolor}{rgb}{0.2,0.6,0.2} \definecolor{optioncolor}{rgb}{0.3.0.2,0} \colorlet{optional}{black!65!white} \colorlet{metaoptional}{optional!50!meta} \def\meta#1{% \ensuremath\langle {\metastyle{#1\/}}% \ensuremath\rangle } \def\marg#1{\@marg{<#1>}} \def\oarg#1{\@oarg{<#1>}} \def\parg#1{\@parg{<#1>}} \def\aarg#1{\@aarg{<#1>}} \def\@marg#1{% {\margstyle{% {\ttfamily\braceleft}% {\def\end@Macro@args{}\read@Macro@arg#1}% {\ttfamily\braceright}% }}% } \def\@oarg#1{% {\oargstyle{% {\ttfamily[}% {\def\end@Macro@args{}\read@Macro@arg#1}% {\ttfamily]}% }}% } \def\@parg#1{% {\pargstyle{% {\ttfamily(}% {\def\end@Macro@args{}\read@Macro@arg#1}% {\ttfamily)}% }}% } \def\@aarg#1{% {\aargstyle{% {\ttfamily<}% {\def\end@Macro@args{}\read@Macro@arg#1}% {\ttfamily>}% }}% } \def\sarg{{\sargstyle{*}}} \RequirePackage{etoolbox} \newrobustcmd*\pkg{\texttt} \newrobustcmd*\cls{\texttt} \newrobustcmd*\env{\texttt} \newrobustcmd*\opt{\textsf} \newrobustcmd*\cs[1]{\texttt{\textbackslash #1}} \newrobustcmd*\cmd[1]{\texttt{{\escapechar=92\string#1}}} \def\macrodescstyle{\ttfamily\bfseries\color{macrodesc}} \def\macroargsstyle{\ttfamily} \def\envcodestyle{\ttfamily} \def\verbstyle{\ttfamily} \def\metastyle{\normalfont\itshape\color{meta}} \def\margstyle{} \def\oargstyle{\color{optional}\colorlet{meta}{metaoptional}} \def\pargstyle{} \def\aargstyle{} \def\sargstyle{\ttfamily\color{optional}} \newdimen\descindent \descindent=-\parindent \newdimen\beforedescskip \beforedescskip=\bigskipamount \newdimen\afterdescskip \afterdescskip=\medskipamount \newdimen\descsep \begingroup \ttfamily \global\descsep=1em\relax \endgroup \def\read@Macro@arg{% \futurelet\@let@token\handle@Macro@arg } \def\handle@Macro@arg{% \ifcase0% \ifx\@let@token\bgroup1\else \ifx\@let@token[\empty2\else \ifx\@let@token(\empty3\else \ifx\@let@token<\empty4\else \ifx\@let@token*\empty5\else \ifx\@let@token'\empty6\else \ifx\@let@token!\empty7\else \ifx\@let@token\@sptoken8\else \ifx\@let@token\space9\else \ifx\@let@token~9\else \ifx\@let@token\AlsoMacro10\else \ifx\@let@token\DescribeMacro11\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \relax \unskip \expandafter\end@Macro@args%0 \or\expandafter\read@Macro@marg%1 \or\expandafter\read@Macro@oarg%2 \or\expandafter\read@Macro@parg%3 \or\expandafter\read@Macro@angle%4 \or\expandafter\read@Macro@sarg%5 \or\expandafter\read@Macro@verb%6 \or\expandafter\read@Macro@cmds%7 \or\expandafter\read@Macro@rmspace%8 \or\expandafter\read@Macro@addtoken%9 \else%10- \fi } \def\end@Macro@args{% \y@egroup \after@Macro@args } \def\after@Macro@args{% } \def\read@Macro@marg{% \begingroup \afterassignment\read@Macro@marg@ \let\@let@token=% } \def\read@Macro@marg@{% \setbox\@tempboxa\hbox\bgroup \color@setgroup\bgroup \aftergroup\color@endgroup \aftergroup\egroup \aftergroup\read@Macro@marg@@ \let\end@Macro@args\empty% \read@Macro@arg } \def\read@Macro@marg@@{% \@marg{\usebox\@tempboxa}% \endgroup \read@Macro@arg } \def\read@Macro@oarg[#1]{% \@oarg{#1}\read@Macro@arg } \def\read@Macro@parg(#1){% \@parg{#1}\read@Macro@arg } \def\read@Macro@aarg<#1>>{% \@aarg{#1}\read@Macro@arg } \def\read@Macro@angle<{% \futurelet\@let@token\read@Macro@angle@ } \def\read@Macro@angle@{% \ifx\@let@token<% \expandafter\read@Macro@aarg \else \expandafter\read@Macro@meta \fi } \def\read@Macro@meta#1>{% \meta{#1}\read@Macro@arg } \def\read@Macro@sarg#1{% \sarg\read@Macro@arg } \def\read@Macro@verb{% \begingroup \let\do\@makeother \dospecials \obeyspaces \read@Macro@verb@ } \def\read@Macro@verb@'#1'{% \endgroup \ifx\relax#1\relax {\verbstyle{\string'}}% \else {\verbstyle{#1}}% \fi \read@Macro@arg } \def\read@Macro@cmds!#1!{% #1\relax \read@Macro@arg } \@firstofone{\def\read@Macro@rmspace} {% \read@Macro@arg } \def\read@Macro@addtoken#1{% #1\read@Macro@arg } \@ifundefined{DescribeMacro}{}{% \PackageInfo{ydoc-desc}{Redefining \string\DescribeMacro}{}% } \def\DescribeMacro{% \DescribeMacros \let\DescribeMacros\y@egroup \def\after@Macro@args{\endDescribeMacros}% \begingroup\makeatletter \Describe@Macro } \def\Describe@Macro#1{% \endgroup \edef\name{\expandafter\@gobble\string#1}% \global\@namedef{href@desc@\name}{}% \immediate\write\@mainaux{% \global\noexpand\@namedef{href@desc@\name}{}% }% \hbox\y@bgroup \@ifundefined{href@impl@\name}{}{\hyperlink{impl:\name}}% {\hypertarget{desc:\name}{\PrintMacroName{#1}}}% \ydoc@macrocatcodes \macroargsstyle \read@Macro@arg } \def\ydoc@macrocatcodes{% \ydoc@short@AlsoMacro } \newcommand*\MakeShortMacroArgs{% \@ifstar {\@MakeShortMacroArgs\Macro}% {\@MakeShortMacroArgs\MacroArgs}% } \def\@MakeShortMacroArgs#1#2{% \MakeShortVerb{#2} \catcode`#2\active \begingroup \catcode`\~\active \lccode`\~`#2\relax \lowercase{\endgroup\gdef~{\bgroup\let~\egroup#1}}% } \newcommand*\DeleteShortMacroArgs[1]{% \DeleteShortVerb{#1}% } \newcommand*\Macro{\MacroArgs\AlsoMacro} \def\@Macro{% \begingroup\makeatletter \Describe@Macro } \newcommand*\AlsoMacro{% \begingroup\makeatletter \AlsoMacro@ } \def\AlsoMacro@#1{% \endgroup \PrintMacroName{#1}% \read@Macro@arg } \begingroup \catcode`\|\active \gdef\ydoc@short@AlsoMacro{% \catcode`\|\active \let|\AlsoMacro } \endgroup \newcommand*\MacroArgs{% \begingroup \def\end@Macro@args{\endgroup\xspace}% \ydoc@macrocatcodes \macroargsstyle \read@Macro@arg } \RequirePackage{xspace} \def\DescribeMacros{% \begingroup \let\Macro\@Macro \parindent=0pt\relax \setbox\descbox\vbox\y@bgroup } \def\endDescribeMacros{% \y@egroup \PrintMacros \endgroup } \def\DescribeMacrosTabcolsep{\tabcolsep} \def\DescribeMacrosTab{% \DescribeMacros \hbox\y@bgroup \tabcolsep=\DescribeMacrosTabcolsep\relax \DescribeMacrosTab@ } \def\DescribeMacrosTab@#1{\tabular{@{}#1@{}}} \def\endDescribeMacrosTab{% \endtabular\y@egroup \endDescribeMacros } \newcommand*\DescribeLength{% \begingroup \let\DescribeLength\Describe@Length \setbox\descbox\hbox\y@bgroup \tabular{@{}l@{\hspace{2em}}l@{}}% \Describe@Length } \newcommand*\Describe@Length[2]{% \PrintLengthName{#1}& (Default: {\macroargsstyle#2\unskip})% \@ifnextchar\DescribeLength {\\}% {% \endtabular \y@egroup \PrintLength \endgroup }% } \@ifundefined{DescribeEnv}{}{% \PackageInfo{ydoc-desc}{Redefining \string\DescribeEnv}{}% } \let\DescribeEnv\relax \newcommand*\DescribeEnv[2][]{% \begingroup \def\DescribeEnv@name{#2}% \let\\\DescribeEnv@newline \ifx\@currenvir\DescribeEnv@string \def\after@Macro@args{% \let\after@Macro@args\empty \setbox\@tempboxa\hbox\y@bgroup \@ifnextchar\end{}% {\DescribeEnv@newline}% #1% }% \else \ifx\relax#1\relax \def\after@Macro@args{% \y@bgroup \endDescribeEnv }% \else \def\after@Macro@args{% \setbox\@tempboxa\hbox\y@bgroup \DescribeEnv@newline\MacroArgs#1% \endDescribeEnv }% \fi \fi \setbox\descbox\vbox\y@bgroup \envcodestyle \let\PrintEnv\PrintSubEnv \hbox\y@bgroup \PrintEnvName{\begin}{\DescribeEnv@name}% \ydoc@macrocatcodes \macroargsstyle \read@Macro@arg } \newcommand*\DescribeEnv@newline[1][0pt]{% \strut\y@egroup {\vskip#1}% \hbox\y@bgroup\strut \hspace*{\descsep}% \ignorespaces }% \def\DescribeEnv@string{DescribeEnv} \newbox\descbox \def\endDescribeEnv{% \y@egroup \begingroup \setbox\@tempboxa\lastbox \ifcase0% \ifdim\wd\@tempboxa>\descsep1\fi \ifdim\ht\@tempboxa>\ht\strutbox1\fi \ifdim\dp\@tempboxa>\dp\strutbox1\fi \else \box\@tempboxa \fi \endgroup \hbox\y@bgroup \PrintEnvName{\end}{\DescribeEnv@name} \y@egroup \y@egroup \PrintEnv \endgroup } \def\PrintMacroName#1{% {\macrodescstyle{\strut \texttt{\char92}% \escapechar\m@ne \string#1}}% } \let\PrintLengthName\PrintMacroName \def\PrintEnvName#1#2{% \strut \string#1\braceleft {\macrodescstyle#2\strut}% \braceright } \def\PrintMacros{% \par\vspace\beforedescskip \noindent\hspace*{\descindent}% \ifdim\wd\descbox>\linewidth \makebox[\linewidth][c]{\fbox{\hspace*{\descsep}\usebox{\descbox}\hspace*{\descsep}}} \else \fbox{\hspace*{\descsep}\usebox{\descbox}\hspace*{\descsep}}% \fi \par\vspace\afterdescskip } \let\PrintLength\PrintMacros \def\PrintEnv{% \par\vspace\beforedescskip \noindent\hspace*{\descindent}% \fbox{\hspace*{\descsep}\usebox{\descbox}\hspace*{\descsep}}% \par\vspace\afterdescskip } \def\PrintSubEnv{% \hbox{\hbox{\usebox{\descbox}}}% } {% \@firstofone{% \catcode`\\=12 \gdef\bslash }{\} }%} \begingroup \catcode`\%=12 \gdef\percent{%} \endgroup \begingroup \catcode`\<=1 \catcode`\>=2 \catcode`\{=12 \catcode`\}=12 \gdef\braceleft <{> \gdef\braceright<}> \endgroup \def\y@bgroup{\bgroup\color@setgroup} \def\y@egroup{\color@endgroup\egroup} \endinput %% %% End of file `ydoc-desc.sty'.