%% %% This is file `ydoc-code.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% ydoc.dtx (with options: `code') %% %% 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-code] {$Id: ydoc.dtx 2035 2011-01-09 17:22:24Z martin $} [v0.4alpha] [ydoc package to document macro code] \RequirePackage{hyperref} \hypersetup{colorlinks=true,pdfborder=0 0 0,pdfborderstyle={}} \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)* )* |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{} \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\strut}% } \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{% \PrintMacroImpl{#1}% \@ifnextchar[%] {\macro@impl@args}% {}% } \def\endmacro{} \def\environment#1{% \PrintEnvImplName{#1}% \@ifnextchar[%] {\macro@impl@args}% {}% } \def\endenvironment{} \def\PrintMacroImpl#1{% \par\bigskip\noindent \hbox{% \edef\name{\expandafter\@gobble\string#1}% \global\@namedef{href@impl@\name}{}% \immediate\write\@mainaux{% \global\noexpand\@namedef{href@impl@\name}{}% }% \raisebox{4ex}[4ex]{\hypertarget{impl:\name}{}}% \hspace*{\descindent}\fbox{% \hspace*{\descsep}% \@ifundefined{href@desc@\name}{}{\hyperlink{desc:\name}}% {\PrintMacroImplName{#1}}% \hspace*{\descsep}% }% }% \par\medskip\noindent } \def\PrintMacroImplName#1{% \implstyle{\string#1\strut}% } \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'.