diff options
author | Karl Berry <karl@freefriends.org> | 2011-08-13 22:20:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-08-13 22:20:48 +0000 |
commit | 6896e1abedec5194e9a456ce8d6c630999e4ed0f (patch) | |
tree | db4ba79c3b3a9afcc9d682ff1135a3440930bb70 /Master/texmf-dist/source/latex/ydoc/ydoc.dtx | |
parent | 878253a4b3b9dc4e9da23f4aaffb88d5d3cf6dff (diff) |
ydoc (13aug11)
git-svn-id: svn://tug.org/texlive/trunk@23544 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/ydoc/ydoc.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/ydoc/ydoc.dtx | 427 |
1 files changed, 293 insertions, 134 deletions
diff --git a/Master/texmf-dist/source/latex/ydoc/ydoc.dtx b/Master/texmf-dist/source/latex/ydoc/ydoc.dtx index 0e8cccfa53c..406e1277337 100644 --- a/Master/texmf-dist/source/latex/ydoc/ydoc.dtx +++ b/Master/texmf-dist/source/latex/ydoc/ydoc.dtx @@ -1,3 +1,101 @@ +% \iffalse +%<*driver> +\expandafter\ifx\csname NeedsTeXFormat\endcsname\relax\else +\begingroup +\long\def\skip#1\NeedsTeXFormat{\endgroup\NeedsTeXFormat} +\expandafter\skip +\fi +%</driver> +% \fi +% +% \iffalse +%<*ydocstrip.tex> +% \fi +% +% \iffalse +\expandafter\ifx\csname ydocstripversion\endcsname\relax\else + \noindent +\fi + +\chardef\ydocstripversion=1 + +\input docstrip + + +\def\checkOption<#1{% + \ifcase + \ifx*#10\else \ifx/#11\else + \ifx+#12\else \ifx-#13\else + \ifx<#14\else + \ifx=#15\else + \ifx!#16\else + 10\fi\fi\fi\fi\fi\fi\fi\relax + \expandafter\starOption\or + \expandafter\slashOption\or + \expandafter\plusOption\or + \expandafter\minusOption\or + \expandafter\verbOption\or + \expandafter\varOption\or + \expandafter\valueOption\else + \expandafter\doOption\fi + #1} + +\def\varOption =#1#2>#3\endLine{{% + \ifx*#1\relax + \edef\varStop{\perCent<=/#2>}% + \global\expandafter\let\csname ydocstrip@var@#2\endcsname\empty% + \expandafter\def\csname ydocstrip@var@#2\endcsname##1{}% + \loop + \ifeof\inFile + \errmessage{Source file ended while reading a multi-line variable content!}% + \fi + \read\inFile to \inLine + \if 1\ifx\inLine\varStop 0\fi 1% if not inLine==varStop + \expandafter\xdef\csname ydocstrip@var@#2\endcsname{\csname ydocstrip@var@#2\endcsname^^J\inLine}% + \maybeMsg{.}% + \repeat + \else + \ifx/#1\relax + \errmessage{Error in expression: spurious '<=/#2>'}% + \else + \ifx+#1\relax + \expandafter\ifx\csname ydocstrip@var@#2\endcsname\relax + \expandafter\xdef\csname ydocstrip@var@#2\endcsname{#3}% + \else + \expandafter\xdef\csname ydocstrip@var@#2\endcsname{\csname ydocstrip@var@#2\endcsname^^J#3}% + \fi + \else + \expandafter\gdef\csname ydocstrip@var@#1#2\endcsname{#3}% + \fi + \fi + \fi +}} + + +\def\valueOption !#1>#2\endLine{% + \begingroup + \expandafter\let\expandafter\var\csname ydocstrip@var@#1\endcsname + \ifx\var\relax + \errmessage{Used variable '#1' was never defined!}% + \else + \ifx\var\empty\else + \def\do##1##2##3{% + \StreamPut##1{\csname ydocstrip@var@#1\endcsname}% + }% + \activefiles + \fi + \fi + \endgroup +} + +% \fi +% \iffalse +%</ydocstrip.tex> +% \fi +% +% \iffalse +%<*ydoc.ins> +% \fi % \iffalse COPYRIGHT %% %% Copyright (c) 2010-2011 by Martin Scharrer <martin@scharrer-online.de> @@ -22,14 +120,7 @@ % \fi % % \iffalse -%<*dtx> -\begingroup -\expandafter\ifx\csname install\endcsname\relax\fi -\expandafter\ifx\csname endinstall\endcsname\relax\fi -\install -%</dtx> -%<*install> -\input ydocstrip.tex +\input ydocstrip \preamble \endpreamble @@ -38,19 +129,19 @@ \askforoverwritefalse \generate{% - \file{ydoc.cls} {\from{ydoc.dtx}{class}}% - \file{ydoc.sty} {\from{ydoc.dtx}{package}}% - \file{ydoc.cfg} {\from{ydoc.dtx}{cfg}}% - \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}}% + \file{ydocstrip.tex}{\from{ydoc.dtx}{ydocstrip.tex}}% + \file{ydoc.ins} {\from{ydoc.dtx}{ydoc.ins}}% + \file{ydoc.cls} {\from{ydoc.dtx}{ydoc.cls}}% + \file{ydoc.sty} {\from{ydoc.dtx}{ydoc.sty}}% + \file{ydoc.cfg} {\from{ydoc.dtx}{ydoc.cfg}}% + \file{ydoc-code.sty}{\from{ydoc.dtx}{ydoc-code.sty}}% + \file{ydoc-desc.sty}{\from{ydoc.dtx}{ydoc-desc.sty}}% + \file{ydoc-expl.sty}{\from{ydoc.dtx}{ydoc-expl.sty}}% + \file{ydoc-doc.sty} {\from{ydoc.dtx}{ydoc-doc.sty}}% } \begingroup -\expandafter\obeyspaces -\csname AtEndDocument\endcsname{% -\ifx\Msg\undefined\let\Msg\typeout\fi +\obeyspaces \Msg{*************************************************************}% \Msg{* *}% \Msg{* To finish the installation you have to move the following *}% @@ -62,40 +153,37 @@ \Msg{* ydoc-desc.sty *}% \Msg{* ydoc-expl.sty *}% \Msg{* ydoc-doc.sty *}% +\Msg{* ydocstrip.tex *}% \Msg{* *}% -\Msg{* To produce the documentation run the file standalone.dtx *}% +\Msg{* To produce the documentation run the file ydoc.dtx *}% \Msg{* through LaTeX. *}% \Msg{* *}% \Msg{* Happy TeXing! *}% \Msg{* *}% \Msg{*************************************************************}% -}% -\endgroup +\endgroup% -%<install>\endbatchfile -%</install> -%<*dtx> -\endinstall -\endgroup -%</dtx> -%<install>% vim: ft=tex +\endbatchfile +% vim: ft=tex +% \fi +% \iffalse +%</ydoc.ins> % \fi % % \iffalse %<*driver> -% \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\RequirePackage{svn-prov}[2010/04/03] -\ProvidesFileSVN[ydoc.dtx] - {$Id: ydoc_doc.dtx 2378 2011-03-20 20:34:27Z martin $} +\ProvidesFile{ydoc.dtx}[% +%<=*DATE> + 2011/08/11 +%<=/DATE> %<=*VERSION> - [v0.5alpha] + v0.5alpha %<=/VERSION> - [DTX file of ydoc] + DTX file of ydoc] -\DefineFileInfoSVN -\GetFileInfoSVN* -\documentclass{ydoc}[\filedate] +\message{^^JRun this DTX file using 'tex' to extract all files!^^J} +\documentclass{ydoc}[2011/08/11] \newdimen\tempskip @@ -106,7 +194,7 @@ \caption } -\OnlyDescription +%\OnlyDescription \begin{document} \DocInput{ydoc.dtx} \PrintChanges @@ -415,6 +503,7 @@ % \subsection{Macros and Environments to include LaTeX Code Examples} % \DescribeEnv{example} % \DescribeEnv{examplecode} +% % (to be written) % % \StopEventually{} @@ -422,21 +511,21 @@ % \clearpage % \section{Implementation} % +% % \iffalse -%<*class> +%<*ydoc.cls> % \fi % \subsection{Class File} % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\RequirePackage{svn-prov}[2010/04/03] -\ProvidesClassSVN - {$Id: ydoc_cls.dtx 2336 2011-03-18 00:56:07Z martin $} +\ProvidesClass{ydoc}[% +%<!DATE> %<!VERSION> %<*DRIVER> - [develop] + 2011/08/11 develop %</DRIVER> - [ydoc class: document LaTeX class and packages] + ydoc class: document LaTeX class and packages] % \end{macrocode} % % At the moment simply load \cls{article} class with \opt{a4paper} option @@ -448,26 +537,24 @@ \LoadClass{article} \RequirePackage{ydoc} % \end{macrocode} -% % \iffalse -%</class> +%</ydoc.cls> % \fi % % \iffalse -%<*package> +%<*ydoc.sty> % \fi % \subsection{Package File} % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\RequirePackage{svn-prov}[2010/04/03] -\ProvidesPackageSVN[ydoc] - {$Id: ydoc_sty.dtx 2332 2011-03-17 17:12:35Z martin $} +\ProvidesPackage{ydoc}[% +%<!DATE> %<!VERSION> %<*DRIVER> - [develop] + 2011/08/11 develop %</DRIVER> - [ydoc package: document LaTeX class and packages] + ydoc package: document LaTeX class and packages] % \end{macrocode} % % \begin{macrocode} @@ -484,46 +571,39 @@ \input{ydoc.cfg} % \end{macrocode} % \iffalse -%</package> +%</ydoc.sty> % \fi % -% % \iffalse -%<*cfg> +%<*ydoc.cfg> % \fi % \subsection{Config File} % \begin{macrocode} %% Please delete the following line on manual changes: -\ProvidesFileSVN[ydoc.cfg]{$Id: ydoc_cfg.dtx 2338 2011-03-18 01:14:34Z martin $} +\ProvidesFile{ydoc.cfg}[% +%<!DATE> %<!VERSION> %<*DRIVER> - [develop] + 2011/08/11 develop %</DRIVER> - [Default config file for ydoc] + Default config file for ydoc] % \end{macrocode} % -% Use 'Linux Libertine' font as main font if installed. -% Define "\/" to some fixed italic corrections -% as long there is none defined by the font. % \begin{macrocode} \usepackage[T1]{fontenc} -\IfFileExists{libertine.sty}{% - \usepackage{libertine} - \begingroup - \setbox0\hbox{\it g\/} - \setbox1\hbox{\it g} - \ifnum\wd0>\wd1\else - \gdef\/{\kern 0.8864pt} - \fi - \endgroup +\IfFileExists{fourier.sty}{% + \usepackage{fourier} }{} % \end{macrocode} % -% Only use 'lmodern' for the 'tt' font if installed. +% Use 'lmodern' only for the 'tt' font if fourier is installed. % \begin{macrocode} -\IfFileExists{lmodern.sty}{% - %\usepackage{lmodern} - \renewcommand{\ttdefault}{lmtt} +\IfFileExists{lmodern.sty}{ + \IfFileExists{fourier.sty}{ + \renewcommand{\ttdefault}{lmtt} + }{ + \usepackage{lmodern} + } }{} % \end{macrocode} % @@ -552,26 +632,25 @@ % \begin{macrocode} \reversemarginpar % \end{macrocode} +% % \iffalse -%</cfg> +%</ydoc.cfg> % \fi % % \iffalse -%<*code> +%<*ydoc-code.sty> % \fi -% % \subsection{Macros and Environments to document Implementations} % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\RequirePackage{svn-prov}[2010/04/03] -\ProvidesPackageSVN - {$Id: ydoc_code_sty.dtx 2339 2011-03-18 20:18:09Z martin $} +\ProvidesPackage{ydoc-code}[% +%<!DATE> %<!VERSION> %<*DRIVER> - [develop] + 2011/08/11 develop %</DRIVER> - [ydoc package to document macro code] + ydoc package to document macro code] % \end{macrocode} % % \begin{macrocode} @@ -812,6 +891,18 @@ % \end{macrocode} % \end{environment} % +% \begin{environment}{key}[2]{key family}{key name} +% \begin{macrocode} +\def\key#1#2{% + \PrintMacroImpl{KV@#1@#2}% + \@ifnextchar[%] + {\macro@impl@args}% + {}% +} +\def\endkey{} +% \end{macrocode} +% \end{environment} +% % \begin{environment}{environment}[1]{environment name} % \begin{macrocode} \def\environment#1{% @@ -824,6 +915,20 @@ % \end{macrocode} % \end{environment} % +% +% \begin{environment}{style}[1]{style name} +% \begin{macrocode} +\def\style#1{% + \PrintStyleImplName{#1}% + \@ifnextchar[%] + {\macro@impl@args}% + {}% +} +\def\endstyle{} +\def\PrintStyleImplName{\PrintEnvImplName} +% \end{macrocode} +% \end{environment} +% % \begin{macro}{\PrintMacroImpl}[1]{macro (token)} % \begin{macrocode} \def\PrintMacroImpl#1{% @@ -885,25 +990,23 @@ }%} % \end{macrocode} % \end{macro} -% % \iffalse -%</code> +%</ydoc-code.sty> % \fi % % \iffalse -%<*doc> +%<*ydoc-doc.sty> % \fi % \subsection{Provide \pkg{doc} macros} % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\RequirePackage{svn-prov}[2010/04/03] -\ProvidesPackageSVN[ydoc] - {$Id: ydoc_doc_sty.dtx 2378 2011-03-20 20:34:27Z martin $} +\ProvidesPackage{ydoc-doc}[% +%<!DATE> %<!VERSION> %<*DRIVER> - [develop] + 2011/08/11 develop %</DRIVER> - [ydoc package to provide 'doc' macros] + ydoc package to provide 'doc' macros] % \end{macrocode} % % \begin{macro}{\ydoc@countbslashes} @@ -1220,26 +1323,24 @@ \let\orig@maketitle\relax } % \end{macrocode} -% % \iffalse -%</doc> +%</ydoc-doc.sty> % \fi % % \iffalse -%<*desc> +%<*ydoc-desc.sty> % \fi % \subsection{Description Macros and Environments} % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\RequirePackage{svn-prov}[2010/04/03] -\ProvidesPackageSVN[ydoc-desc] - {$Id: ydoc_desc_sty.dtx 2369 2011-03-20 00:04:45Z martin $} +\ProvidesPackage{ydoc-desc}[% +%<!DATE> %<!VERSION> %<*DRIVER> - [develop] + 2011/08/11 develop %</DRIVER> - [ydoc package to describe macros, environments, options etc.] + ydoc package to describe macros, environments, options etc.] % \end{macrocode} % % \begin{macrocode} @@ -1264,6 +1365,7 @@ % \begin{macrocode} \RequirePackage{xcolor} \definecolor{macrodesc}{rgb}{0,0.2,0.6} +\definecolor{keydesc}{rgb}{0,0.4,0.9} \definecolor{macroimpl}{rgb}{0,0.1,0.3} \definecolor{meta}{rgb}{0,0.25,0.75} \definecolor{scriptcolor}{rgb}{0.2,0.6,0.2} @@ -1420,6 +1522,12 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\Key} +% \begin{macrocode} +\newrobustcmd*\Key[1]{\PrintKeyName{#1}\MacroArgs} +% \end{macrocode} +% \end{macro} +% % \subsubsection{Text Formatting Styles} % % \begin{macro}{\macrodescstyle} @@ -1429,6 +1537,13 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\macrodescstyle} +% Style of described macro names. +% \begin{macrocode} +\def\keydescstyle{\ttfamily\bfseries\color{keydesc}} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\macroargsstyle} % Default style for macro arguments (e.g.\ \cs{MacroArgs}). % \begin{macrocode} @@ -1571,7 +1686,7 @@ \def\AlsoMacro@#1{% \endgroup %<*DEBUG> - \typeout{DEBUG: Macro: \string#1}% + %\typeout{DEBUG: Macro: \string#1}% %</DEBUG> \PrintMacroName{#1}% \read@Macro@arg @@ -1618,14 +1733,14 @@ \ifx\handler\relax \def\handler{\ifhmode\unskip\fi\end@Macro@args}% %<*DEBUG> - \typeout{DEBUG: Stopped at: \expandafter\meaning\csname @let@token\endcsname}% - \typeout{}% - \else - \expandafter\ifx\csname @let@token\endcsname\AlsoMacro - \typeout{DEBUG: TOKEN: \string\AlsoMacro}% - \else - \typeout{DEBUG: TOKEN: \expandafter\meaning\csname @let@token\endcsname}% - \fi + % \typeout{DEBUG: Stopped at: \expandafter\meaning\csname @let@token\endcsname}% + % \typeout{}% + %\else + %\expandafter\ifx\csname @let@token\endcsname\AlsoMacro + % \typeout{DEBUG: TOKEN: \string\AlsoMacro}% + %\else + % \typeout{DEBUG: TOKEN: \expandafter\meaning\csname @let@token\endcsname}% + %\fi %</DEBUG> \fi \handler @@ -1905,6 +2020,19 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\DescribeKey} +% \begin{macrocode} +\def\DescribeKey{% + \DescribeKeys + \let\DescribeKeys\y@egroup + \optionalon + \def\after@Macro@args{\endDescribeKeys}% + \begingroup\makeatletter + \Describe@Macro +} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\Describe@Macro} % \begin{macrocode} \def\Describe@Macro#1{% @@ -1979,6 +2107,7 @@ % \begin{macrocode} \define@Macro@handler\AlsoMacro{} \define@Macro@handler\DescribeMacro{} +\define@Macro@handler\DescribeKey{} % \end{macrocode} % % \begin{macro}{\MacroArgs} @@ -1991,8 +2120,8 @@ \ydoc@macrocatcodes \macroargsstyle %<*DEBUG> - \typeout{}% - \typeout{DEBUG: Start MacroArgs}% + %\typeout{}% + %\typeout{DEBUG: Start MacroArgs}% %</DEBUG> \read@Macro@arg } @@ -2021,6 +2150,29 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\DescribeKeys} +% \begin{macrocode} +\def\DescribeKeys{% + \begingroup + \let\PrintMacroName\PrintKeyName + \let\Key\@Macro + \parindent=0pt\relax + \setbox\descbox\vbox\y@bgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endDescribeKeys} +% \begin{macrocode} +\def\endDescribeKeys{% + \y@egroup + \PrintKeys + \endgroup +} +\def\PrintKeys{\PrintMacros} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\DescribeMacrosTabcolsep} % \begin{macrocode} \def\DescribeMacrosTabcolsep{\tabcolsep} @@ -2208,6 +2360,16 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\PrintKeyName} +% Formats macro name. The backslash is forced to |tt| font. +% \begin{macrocode} +\def\PrintKeyName#1{% + {\keydescstyle{\strut + #1\strut}}% +} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\PrintLengthName} % Formats length register name. % \begin{macrocode} @@ -2237,7 +2399,7 @@ \par\vspace\beforedescskip \begingroup \sbox\@tempboxa{\descframe{\usebox{\descbox}}}% - \Needspace*{\dimexpr\ht\@tempboxa+2\baselineskip\relax}% + \Needspace*{\dimexpr\ht\@tempboxa+3\baselineskip\relax}% \par\noindent \ifdim\wd\@tempboxa>\dimexpr\linewidth-2\descindent\relax \makebox[\linewidth][c]{\usebox\@tempboxa}% @@ -2378,26 +2540,24 @@ {\par\egroup\smallskip\noindent\ignorespacesafterend} % \end{macrocode} % \end{environment} -% % \iffalse -%</desc> +%</ydoc-desc.sty> % \fi % % \iffalse -%<*expl> +%<*ydoc-expl.sty> % \fi % \subsection{Include Code Examples} % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\RequirePackage{svn-prov}[2010/04/03] -\ProvidesPackageSVN[ydoc] - {$Id: ydoc_expl_sty.dtx 2332 2011-03-17 17:12:35Z martin $} +\ProvidesPackage{ydoc-expl}[% +%<!DATE> %<!VERSION> %<*DRIVER> - [develop] + 2011/08/11 develop %</DRIVER> - [ydoc package to insert live examples of LaTeX code] + ydoc package to insert live examples of LaTeX code] % \end{macrocode} % % \iffalse @@ -2436,11 +2596,17 @@ \def\ydoc@exafile{\jobname.exa} % \end{macrocode} % -% \begin{macro}{\exampleprintsettings} +% \begin{style}{examplecode} % \begin{macrocode} -\def\exampleprintsettings{numbers=left,numberstyle=\tiny\color{gray}\sffamily,numbersep=5pt}% +\lstdefinestyle{examplecode}{numbers=left,firstnumber=1,numberstyle=\tiny\color{gray}\sffamily,numbersep=5pt}% % \end{macrocode} -% \end{macro} +% \end{style} +% +% \begin{style}{exampleextract} +% \begin{macrocode} +\lstdefinestyle{exampleextract}{gobble=4}% +% \end{macrocode} +% \end{style} % % \begin{macrocode} \newbox\examplecodebox @@ -2451,9 +2617,7 @@ % \begin{macrocode} \def\BoxExample{% \setbox\examplecodebox\hbox{\color@setgroup - \expandafter\expandafter\expandafter\lstinputlisting - \expandafter\expandafter\expandafter[% - \expandafter\exampleprintsettings\expandafter,\thisexampleprintsettings]% + \lstinputlisting[style=examplecode,style=thisexampleprint]% {\ydoc@exafile}% \unskip\color@endgroup}% \setbox\exampleresultbox\hbox{\color@setgroup @@ -2469,7 +2633,7 @@ \RequirePackage{showexpl} \def\PrintExample{% \begingroup - \lstset{basicstyle=\ttfamily}% + \lstset{style=examplecode}% \MakePercentComment \LTXinputExample[varwidth]{\ydoc@exafile}% \endgroup @@ -2509,16 +2673,11 @@ % \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}% + \lstdefinestyle{thisexampleprint}{#1}% + \lstset{style=exampleextract,#1}% \setbox\@tempboxa\hbox\bgroup \lst@BeginWriteFile{\ydoc@exafile}% } @@ -2556,9 +2715,9 @@ }{\endexample} % \end{macrocode} % \end{environment} -% % \iffalse -%</expl> +%</ydoc-expl.sty> % \fi +% % \Finale % \endinput |