diff options
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/ydoc/ydoc.dtx | 1862 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/ydoc/ydoc.ins | 26 |
2 files changed, 1888 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/ydoc/ydoc.dtx b/Master/texmf-dist/source/latex/ydoc/ydoc.dtx new file mode 100644 index 00000000000..9335c986862 --- /dev/null +++ b/Master/texmf-dist/source/latex/ydoc/ydoc.dtx @@ -0,0 +1,1862 @@ +% \iffalse +%% 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. +%% +% \fi +% +% \iffalse +%<*driver|class|package|code|desc|expl|doc> +\RequirePackage{svn-prov}[2010/04/03] +%</driver|class|package|code|desc|expl|doc> +%<*driver> +\ProvidesFileSVN[ydoc.dtx] +%</driver> +%<package|code|desc|expl|doc>\NeedsTeXFormat{LaTeX2e}[1999/12/01] +%<class>\ProvidesClassSVN +%<package|code|desc|expl|doc>\ProvidesPackageSVN +%<code> [ydoc-code] +%<desc> [ydoc-desc] +%<expl> [ydoc-expl] +%<doc> [ydoc-doc] +%<*driver|class|package|code|desc|expl|doc> + {$Id: ydoc.dtx 1847 2010-04-10 10:57:11Z martin $} + [v0.1alpha] +%</driver|class|package|code|desc|expl|doc> +%<class> [ydoc class: document LaTeX class and packages] +%<package> [ydoc package: document LaTeX class and packages] +%<code> [ydoc package to document macro code] +%<desc> [ydoc package to describe macros, environments, options etc.] +%<expl> [ydoc package to insert live examples of LaTeX code] +%<doc> [ydoc package to provide 'doc' macros] +% +%<*driver> +\DefineFileInfoSVN +\GetFileInfoSVN* +\documentclass{ydoc}[\filedate] + +\usepackage{xcolor} +\usepackage{hyperref} +\usepackage{lmodern} +\usepackage{listings} +\usepackage{booktabs} + +\newdimen\tempskip + +\def\tablecaption{% + \tempskip=\abovecaptionskip + \abovecaptionskip=\belowcaptionskip + \belowcaptionskip=\tempskip + \caption +} + +\begin{document} + \DocInput{ydoc.dtx} + \PrintChanges + \PrintIndex +\end{document} +%</driver> +% \fi +% +% \CheckSum{1151} +% +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% +% \changes{v0.1alpha}{2010/04/10}{First released alpha version} +% +% \DoNotIndex{\newcommand,\newenvironment} +% +% \GetFileInfoSVN{ydoc.dtx} +% +% \title{The \textsf{ydoc} Class and Packages} +% \author{Martin Scharrer \\ \href{mailto:martin@scharrer-online.de}{martin@scharrer-online.de} \\ +% \url{http://latex.scharrer-online.de/ydoc/}\\ +% CTAN: \url{http://tug.ctan.org/pkg/ydoc}} +% \makeatletter +% \date{Version \expandafter\@gobble\fileversion\\[0.5ex]\filedate} +% \makeatother +% +% \maketitle +% +% \ifpdf +% \hypersetup{% +% pdfauthor = {Martin Scharrer <martin@scharrer-online.de>}, +% pdftitle = {The ydoc package, \fileversion, \filedate}, +% pdfsubject = {Documentation of LaTeX package ydoc.}, +% pdfkeywords = {ydoc, documentation, LaTeX} +% }% +% \fi +% +% +% \begin{abstract} +% {\color{red}\bfseries This package bundle is currently under development. +% All functionality, settings and macro as well as file names can change in later versions and may be incomplete! +% It is not ready yet to be used for other packages. +% } +% +% The \pkg{ydoc} class and packages provide macros to document the functionality and implementation of \LaTeX{} classes and packages. +% It is similar to the \pkg{ltxdoc} class with the \pkg{doc} package, but uses more modern features/packages by default +% (e.g.\ \pkg{xcolor}, \pkg{hyperref}, \pkg{listings}). However, some of the features like code indexing is not yet included. +% \end{abstract} +% +% \section{Introduction} +% The \pkg{ydoc} packages allow the documentation of \LaTeX\ packages and classes. +% The name stands for ``\emph{Y}et another \emph{Doc}umentation Package'' and is a pun on +% the fact that there are several documentation packages written by package developers +% to document their own packages. All these packages didn't suited the author and therefore he, +% take a guess, wrote his own documentation package. +% It (will) support(s) all macros and environments (but not necessary with full/identical features) provided by the \pkg{doc} +% package to allow the fast adaption of existing |.dtx| files. +% +% This documentation uses the \pkg{ydoc} packages itself and therefore also acts as a live example. +% +% \subsection{\pkg{ydoc} Files} +% The \pkg{ydoc} bundle consists (at the moment, subject to change) of the \cls{ydoc} class and the packages \pkg{ydoc}, \pkg{ydoc-code}, +% \pkg{ydoc-desc}, \pkg{ydoc-expl} and \pkg{ydoc-doc}. The \cls{ydoc} class and package allow the user the freedom to use the functionality with other classes if wanted. +% The class will load the package. The \pkg{ydoc} package loads the packages \pkg{ydoc-code}, \pkg{ydoc-desc}, \pkg{ydoc-expl} and \pkg{ydoc-doc}, which +% provide the functionality to document \LaTeX\ code implementation, describe the user-level macro, include live code examples and provide replacements for the +% macros of the \pkg{doc} package, respectively. +% This packages can be loaded on their own in other kind of \LaTeX\ documents if required. +% +% \subsection{Similar Packages} +% Other documentation related classes and packages are \pkg{ltxdoc}, \pkg{doc}, \pkg{dox}, \pkg{xdoc}, \pkg{gmdoc}, \pkg{pauldoc}, \pkg{hypdoc}, +% \pkg{codedoc}, \pkg{nicetext} and \pkg{tkz-doc}. +% +% +% \section{Usage} +% (section incomplete) +% +% \subsection{Code Documentation Environments} +% +% \begin{DescribeEnv}{macro}{<macro>}[<number of arguments>]!\color{optional}\colorlet{meta}{metaoptional}!{<arg~1~description>}!\ldots!{<arg~$n$~description>} +% \MacroArgs<macro documentation>\\ +% \begin{DescribeEnv}{macrocode} +% \MacroArgs<macro code> +% \end{DescribeEnv}\\ +% \ldots +% \end{DescribeEnv} +% The implementation of macros can be documented using this environment. The actual \meta{macro code} must be placed in a \env{macrocode} environment. +% Longer macro definition can be split using multiple \env{macrocode} environments with interleaved documentation texts. +% +% The \pkg{ydoc} definition of the \env{macro} environment has an additional feature compare to \pkg{doc}. The arguments of the macro (|#1|, |#2|, \ldots) can be +% documented in a vertical list. The environment has an optional argument to declare the \meta{number of arguments} the macro implementation has. +% The descriptions of this macro arguments are read from the next arguments of the environment. If the \meta{number of arguments} is not given or zero (or less) +% no further arguments are read by the \env{macro} environment. +% +% \begin{DescribeEnv}{macrocode} +% \MacroArgs<macro code> +% \end{DescribeEnv} +% This environment wraps around any \TeX\ code and types it verbatim. The environment end is read verbatim as well and must be written on a separate +% line beginning with a percent followed by exactly four spaces: `\verb*+% \end{macrocode}+'. +% +% \begin{DescribeEnv}{environment}{<environment name>}[<number of arguments>]!\color{optional}\colorlet{meta}{metaoptional}!{<arg~1~description>}!\ldots!{<arg~$n$~description>} +% \MacroArgs<environment documentation>\\ +% \begin{DescribeEnv}{macrocode} +% \MacroArgs<macro code> +% \end{DescribeEnv}\\ +% \ldots +% \end{DescribeEnv} +% This environment provides the same functionality as the \env{macro} environment above, but for environments instead. +% +% +% \subsection{Description Macros and Environments} +% +% \DescribeMacro\DescribeMacro<\textbackslash macro><macro arguments> +% The \cs{DescribeMacro} is used to describe macros included their arguments. +% It takes the to be described \meta{\textbackslash macro} as first argument (can also be enclosed in |{ }|). +% The macro name can include `|@|'. Any number of \meta{macro arguments} (in a broad sense, see Table~\ref{tab:macroargs}) following it +% are formatted as arguments of this macro. +% Any following non-argument token (normal text, macro, etc.)\ will make \cs{DescribeMacro} stop collecting arguments. +% For example, if a \TeX\ group should be started using |{ }| direct after \cs{DescribeMacro} a |\relax| (or a similar macro) should be inserted +% between them, otherwise the group will be taken as mandatory argument of the described macro. +% +% Multiple \cs{DescribeMacro} in a row will automatically stacked inside one framed box. If this is not wanted simply separate them with |\relax| +% or any other macro or token. See also the \env{DescribeMacros} environment below. +% +% \subsubsection*{Examples:} +% \par\noindent |\DescribeMacro\mymacro*[<optional>]{<meta text>}| will result in\\ +% \mbox{\Macro\mymacro*[<optional>]{<meta text>}} (inside a framed box). +% \par\medskip\noindent The above syntax description of \cs{DescribeMacro} itself was typeset with\\ +% |\DescribeMacro\DescribeMacro<\textbackslash macro><macro arguments>|. +% \par\medskip\noindent Special macros with have a partner macro as end marker can be typeset like this:\\ +% |\DescribeMacro\csname<text>\AlsoMacro\endcsname|, which will result in\\ +% \mbox{\Macro\csname<text>\AlsoMacro\endcsname}. +% +% \DescribeMacro\Macro<\textbackslash macro><macro arguments> +% This macro is like an in-text version of \cs{DescribeMacro}. +% The macro description stays as part of the surrounding text and is not placed inside a framed box. +% The description can be broken between lines. This can be avoided by placing it inside a |\mbox{}|. +% \cs{Macro} is equivalent to \cs{MacroArgs}\cs{AlsoMacro}. +% +% \DescribeMacro\MacroArgs<macro arguments> +% This macro formats the \meta{macro arguments} the same way as \cs{DescribeMacro} and \cs{Macro} but without a macro name. +% Like \cs{Macro} the description is placed in-text. +% +% \DescribeMacro\AlsoMacro<\textbackslash macro><further macro arguments> +% This macro can only be used inside the \meta{macro arguments} of the above macros and typesets an additional macro as part +% of the syntax of the described macro. The additional macro is normally an end- or other marker of some kind. Further macro arguments may +% follow. Macros which are not part of the syntax but normal arguments should be written as +% |<\textbackslash name>| (yielding \MacroArgs<\textbackslash name>) instead. +% +% \subsubsection*{Example:} +% |\Macro\@for<\textbackslash var> ':=' <list> \AlsoMacro\do {<code>}|\\ +% \Macro\@for<\textbackslash var> ':=' <list> \AlsoMacro\do {<code>}\\ +% +% \begin{DescribeEnv}{DescribeMacros} +% \Macro\Macro<\textbackslash name><arguments>\\ +% \Macro\Macro<\textbackslash name><arguments>\\ +% \ldots +% \end{DescribeEnv} +% This environment can be used to place multiple macro description into the same framed box. +% The macros are described using \cs{Macro}, which has a slightly different definition than outside of this environment, to place the +% description into a |\hbox|. The environment stacks these |\hbox|es in a |\vbox|. The macros can also be placed freely using anything +% which produces a |\hbox|, e.g.\ |\hbox{\Macro\A ~~~ \Macro\B}| or using +% a |tabular| (see also \env{DescribeMacrosTab}). +% +% \DescribeEnv[<tabular content>]{DescribeMacrosTab}{<tabular column definition>} +% This is a special version of the \env{DescribeMacros} environment which adds a tabular environment around the content. +% This is useful if a large set of small macros should be desribed at once. Placing them all below each other would result in a very bad page layout. +% The environment has one argument which is passed to \env{tabular} as the column definition. A `|@{}|' is added before and after to remove any margins. +% +% +% \begin{DescribeEnv}{DescribeEnv}{<name>}<arguments> +% \MacroArgs<body content>\relax\space |\\|\\ +% \MacroArgs<more body content> +% \end{DescribeEnv} +% \vspace{-\beforedescskip} +% \DescribeMacro\DescribeEnv[<body content>]{<name>}<arguments> +% The \env{DescribeEnv} can be used to describe environments in the same way the \cs{DescribeMacro} macro describes macros. +% Supported \meta{arguments} are shown in Table~\ref{tab:macroargs}. +% Potential \meta{body content} can be placed between the begin and end of the environment description to explain the user what kind of material +% should be placed inside it. +% The environment also exists in macro form as \cs{DescribeEnv}, which allows to provide small \meta{body content} as an optional argument. +% Please note that for this optional argument a \cs{MacroArgs} is automatically inserted, but not for the \cs{DescribeEnv} environment content. +% +% The body content is placed into a indented |\hbox{}| stacked inside a |\vbox{}| also holding the environment begin and end line. +% The |\\| macro is redefined to create a new indented |\hbox| acting as new code line. +% Therefore this environment is similar to a one-column \env{tabular}: all macros placed into a line are only valid up to the next line end. +% +% \begin{table} +% \tablecaption{Supported `arguments' for \cs{DescribeMacro}/\cs{DescribeEnv}/\cs{MacroArgs}.}\label{tab:macroargs} +% \begin{tabular}{llll} +% \toprule +% Description & Syntax & Result & Macro$^{a}$ \\ +% \midrule +% Meta text & |<text>| & \MacroArgs<text> & |\meta| \\ +% Mandatory Argument & |{<text>}| & \MacroArgs{<text>} & |\marg| \\ +% ---, without meta text & |{text}| & \MacroArgs{text} & \\ +% Optional Argument & |[<text>]| & \MacroArgs[<text>] & |\oarg| \\ +% ---, without meta text & |[text]| & \MacroArgs[text] & \\ +% Picture Argument & |(<text>)| & \MacroArgs(<text>) & |\parg| \\ +% ---, without meta text & |(text)| & \MacroArgs(text) & \\ +% Beamer Overlay Argument & |<<text>>| & \MacroArgs<<text>> & |\aarg| \\ +% ---, without meta text & |'<'text'>'| & \MacroArgs'<'text'>' \\ +% Star & |*| & \MacroArgs* \\ +% \midrule +% Verbatim content & |'$&^%_#$\'| & \MacroArgs'$&^%_#$\' \\ +% ---, produce |'| char & |''| & \MacroArgs'' \\ +% Insert any \TeX\ code & |!\fbox{T}!| & \MacroArgs!\fbox{T}! \\ +% Unbreakable Space & |~| & \\ +% Space (explicit macro) & |\space| & \\ +% \midrule +% Second macro (e.g.\ endmarker) & |\AlsoMacro\macro| & \MacroArgs\AlsoMacro\macro \\ +% \bottomrule +% \multicolumn{4}{l}{{\Large\strut}$^{a}$) As alternative to be used inside normal text.} +% \end{tabular} +% \end{table} +% +% \DescribeMacro\DescribeLength<\textbackslash name>{<default value>} +% This macro can be used to describe \LaTeX\ lengths also known as dimensions. Multiple \cs{DescribeLength} macros in a row will automatically be grouped. +% +% \subsection{Format Macros} +% \begin{DescribeMacrosTab}{ll} +% \Macro\cs{<macro name>} & \Macro\env{<environment name>} \\ +% \Macro\pkg{<package name>} & \Macro\cls{<class name>} \\ +% \end{DescribeMacrosTab} +% This macros can be used to format names of macros, environments, packages and classes, respectively. +% At the moment they simply use |\texttt|. +% +% \DescribeMacros\hbox{\Macro\bslash~~~~\Macro\percent~~~~\Macro\braceleft~~~~\Macro\braceright}\endDescribeMacros +% This macros define expandable backslash (\texttt{\bslash}$_{12}$), percent char (\texttt{\percent}$_{12}$), +% and left (\texttt{\braceleft}$_{12}$) and right (\texttt{\braceright}$_{12}$) braces with catcode 12 (other), respectively. +% They should only be used with text-typer font when used in text, because other fonts might not have the +% correct characters. The macros must be protected when used in a moving argument. +% +% \DescribeMacrosTab{@{}ll@{}} +% \Macro\meta{<meta text>} & +% \Macro\marg{<argument text>} \\ +% \Macro\oarg{<argument text>} & +% \Macro\parg{<argument text>} \\ +% \Macro\aarg{<argument text>} & +% \Macro\sarg \\ +% \endDescribeMacrosTab +% This macros allow to typeset meta text and mandatory, optional, picture and beamer overlay arguments as well as a star symbol. +% They are used internally by \cs{MacroArgs} and friends. See Table~\ref{tab:macroargs} for examples. +% +% \DescribeMacrosTab{ll} +% \Macro\metastyle & +% \Macro\margstyle \\ +% \Macro\oargstyle & +% \Macro\pargstyle \\ +% \Macro\aargstyle & +% \Macro\sargstyle \\ +% \endDescribeMacrosTab +% This macros are used to define the style in which the corresponding macros above are being formatted. +% They are used like \MacroArgs '{'<\textbackslash stylemacro>{<material>}'}' to allow the styles to +% use macros like |\ttfamily| or |\texttt|\marg{material}. By default the optional argument and the also optional star are +% printed in the color `|optional|' which is a 65\% gray. +% +% \subsection{Settings} +% The following macro and dimensions can be redefined by the user to adjust the layout of the package documentation. +% +% \DescribeLength\descindent {-20pt} +% \DescribeLength\beforedescskip{~12pt plus 4pt minus 4pt} +% \DescribeLength\afterdescskip {~~6pt plus 2pt minus 2pt} +% These length define the indention and vertical distances before and after a \cs{Describe\ldots} macro or environment, respectively. +% +% \DescribeLength\descsep {1em in \texttt{tt} font = 10.5pt} +% This macro defines the space on the left and right side between the description text and the framed box. +% +% \subsection{Macros and Environments to include LaTeX Code Examples} +% \DescribeEnv{example} +% \DescribeEnv{examplecode} +% (to be written) +% +% \StopEventually{} +% +% \clearpage +% \section{Implementation} +% +% \iffalse +%<*class> +% \fi +% \subsection{Class File} +% \begin{macrocode} +\LoadClassWithOptions{article} +%%\RequirePackage{doc} +\RequirePackage{ydoc} +% \end{macrocode} +% \iffalse +%</class> +% \fi +% +% \iffalse +%<*package> +% \fi +% \subsection{Package File} +% \begin{macrocode} +\RequirePackage{ydoc-code} +\RequirePackage{ydoc-expl} +\RequirePackage{ydoc-desc} +\RequirePackage{ydoc-doc} + +\RequirePackage{newverbs} +\MakeSpecialShortVerb{\qverb}{\"} +\AtBeginDocument{\catcode`\^^A=14\relax} +% \end{macrocode} +% \iffalse +%</package> +% \fi +% +% \iffalse +%<*code> +% \fi +% +% \subsection{Macros and Environments to document Implementations} +% +% \subsubsection{Color and style definitions} +% \begin{macrocode} +\RequirePackage{xcolor} +\definecolor{macroimpl}{rgb}{0.0,0.0,0.4} +% \end{macrocode} +% +% \subsubsection{General Macros} +% +% \begin{macro}{\ydocwrite} +% \begin{macrocode} +\@ifundefined{ydocwrite}{% + \newwrite\ydocwrite +}{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ydocfname} +% \begin{macrocode} +\@ifundefined{ydocfname}{% + \def\ydocfname{\jobname.cod}% +}{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ydoc@catcodes} +% \begin{macrocode} +\def\ydoc@catcodes{% + \let\do\@makeother + \dospecials + \catcode`\\=\active + \catcode`\^^M=\active + \catcode`\ =\active +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Handling Macrocode} +% \begin{environment}{macrocode} +% \begin{macrocode} +\def\macrocode{% + \par\noindent + \begingroup + \ydoc@catcodes + \macro@code +} +\def\endmacrocode{} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\macro@code}[1]{verbatim macro code} +% \begin{macrocode} +\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 +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\macro@@code}[1]{verbatim macro code} +% \begin{macrocode} +\def\macro@@code#1{% + {\ydoc@defspecialmacros + \xdef\themacrocode{#1}}% + \PrintMacroCode + \end{macrocode}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\linenumberbox} +% \begin{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~}% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintMacroCode} +% \begin{macrocode} +\def\PrintMacroCode{% + \begingroup + \ttfamily + \noindent\themacrocode + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintMacroCode} +% \begin{macrocode} +\RequirePackage{listings} +% \end{macrocode} +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\ydoclistingssettings} +% \begin{macrocode} +\def\ydoclistingssettings{% + \lstset{% + language=[latex]tex,basicstyle=\ttfamily, + numbers=left,numberstyle=\tiny\color{gray},firstnumber=last, + breaklines,prebreak={\mbox{\tiny$\swarrow$}}% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\macro@impl@args}[1]{number of macro arguments} +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\macro@impl@endargs} +% \begin{macrocode} +\def\macro@impl@endargs{% + \endgroup + \unskip\par\noindent\ignorespaces +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\macro@impl@argline}[2]{argument number}{argument description} +% \begin{macrocode} +\def\macro@impl@argline#1#2{% + \par{\texttt{\##1}:~#2}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\macro@impl@arg}[1]{argument description} +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{macro}[1]{implemented macro} +% \begin{macrocode} +\def\macro#1{% + \PrintMacroImplName{#1}% + \@ifnextchar[%] + {\macro@impl@args}% + {}% +} +\def\endmacro{} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{environment}[1]{environment name} +% \begin{macrocode} +\def\environment#1{% + \PrintEnvImplName{#1}% + \@ifnextchar[%] + {\macro@impl@args}% + {}% +} +\def\endenvironment{} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\PrintMacroImplName}[1]{macro (token)} +% \begin{macrocode} +\def\PrintMacroImplName#1{% + \par\bigskip\noindent + \hbox{\hspace*{\descindent}\fbox{{\implstyle{\string#1}}}}% + \par\medskip\noindent +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintEnvImplName}[1]{environment name} +% test +% \begin{macrocode} +\def\PrintEnvImplName#1{% + \par\bigskip\noindent + \hbox{\hspace*{\descindent}\fbox{{\implstyle{#1}}}}% + \par\medskip +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\implstyle} +% \begin{macrocode} +\def\implstyle{\ttfamily\bfseries\color{macroimpl}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\bslash} +% Defines an expandable backslash with catcode 12: `\texttt{\bslash}$_{12}$'. +% The |\@firstofone| trick is used to read the |\gdef\bslash| code before changing the catcode. +% \begin{macrocode} +{% +\@firstofone{% + \catcode`\\=12 + \gdef\bslash +}{\} +}%} +% \end{macrocode} +% \end{macro} +% +% \iffalse +%</code> +% \fi +% +% +% \subsection{Provide \pkg{doc} macros} +% +% \iffalse +%<*doc> +% \fi +% +% \begin{macro}{\ydoc@countbslashes} +% Reads the macro code into a temp box. The backslashes are defined to increase a counter. +% \begin{macrocode} +\newcount\ydoc@bslashcnt +\def\ydoc@countbslashes{% + \begingroup + \let\firstlinemacro\empty + \let\lastlinemacro\empty + \let\newlinemacro\empty + \let\spacemacro\empty + \def\bslashmacro{\global\advance\ydoc@bslashcnt by\@ne}% + \setbox\@tempboxa\hbox{\themacrocode}% + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\CheckSum} +% \begin{macrocode} +\def\CheckSum#1{% + \gdef\ydoc@checksum{#1}% +} +\let\ydoc@checksum\z@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\AlsoImplementation} +% \begin{macro}{\OnlyDescription} +% \begin{macro}{\StopEventually} +% \begin{macro}{\Finale} +% The first two macros modify the \cs{StopEventually} macro which either +% stores its argument in \cs{Final} or executes it itself. +% \begin{macrocode} +\def\AlsoImplementation{% + \gdef\StopEventually##1{% + \@bsphack + \gdef\Finale{##1\ydoc@checkchecksum}% + \@esphack + }% +} +\AlsoImplementation +\def\OnlyDescription{% + \@bsphack + \long\gdef\StopEventually##1{##1\endinput}% + \@esphack +} +\let\Finale\relax +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\MakePercentComment} +% \begin{macro}{\MakePercentIgnore} +% \begin{macrocode} +\def\MakePercentIgnore{\catcode`\%9\relax} +\def\MakePercentComment{\catcode`\%14\relax} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\DocInput} +% \begin{macrocode} +\def\DocInput#1{\MakePercentIgnore\input{#1}\MakePercentComment} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\CharacterTable} +% \begin{macrocode} +\providecommand*\CharacterTable[1]{% + \PackageWarning{ydoc}{Ignoring Character Table - not implemented yet!}{}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DoNotIndex} +% \begin{macrocode} +\providecommand*\DoNotIndex[1]{% + \PackageWarning{ydoc}{Ignoring DoNotIndex - not implemented yet!}{}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\changes} +% \begin{macrocode} +\providecommand*\changes[3]{% + \PackageWarning{ydoc}{Ignoring changes - not implemented yet!}{}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\RecordChanges} +% \begin{macrocode} +\providecommand*\RecordChanges{% + \PackageWarning{ydoc}{List of changes not implemented yet!}{}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintChanges} +% \begin{macrocode} +\providecommand*\PrintChanges{% + \PackageWarning{ydoc}{List of changes not implemented yet!}{}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintIndex} +% \begin{macrocode} +\providecommand*\PrintIndex{% + \PackageWarning{ydoc}{Code index not implemented yet!}{}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\CodelineIndex} +% \begin{macrocode} +\providecommand*\CodelineIndex{% + \PackageWarning{ydoc}{Code line index not implemented yet!}{}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\EnableCrossrefs} +% \begin{macrocode} +\providecommand*\EnableCrossrefs{% + \PackageWarning{ydoc}{Cross references not implemented yet!}{}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\GetFileInfo} +% \begin{macrocode} +\providecommand*\GetFileInfo[1]{% + \PackageWarning{ydoc}{Get File Info not implemented yet!}{}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ydoc@checkchecksum} +% \begin{macrocode} +\def\ydoc@checkchecksum{% + \ifnum\ydoc@checksum=\m@ne + \message{^^J}% + \message{**********************^^J}% + \message{* No Checksum found! *^^J}% + \message{**********************^^J}% + \else + \ifnum\ydoc@checksum=\ydoc@bslashcnt + \message{^^J}% + \message{*******************^^J}% + \message{* Checksum passed *^^J}% + \message{*******************^^J}% + \else + \message{^^J}% + \message{****************************^^J}% + \message{* Checksum wrong (\ydoc@checksum<>\the\ydoc@bslashcnt) ^^J}% + \message{****************************^^J}% + \GenericError{Checksum wrong}{}{}{}% + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\RequirePackage{shortvrb} +\MakeShortVerb{\|} +% \end{macrocode} +% +% \iffalse +%</doc> +% \fi +% +% \iffalse +%<*desc> +% \fi +% \subsection{Description Macros and Environments} +% +% \subsubsection{Color and style definitions} +% \begin{macrocode} +\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} +% \end{macrocode} +% +% +% \subsubsection{Text Formatting Macros} +% +% \begin{macro}{\meta} +% Prints \meta{meta text}. +% \begin{macrocode} +\def\meta#1{% + \ensuremath\langle + {\metastyle{#1\/}}% + \ensuremath\rangle +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@meta} +% Checks if |#1| is surrounded by angles |< >|. +% If so it calls \cs{is@meta} which removes the angles and calls \cs{meta}. +% \begin{macrocode} +\def\@meta#1{% + \@ifnextchar<% + {\is@meta}% + {}% + #1% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\is@meta} +% Only removes the |< >| ands calls \cs{meta}. +% \begin{macrocode} +\def\is@meta<#1>{% + \meta{#1}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\marg} +% Calls \cs{marg} with angles added to force meta format. +% \begin{macrocode} +\def\marg#1{\@marg{<#1>}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\oarg} +% Calls \cs{oarg} with angles added to force meta format. +% \begin{macrocode} +\def\oarg#1{\@oarg{<#1>}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\parg} +% Calls \cs{parg} with angles added to force meta format. +% \begin{macrocode} +\def\parg#1{\@parg{<#1>}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\aarg} +% Calls \cs{aarg} with angles added to force meta format. +% \begin{macrocode} +\def\aarg#1{\@aarg{<#1>}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@marg} +% Sets style and adds braces. Text is formatted with \cs{@meta} which might add meta format. +% \begin{macrocode} +\def\@marg#1{% + {\margstyle{% + {\ttfamily\braceleft}% + \@meta{#1}% + {\ttfamily\braceright}% + }}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@oarg} +% Sets style and adds brackets. Text is formatted with \cs{@meta} which might add meta format. +% \begin{macrocode} +\def\@oarg#1{% + {\oargstyle{% + {\ttfamily[}% + \@meta{#1}% + {\ttfamily]}% + }}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@parg} +% Sets style and adds parentheses. Text is formatted with \cs{@meta} which might add meta format. +% \begin{macrocode} +\def\@parg#1{% + {\pargstyle{% + {\ttfamily(}% + \@meta{#1}% + {\ttfamily)}% + }}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@aarg} +% Sets style and adds angles. Text is formatted with \cs{@meta} which might add meta format. +% \begin{macrocode} +\def\@aarg#1{% + {\aargstyle{% + {\ttfamily<}% + \@meta{#1}% + {\ttfamily>}% + }}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sarg} +% Prints star with given style. +% \begin{macrocode} +\def\sarg{{\sargstyle{*}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\pkg} +% \begin{macro}{\cls} +% \begin{macro}{\env} +% \begin{macro}{\cs} +% \begin{macro}{\opt} +% \begin{macrocode} +\def\pkg{\texttt} +\def\cls{\texttt} +\def\env{\texttt} +\def\cs#1{\texttt{\textbackslash #1}} +\def\opt{\textsf} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsubsection{Text Formatting Styles} +% +% \begin{macro}{\macrodescstyle} +% Style of described macro names. +% \begin{macrocode} +\def\macrodescstyle{\ttfamily\bfseries\color{macrodesc}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\macroargsstyle} +% Default style for macro arguments (e.g.\ \cs{MacroArgs}). +% \begin{macrocode} +\def\macroargsstyle{\ttfamily} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\envcodestyle} +% Default style for code body content in described environments. +% \begin{macrocode} +\def\envcodestyle{\ttfamily} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verbstyle} +% Style for verbatim text inside macro argument list. +% \begin{macrocode} +\def\verbstyle{\ttfamily} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\metastyle} +% Meta text style. Because \cs{macroargsstyle} might be also active a |\normalfont| reset +% the font. +% \begin{macrocode} +\def\metastyle{\normalfont\itshape\color{meta}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\margstyle} +% Style for \cs{marg}. +% \begin{macrocode} +\def\margstyle{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\oargstyle} +% Style for \cs{oarg}. A special color is set to show the `optional' status. +% \begin{macrocode} +\def\oargstyle{\color{optional}\colorlet{meta}{metaoptional}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\pargstyle} +% Style for \cs{parg}. +% \begin{macrocode} +\def\pargstyle{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\aargstyle} +% Style for \cs{aarg}. +% \begin{macrocode} +\def\aargstyle{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sargstyle} +% Style for \cs{sarg}. A special color is set to show the `optional' status. +% \begin{macrocode} +\def\sargstyle{\ttfamily\color{optional}} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Dimension Registers} +% +% \begin{macro}{\descindent} +% \begin{macrocode} +\newdimen\descindent +\descindent=-\parindent +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\beforedescskip} +% \begin{macrocode} +\newdimen\beforedescskip +\beforedescskip=\bigskipamount +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\afterdescskip} +% \begin{macrocode} +\newdimen\afterdescskip +\afterdescskip=\medskipamount +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\descsep} +% Set to |1em| in |tt| font. +% \begin{macrocode} +\newdimen\descsep +\begingroup +\ttfamily +\global\descsep=1em\relax +\endgroup +% \end{macrocode} +% \end{macro} +% +% +% \subsubsection{Macro Argument Reading Mechanism} +% +% \begin{macro}{\read@Macro@arg} +% Reads next token and calls second macro. +% \begin{macrocode} +\def\read@Macro@arg{% + \futurelet\@let@token\handle@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\handle@Macro@arg} +% Checks if next token is the begin of a valid macro argument and calls +% the appropriate read macro or the end macro otherwise. +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\end@Macro@args} +% Closes box as calls hook. Might be locally redefined by some +% macros calling \cs{read@Macro@args}. +% \begin{macrocode} +\def\end@Macro@args{% + \y@egroup + \after@Macro@args +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\after@Macro@args} +% Hook to add additional commands in certain situations. +% \begin{macrocode} +\def\after@Macro@args{% +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection*{Macro argument reading macros} +% This macros read the macro arguments and call the appropriate format macros. +% +% \begin{macro}{\read@Macro@marg} +% \begin{macrocode} +\def\read@Macro@marg#1{% + \@marg{#1}\read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@oarg} +% \begin{macrocode} +\def\read@Macro@oarg[#1]{% + \@oarg{#1}\read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@parg} +% \begin{macrocode} +\def\read@Macro@parg(#1){% + \@parg{#1}\read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@aarg} +% \begin{macrocode} +\def\read@Macro@aarg<#1>>{% + \aarg{#1}\read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@angle} +% \begin{macrocode} +\def\read@Macro@angle<{% + \futurelet\@let@token\read@Macro@angle@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@angle@} +% \begin{macrocode} +\def\read@Macro@angle@{% + \ifx\@let@token<% + \expandafter\read@Macro@aarg + \else + \expandafter\read@Macro@meta + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@meta} +% \begin{macrocode} +\def\read@Macro@meta#1>{% + \meta{#1}\read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@sarg} +% \begin{macrocode} +\def\read@Macro@sarg#1{% + \sarg\read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@verb} +% Sets up verbatim mode calls second macro. +% \begin{macrocode} +\def\read@Macro@verb{% + \begingroup + \let\do\@makeother + \dospecials + \read@Macro@verb@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@verb@} +% Closes verbatim mode and formats text. +% If |#1| is empty (|''|) than a single |'| is printed. +% \begin{macrocode} +\def\read@Macro@verb@'#1'{% + \endgroup + \ifx\relax#1\relax + {\verbstyle{\string'}}% + \else + {\verbstyle{#1}}% + \fi + \read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@cmds} +% Simply executes given code. +% \begin{macrocode} +\def\read@Macro@cmds!#1!{% + #1\relax + \read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@rmspace} +% Removes space. The |\@firstofone| is used to preserve the space in the macro definition. +% \begin{macrocode} +\@firstofone{\def\read@Macro@rmspace} {% + \read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\read@Macro@addtoken} +% Takes token over from input to output `stream'. This is used for |\space| and |~|. +% \begin{macrocode} +\def\read@Macro@addtoken#1{% + #1\read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Description Macros} +% \subsubsection*{For Macros} +% +% \begin{macro}{\DescribeMacro} +% \begin{macrocode} +\@ifundefined{DescribeMacro}{}{% + \PackageInfo{ydoc-desc}{Redefining \string\DescribeMacro}{}% +} +% \end{macrocode} +% A \cs{DescribeMacro} places itself in a \env{DescribeMacros} environment. +% Multiple \cs{DescribeMacro} macros will stack themselves inside this environment. +% For this to work \cs{DescribeMacros} is locally defined to |\y@egroup| to close the +% |\hbox| from the previous \cs{DescribeMacro}. +% \begin{macrocode} +\def\DescribeMacro{% + \DescribeMacros + \let\DescribeMacros\y@egroup + \def\after@Macro@args{\endDescribeMacros}% + \begingroup\makeatletter + \Describe@Macro +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Describe@Macro} +% \begin{macrocode} +\def\Describe@Macro#1{% + \endgroup + \hbox\y@bgroup + \PrintMacroName{#1}% + \macroargsstyle + \read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Macro} +% Simply uses the two macros below. +% \begin{macrocode} +\newcommand*\Macro{\MacroArgs\AlsoMacro} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@Macro} +% Alternative definition of \cs{Macro} inside \env{DescribeMacros} environments. +% \begin{macrocode} +\def\@Macro{% + \begingroup\makeatletter + \Describe@Macro +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\AlsoMacro} +% Reads argument while |@| is a letter, +% prints the macro name and reads further arguments. +% \begin{macrocode} +\newcommand*\AlsoMacro{% + \begingroup\makeatletter + \AlsoMacro@ +} +\def\AlsoMacro@#1{% + \endgroup + \PrintMacroName{#1}% + \read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MacroArgs} +% Uses the normal macro argument reading mechanism from \cs{DescribeMacro}. +% Instead of a box a simple group is added. +% \begin{macrocode} +\newcommand*\MacroArgs{% + \begingroup + \let\end@Macro@args\endgroup + \read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DescribeMacros} +% \begin{macrocode} +\def\DescribeMacros{% + \begingroup + \let\Macro\@Macro + \parindent=0pt\relax + \setbox\descbox\vbox\y@bgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endDescribeMacros} +% \begin{macrocode} +\def\endDescribeMacros{% + \y@egroup + \PrintMacros + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DescribeMacrosTabcolsep} +% \begin{macrocode} +\def\DescribeMacrosTabcolsep{\tabcolsep} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DescribeMacrosTab} +% \begin{macrocode} +\def\DescribeMacrosTab{% + \DescribeMacros + \hbox\y@bgroup + \tabcolsep=\DescribeMacrosTabcolsep\relax + \DescribeMacrosTab@ +} +\def\DescribeMacrosTab@#1{\tabular{@{}#1@{}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endDescribeMacrosTab} +% \begin{macrocode} +\def\endDescribeMacrosTab{% + \endtabular\y@egroup + \endDescribeMacros +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection*{For Lengths} +% +% \begin{macro}{\DescribeLength} +% \begin{macrocode} +\newcommand*\DescribeLength{% + \begingroup + \let\DescribeLength\Describe@Length + \setbox\descbox\hbox\y@bgroup + \tabular{@{}l@{\hspace{2em}}l@{}}% + \Describe@Length +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Describe@Length} +% \begin{macrocode} +\newcommand*\Describe@Length[2]{% + \PrintLengthName{#1}& + (Default: {\macroargsstyle#2\unskip})% + \@ifnextchar\DescribeLength + {\\}% + {% + \endtabular + \y@egroup + \PrintLength + \endgroup + }% +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection*{For Environments} +% +% \begin{macro}{\DescribeEnv} +% \begin{macrocode} +\@ifundefined{DescribeEnv}{}{% + \PackageInfo{ydoc-desc}{Redefining \string\DescribeEnv}{}% +} +\let\DescribeEnv\relax +% \end{macrocode} +% \begin{macrocode} +\newcommand*\DescribeEnv[2][]{% + \begingroup + \def\DescribeEnv@name{#2}% + \let\\\DescribeEnv@newline +% \end{macrocode} +% +% Sets after-macro-arguments hook. +% First checks if the environment or macro version was used. +% The environment starts a new line only if the next token isn't |\end|, +% which is taken as end of the environment. +% \begin{macrocode} + \ifx\@currenvir\DescribeEnv@string + \def\after@Macro@args{% + \let\after@Macro@args\empty + \setbox\@tempboxa\hbox\y@bgroup + \@ifnextchar\end{}% + {\DescribeEnv@newline}% + #1% + }% +% \end{macrocode} +% The macro version adds the optional argument as content line if given. +% \begin{macrocode} + \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 +% \end{macrocode} +% Start |\vbox| and adds first line. +% \begin{macrocode} + \setbox\descbox\vbox\y@bgroup + \envcodestyle + \let\PrintEnv\PrintSubEnv + \hbox\y@bgroup + \PrintEnvName{\begin}{\DescribeEnv@name}% + \macroargsstyle + \read@Macro@arg +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DescribeEnv@newline} +% Closes existing and starts a new horizontal box representing a indented line. +% The optional argument allows to add extra space between lines like the normal |\\|. +% Negative values are not supported. +% \begin{macrocode} +\newcommand*\DescribeEnv@newline[1][0pt]{% + \strut\y@egroup + {\vskip#1}% + \hbox\y@bgroup\strut + \hspace*{\descsep}% + \ignorespaces +}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DescribeEnv@string} +% Holds the environment name for comparison. +% \begin{macrocode} +\def\DescribeEnv@string{DescribeEnv} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\descbox} +% Save box to store description content. +% \begin{macrocode} +\newbox\descbox +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endDescribeEnv} +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% +% \subsubsection{Print Macros} +% +% \begin{macro}{\PrintMacroName} +% Formats macro name. The backslash is forced to |tt| font. +% \begin{macrocode} +\def\PrintMacroName#1{% + {\macrodescstyle{\strut + \texttt{\char92}% + \escapechar\m@ne + \string#1}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintLengthName} +% Formats length register name. +% \begin{macrocode} +\let\PrintLengthName\PrintMacroName +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\PrintEnvName} +% |#1| = `|\begin|' or `|\end|', |#2| = env name. +% \begin{macrocode} +\def\PrintEnvName#1#2{% + \strut + \string#1\braceleft + {\macrodescstyle#2}% + \braceright +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintMacros} +% Prints macros described using \cs{DescribeMacros}. +% The actual content was stored inside \cs{descbox}. +% If it is wider than the line width it is centered. +% \begin{macrocode} +\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 +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintLength} +% Prints lengths registers described using one or multiple \cs{DescribeLength}. +% \begin{macrocode} +\let\PrintLength\PrintMacros +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintEnv} +% Prints \env{DescribeEnv} environments. +% The actual content was stored inside \cs{descbox}. +% \begin{macrocode} +\def\PrintEnv{% + \par\vspace\beforedescskip + \noindent\hspace*{\descindent}% + \fbox{\hspace*{\descsep}\usebox{\descbox}\hspace*{\descsep}}% + \par\vspace\afterdescskip +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintSubEnv} +% Prints sub environments, i.e.\ \env{DescribeEnv} environments +% inside the body of another \env{DescribeEnv}. +% The actual content was stored inside \cs{descbox}. +% \begin{macrocode} +\def\PrintSubEnv{% + \hbox{\hbox{\usebox{\descbox}}}% +} +% \end{macrocode} +% \end{macro} +% +% +% \subsubsection{Special Character Macros} +% +% \begin{macro}{\bslash} +% Defines an expandable backslash with catcode 12: `\texttt{\bslash}$_{12}$'. +% The |\@firstofone| trick is used to read the |\gdef\bslash| code before changing the catcode. +% \begin{macrocode} +{% +\@firstofone{% + \catcode`\\=12 + \gdef\bslash +}{\} +}%} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\percent} +% Defines an expandable percent character with catcode 12: `\percent$_{12}$'. +% \begin{macrocode} +\begingroup +\catcode`\%=12 +\gdef\percent{%} +\endgroup +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\braceleft} +% \begin{macro}{\braceright} +% Defines expandable left and right braces with catcode 12: `\texttt{\braceleft}$_{12}$' `\texttt{\braceright}$_{12}$'. +% \begin{macrocode} +\begingroup +\catcode`\<=1 +\catcode`\>=2 +\catcode`\{=12 +\catcode`\}=12 +\gdef\braceleft <{> +\gdef\braceright<}> +\endgroup +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsubsection{Other Macros} +% +% \begin{macro}{\y@bgroup} +% \begin{macro}{\y@egroup} +% These macros are used to begin and end |\vbox|/|\hbox|-es. +% \begin{macrocode} +\def\y@bgroup{\bgroup\color@setgroup} +\def\y@egroup{\color@endgroup\egroup} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \iffalse +%</desc> +% \fi +% +% \iffalse +%<*expl> +% \fi +% \subsection{Include Code Examples} +% +% \iffalse +%<*dontinclude> +% \begin{macrocode} +\newcounter{example} +\def\examplename{Example} +\newenvironment{example}[1]{% + \par\bigskip\noindent + \centerline{\examplename~\refstepcounter{example}\theexample: #1}% + \smallskip + \hrule + \smallskip +}{% + \smallskip + \hrule + \par\bigskip +} +% \end{macrocode} +% +% \begin{macro}{\PrintExample} +% \begin{macrocode} +\def\PrintExample{% + \usebox\examplecodebox + \hfill + \usebox\exampleresultbox +} +% \end{macrocode} +% \end{macro} +%</dontinclude> +% \fi +% +% \begin{macrocode} +\RequirePackage{listings} +\lst@RequireAspects{writefile} +\def\ydoc@exafile{\jobname.exa} +% \end{macrocode} +% +% \begin{macro}{\exampleprintsettings} +% \begin{macrocode} +\def\exampleprintsettings{frame=lines}% +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\newbox\examplecodebox +\newbox\exampleresultbox +% \end{macrocode} +% +% \begin{macro}{\BoxExample} +% \begin{macrocode} +\def\BoxExample{% + \setbox\examplecodebox\hbox{\color@setgroup + \expandafter\expandafter\expandafter\lstinputlisting + \expandafter\expandafter\expandafter[% + \expandafter\exampleprintsettings\expandafter,\thisexampleprintsettings]% + {\ydoc@exafile}% + \color@endgroup}% + \setbox\exampleresultbox\hbox{\color@setgroup + \@@input\ydoc@exafile\relax + \color@endgroup}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PrintExample} +% \begin{macrocode} +\RequirePackage{showexpl} +\def\PrintExample{% + \begingroup + \lstset{basicstyle=\ttfamily}% + \MakePercentComment + \LTXinputExample[varwidth]{\ydoc@exafile}% + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macrocode} +\def\examplecodesettings{gobble=4} +% \end{macrocode} +% +% \begin{environment}{examplecode} +% \begin{macrocode} +\lstnewenvironment{examplecode}[1][]{% + \def\thisexampleprintsettings{#1}% + \expandafter\lstset\expandafter{\examplecodesettings,#1}% + \setbox\@tempboxa\hbox\bgroup + \lst@BeginWriteFile{\ydoc@exafile}% +} +{% + \lst@EndWriteFile + \egroup + \PrintExample +} +% \end{macrocode} +% \end{environment} +% +% \begin{macrocode} +\RequirePackage{float} +% \end{macrocode} +% +% \begin{environment}{example} +% \begin{macrocode} +\floatstyle{plain} +\newfloat{example}{tbhp}{loe} +\floatname{example}{\examplename} +\def\examplename{Example} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{exampletable} +% \begin{macrocode} +\newenvironment{exampletable}{% + \floatstyle{plaintop}% + \restylefloat{example}% + \example +}{\endexample} +% \end{macrocode} +% \end{environment} +% +% \iffalse +%</expl> +% \fi +% \Finale +\endinput diff --git a/Master/texmf-dist/source/latex/ydoc/ydoc.ins b/Master/texmf-dist/source/latex/ydoc/ydoc.ins new file mode 100644 index 00000000000..eead38f53ef --- /dev/null +++ b/Master/texmf-dist/source/latex/ydoc/ydoc.ins @@ -0,0 +1,26 @@ +% ydoc.ins +% Copyright (c) 2010 by Martin Scharrer <martin@scharrer-online.de> +% WWW: http://latex.scharrer-online.de/ + +% See file 'ydoc.dtx' for copyright and licence information. +% $Id: ydoc.ins 1846 2010-04-10 10:41:21Z martin $ + +\input docstrip + +\keepsilent +\askforoverwritefalse + +\preamble +\endpreamble + +\generate{% + \file{ydoc.cls}{\from{ydoc.dtx}{class}}% + \file{ydoc.sty}{\from{ydoc.dtx}{package}}% + \file{ydoc-code.sty}{\from{ydoc.dtx}{code}}% + \file{ydoc-desc.sty}{\from{ydoc.dtx}{desc}}% + \file{ydoc-expl.sty}{\from{ydoc.dtx}{expl}}% + \file{ydoc-doc.sty}{\from{ydoc.dtx}{doc}}% +} + +\endbatchfile +% vim: ft=tex |