Debian Codegraph @

texmf-dist/source/latex/base/doc.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2025
4 % The LaTeX Project and any individual authors listed elsewhere
5 % in this file.
6 %
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9 %
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % https://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2008 or later.
17 %
18 % This file has the LPPL maintenance status "maintained".
19 %
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
23 %
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
27 %
28 % \fi
29 % ^^A -*-LaTeX-*-
30 %
31 % ^^A These shouldn't come out in .ist files, hence the module
32 % ^^A comments, or in the printed version, hence temporary comment
33 % ^^A category for `<'
34 %\catcode`\<=14
35 %<+package|shortvrb>\NeedsTeXFormat{LaTeX2e}[1994/12/01]
36 %<+package>
37 % ^^A Any rollback request before 2016-02-15 we try to fulfill with the 2016 version:
38 %<+package>\DeclareRelease{}{1994-06-01}
39 %<+package> {doc-2016-02-15.sty}
40 %<+package>\DeclareRelease{v2.1g}{2016-02-15}
41 %<+package> {doc-2016-02-15.sty}
42 %<+package>\DeclareRelease{v2}{2021-06-01}
43 %<+package> {doc-2021-06-01.sty}
44 %<+package>\DeclareCurrentRelease{v3}{2022-06-01}
45 %<+package>
46 %<+package>\ProvidesPackage{doc}
47 %<+shortvrb>\ProvidesPackage{shortvrb}
48 %<+package|shortvrb> [2024/12/25 v3.0q
49 %<+package|shortvrb> Standard LaTeX documentation package V3 (FMi)]
50 %\catcode`\<=12
51 %
52 %%
53 %\iffalse This is a METACOMMENT
54 % Everything up to the next `\ fi' (without a blank) will
55 % be ignored. This is necessary because `%' may no longer
56 % be a comment mark when this file is read in.
57 %
58 %
59 %% Package `doc' to use with LaTeX 2e
60 %% Copyright (C) 1989-2023 Frank Mittelbach, all rights reserved.
61 %
62 %
63 % Version: Date: Changes:
64 %
65 % 1.0a 5.5.88 This is nothing but a collection of tests and
66 % hacks. It is certainly going to be greatly
67 % changed.
68 % Better not to use it!
69 % 1.5a and earlier... are not longer recorded
70 % 1.5b and higher... are documented with the (undocumented) \changes
71 % feature.
72 %\fi
73 % \changes{v1.5f}{1989/04/29}{Thanks to Brian who documented the
74 % \cs{changes} macro feature.}
75 % \changes{v1.5g}{1989/05/07}{MacroTopsep now called MacrocodeTopsep and
76 % new MacroTopsep added}
77 % \changes{v1.5h}{1989/05/17}{All lines shortened to <72 characters}
78 % \changes{v1.5j}{1989/06/09}{Corrections by Ron Whitney added}
79 % \changes{v1.5q}{1989/11/03}{`\ldots{}Listing macros renamed to
80 % `\ldots{}Input. Suggested by R. Wonneberger}
81 % \changes{v1.5w}{1990/02/05}{Counter codelineno renamed to CodelineNo}
82 % \changes{v1.9a}{1993/12/02}{Upgrade for LaTeX2e}
83 % \changes{v1.9d}{1993/12/20}{Protected changes entry.}
84 % \changes{v1.0p}{1994/05/21}{Use new error commands}
85 % \changes{v3.0m}{2022/11/13}{Redefinitions of \cs{verb} removed as
86 % no longer needed (gh/953)}
87 %
88 %
89 % \hyphenation{make-index}
90 %
91 % \DoNotIndex{\@,\@@par,\@beginparpenalty,\@empty}
92 % \DoNotIndex{\@flushglue,\@gobble,\@input}
93 % \DoNotIndex{\@makefnmark,\@makeother,\@maketitle}
94 % \DoNotIndex{\@namedef,\@ne,\@spaces,\@tempa}
95 % \DoNotIndex{\@tempb,\@tempswafalse,\@tempswatrue}
96 % \DoNotIndex{\@thanks,\@thefnmark,\@topnum}
97 % \DoNotIndex{\@@,\@elt,\@forloop,\@fortmp,\@gtempa,\@totalleftmargin}
98 % \DoNotIndex{\",\/,\@ifundefined,\@nil,\@verbatim,\@vobeyspaces}
99 % \DoNotIndex{\|,\~,\ ,\active,\advance,\aftergroup,\begingroup,\bgroup}
100 % \DoNotIndex{\mathcal,\csname,\def,\documentstyle,\dospecials,\edef}
101 % \DoNotIndex{\egroup}
102 % \DoNotIndex{\else,\endcsname,\endgroup,\endinput,\endtrivlist}
103 % \DoNotIndex{\expandafter,\fi,\fnsymbol,\futurelet,\gdef,\global}
104 % \DoNotIndex{\hbox,\hss,\if,\if@inlabel,\if@tempswa,\if@twocolumn}
105 % \DoNotIndex{\ifcase}
106 % \DoNotIndex{\ifcat,\iffalse,\ifx,\ignorespaces,\index,\input,\item}
107 % \DoNotIndex{\jobname,\kern,\leavevmode,\leftskip,\let,\llap,\lower}
108 % \DoNotIndex{\m@ne,\next,\newpage,\nobreak,\noexpand,\nonfrenchspacing}
109 % \DoNotIndex{\obeylines,\or,\protect,\raggedleft,\rightskip,\rm,\sc}
110 % \DoNotIndex{\setbox,\setcounter,\small,\space,\string,\strut}
111 % \DoNotIndex{\strutbox}
112 % \DoNotIndex{\thefootnote,\thispagestyle,\topmargin,\trivlist,\tt}
113 % \DoNotIndex{\twocolumn,\typeout,\vss,\vtop,\xdef,\z@}
114 % \DoNotIndex{\,,\@bsphack,\@esphack,\@noligs,\@vobeyspaces,\@xverbatim}
115 % \DoNotIndex{\`,\catcode,\end,\escapechar,\frenchspacing,\glossary}
116 % \DoNotIndex{\hangindent,\hfil,\hfill,\hskip,\hspace,\ht,\it,\langle}
117 % \DoNotIndex{\leaders,\long,\makelabel,\marginpar,\markboth,\mathcode}
118 % \DoNotIndex{\mathsurround,\mbox,\newcount,\newdimen,\newskip}
119 % \DoNotIndex{\nopagebreak}
120 % \DoNotIndex{\parfillskip,\parindent,\parskip,\penalty,\raise,\rangle}
121 % \DoNotIndex{\section,\setlength,\TeX,\topsep,\underline,\unskip,\verb}
122 % \DoNotIndex{\vskip,\vspace,\widetilde,\\,\%,\@date,\@defpar}
123 % \DoNotIndex{\[,\{,\},\]}
124 % \DoNotIndex{\count@,\ifnum,\loop,\today,\uppercase,\uccode}
125 % \DoNotIndex{\baselineskip,\begin,\tw@}
126 % \DoNotIndex{\a,\b,\c,\d,\e,\f,\g,\h,\i,\j,\k,\l,\m,\n,\o,\p,\q}
127 % \DoNotIndex{\r,\s,\t,\u,\v,\w,\x,\y,\z,\A,\B,\C,\D,\E,\F,\G,\H}
128 % \DoNotIndex{\I,\J,\K,\L,\M,\N,\O,\P,\Q,\R,\S,\T,\U,\V,\W,\X,\Y,\Z}
129 % \DoNotIndex{\1,\2,\3,\4,\5,\6,\7,\8,\9,\0}
130 % \DoNotIndex{\!,\#,\$,\&,\',\(,\),\+,\.,\:,\;,\<,\=,\>,\?,\_}
131 % \DoNotIndex{\discretionary,\immediate,\makeatletter,\makeatother}
132 % \DoNotIndex{\meaning,\newenvironment,\par,\relax,\renewenvironment}
133 % \DoNotIndex{\repeat,\scriptsize,\selectfont,\the,\undefined}
134 % \DoNotIndex{\arabic,\do,\makeindex,\null,\number,\show,\write,\@ehc}
135 % \DoNotIndex{\@author,\@ehc,\@ifstar,\@sanitize,\@title,\everypar}
136 % \DoNotIndex{\if@minipage,\if@restonecol,\ifeof,\ifmmode}
137 % \DoNotIndex{\lccode,\newtoks,\onecolumn,\openin,\p@,\SelfDocumenting}
138 % \DoNotIndex{\settowidth,\@resetonecoltrue,\@resetonecolfalse,\bf}
139 % \DoNotIndex{\clearpage,\closein,\lowercase,\@inlabelfalse}
140 % \DoNotIndex{\selectfont,\mathcode,\newmathalphabet,\rmdefault}
141 % \DoNotIndex{\bfdefault}
142 %
143 % \MakeShortVerb{\|}
144 % \setcounter{StandardModuleDepth}{1}
145 %
146 % {\catcode`\p=12 \catcode`\t=12 ^^A hack used later on to print a
147 % \gdef\dimenvalue#1pt{$#1$pt}} ^^A register value with a - sign
148 %
149 % \newcommand{\DOC}{\texttt{doc}\xspace}
150 %
151 % \changes{v3.0j}{2022/06/02}{Use \cs{providecommand} to define \cs{pkg}}
152 % \providecommand\env{\texttt}
153 % \providecommand\opt{\texttt}
154 % \providecommand\cls{\texttt}
155 % \providecommand\pkg{\texttt}
156 % \providecommand\prg{\textsf}
157 %
158 % \newcommand\DOX{\env{DoX}\xspace}
159 % \newcommand\api{\textsc{api}\xspace}
160 %
161 % \newcommand\fmi[1]{\par\textbf{TODO: }\textit{#1}\par}
162 %
163 % \newcommand\NewIn[1]{\leavevmode
164 % \marginpar{\hfill\fbox{\fbox{New in #1}}\hspace*{1em}}\ignorespaces}
165 %
166 %
167 %\RenewDocElement[macrolike = true ,
168 % toplevel = false,
169 % idxtype = ,
170 % idxgroup = LaTeX commands\actualchar\LaTeX{} commands ,
171 % printtype =
172 % ]{Macro}{macro}
173 %
174 %\RenewDocElement[macrolike = false ,
175 % toplevel = false,
176 % idxtype = env. ,
177 % idxgroup = Package environments,
178 % printtype = \textit{env.}
179 % ]{Env}{environment}
180 %
181 %
182 %\NewDocElement[macrolike = true ,
183 % toplevel = false,
184 % idxtype = ,
185 % idxgroup = Package commands,
186 % printtype =
187 % ]{InterfaceMacro}{imacro}
188 %
189 %\NewDocElement[macrolike = true ,
190 % toplevel = false,
191 % idxtype = ,
192 % idxgroup = Package commands (obsolete),
193 % printtype =
194 % ]{ObsoleteInterfaceMacro}{omacro}
195 %
196 %\NewDocElement[macrolike = false ,
197 % toplevel = false,
198 % idxtype = counter ,
199 % idxgroup = LaTeX counters\actualchar \LaTeX{} counters ,
200 % printtype = \textit{counter}
201 % ]{LaTeXCounter}{lcounter}
202 %
203 %\NewDocElement[macrolike = true ,
204 % toplevel = false,
205 % idxtype = counter ,
206 % idxgroup = TeX counters\actualchar \protect\TeX{} counters ,
207 % printtype = \textit{counter}
208 % ]{TeXCounter}{tcounter}
209 %
210 %
211 %\NewDocElement[macrolike = true ,
212 % toplevel = false,
213 % idxtype = skip ,
214 % idxgroup = LaTeX length\actualchar \LaTeX{} length (skip) ,
215 % printtype = \textit{skip}
216 % ]{LaTeXSkip}{lskip}
217 %
218 %\NewDocElement[macrolike = true ,
219 % toplevel = false,
220 % idxtype = dimen ,
221 % idxgroup = LaTeX length\actualchar \LaTeX{} length (dimen) ,
222 % printtype = \textit{dimen}
223 % ]{LaTeXDimen}{ldimen}
224 %
225 %\NewDocElement[macrolike = false ,
226 % toplevel = false,
227 % idxtype = option ,
228 % idxgroup = Package options ,
229 % printtype = \textit{option}
230 % ]{Option}{option}
231 %
232 % \renewcommand\code[1]{\mbox{$\ell$-#1}}
233 % \renewcommand\main[1]{\underline{\mbox{$\ell$-#1}}}
234 % \setcounter{IndexColumns}{2}
235 %
236 %
237 % \changes{v1.9t}{1995/05/11}{Use \cs{GetFileInfo}}
238 % \GetFileInfo{doc.sty}
239 %
240 % \CheckSum{0}
241 %
242 % \title{The \DOC{} and \texttt{shortvrb} Packages\thanks
243 % {This file has version number \fileversion{} dated \filedate{}.}}
244 % \author{Frank Mittelbach\thanks{Further commentary added at Royal
245 % Military College of Science by B. Hamilton Kelly; English
246 % translation of parts of the original German commentary
247 % provided by Andrew Mills; fairly substantial additions,
248 % particularly from \texttt{newdoc}, and
249 % documentation of post-v1.5q features added at v1.7a by Dave
250 % Love (SERC Daresbury Lab).}~\thanks
251 % {Extraction of \texttt{shortvrb}
252 % package added by Joachim Schrod (TU~Darmstadt).}~\thanks
253 % {Version~3 now integrates code from Didier Verna's
254 % \DOX package and some of his documentation was
255 % reused (a.k.a.\ stolen).}}
256 % \date{Printed \today}
257 %
258 % \MaintainedByLaTeXTeam{latex}
259 %
260 % \maketitle
261 %
262 % \begin{abstract}
263 % Roughly 30 years ago (version 1.0 was dated 1988/05/05) I wrote
264 % the first version of the \DOC package, a package to provide code
265 % documentation for \TeX{} code. Since then it has been used all
266 % over the place to document the \LaTeX{} kernel and most of the
267 % packages that are nowadays available. The core code of version 2
268 % (which is the current version) exists since 1998, i.e., for 20
269 % years.
270 %
271 % If I would restart from scratch I would do a lot of things
272 % differently these days and in fact several other people have
273 % tried to come up with better solutions. However, as the saying
274 % goes, a bad standard is better than none, \DOC has prevailed and
275 % changing it now in incompatible ways is probably not really
276 % helpful.
277 %
278 % So this is version 3 of the package with some smaller extensions
279 % that are upwards compatible but hopefully serve well. Most
280 % important modifications are the integration of the
281 % \pkg{hypdoc} package to enable links within the document (in
282 % particular from the index) if so desired. Also integrated are the
283 % ideas from the \DOX package by Didier Verna (although I
284 % offer a different interface that imho fits better with the rest
285 % of \DOC's interfaces). Finally I updated a few odds and ends.
286 % \end{abstract}
287 %
288 %
289 % \newpage
290 %
291 % \addtocontents{toc}{\protect\begin{multicols}{2}}
292 %
293 % ^^A{\parskip 0pt ^^A We have to reset \parskip
294 % ^^A (bug in \LaTeX)
295 % \tableofcontents
296 % ^^A}
297 %
298 % \changes{v1.7a}{1992/02/25}{Miscellaneous small changes to the text}
299 % \changes{v3.0a}{2018/03/04}{Integrated DoX package}
300 % \changes{v3.0a}{2018/03/04}{Interfaced hypdoc package}
301 %
302 %
303 %
304 % \section{Introduction}
305 %
306 % This is a new version of the \DOC package, written roughly 30 years
307 % after the initial release. As the package has been used for so long
308 % (and largely unchanged)
309 % it is absolutely important to preserve existing interfaces, even if
310 % we can agree that they could have been done better.
311 %
312 % So this is a light-weight change, basically adding hyperlink support
313 % and adding a way to provide generally \DOC elements (not just macros
314 % and environments) and try to do this properly (which wasn't the case
315 % for environments either in the past). The ideas for this have been
316 % stolen from the \DOX package by Didier Verna even though I
317 % didn't keep his interfaces.
318 %
319 % Most of the documentation below is from the earlier release which
320 % accounts for some inconsistencies in presentation, mea culpa.
321 %
322 %
323 % \section{The User Interface}\label{sec:interface}
324 % \subsection{The driver file}
325 %
326 % If one is going to document a set of macros with the \DOC{}
327 % package one has to prepare a special driver file which produces the
328 % formatted document. This driver file has the following
329 % characteristics:
330 % \begin{quote}
331 % \noindent |\documentclass|\oarg{options}^^A
332 % \marg{document-class}\\[1pt]
333 % |\usepackage{doc}|\\[3pt]
334 % \hspace*{10pt}\meta{preamble}\\[3pt]
335 % |\begin{document}|\\[3pt]
336 % \hspace*{10pt}\meta{special input commands}\\[3pt]
337 % |\end{document}|
338 % \end{quote}
339 % The \meta{document-class} might be any document class, I usually
340 % use \texttt{article}.
341 %
342 % In the \meta{preamble} one should place declarations which
343 % manipulate the behavior of the \DOC{} package like
344 % |\DisableCrossrefs| or |\OnlyDescription|.
345 %
346 %
347 % \DescribeInterfaceMacro\DocInput \DescribeInterfaceMacro\IndexInput
348 % Finally
349 % the \meta{special input commands} part should contain one or
350 % more |\DocInput|\marg{file name} and/or
351 % |\IndexInput|\marg{file name} commands. The
352 % |\DocInput| command is used for files prepared for the
353 % \DOC{} package whereas |\IndexInput| can be used for all kinds of
354 % macro files. See page \pageref{..Input} for more details of
355 % |\IndexInput|. Multiple |\DocInput|s can be used with a
356 % number of included files which are each self-contained
357 % self-documenting packages---for instance, each containing
358 % |\maketitle|.
359 %
360 % As an example, the driver file for the \DOC{} package itself is
361 % the following text surrounded by |%<*driver>| and |%</driver>|.
362 % To produce the documentation you can simply run the \texttt{.dtx}
363 % file through \LaTeX{} in which case this code will be executed
364 % (loading the document class \texttt{ltxdoc}, etc.) or you can
365 % extract this into a separate file by using
366 % the \texttt{docstrip} program.
367 % The line numbers below are added by
368 % \DOC{}'s formatting.
369 % Note that the class \cls{ltxdoc} has the \DOC{} package
370 % preloaded.
371 % \changes{v1.7a}{1992/03/06}{Added
372 % docstrip-derivable driver file as example.}
373 % \changes{v1.7c}{1992/04/01}{Expurgated ltugboat.sty from driver.}
374 % \begin{macrocode}
375 %<*driver>
376 \documentclass{ltxdoc}
377
378 \usepackage[T1]{fontenc}
379 \usepackage{xspace}
380
381 \OnlyDescription
382
383 \EnableCrossrefs
384 %\DisableCrossrefs % Say \DisableCrossrefs if index is ready
385 \CodelineIndex
386 \RecordChanges % Gather update information
387 \SetupDoc{reportchangedates}
388 %\OnlyDescription % comment out for implementation details
389 \setlength\hfuzz{15pt} % don't show so many
390 \hbadness=7000 % over- and underfull box warnings
391 \begin{document}
392 \DocInput{doc.dtx}
393 \end{document}
394 %</driver>
395 % \end{macrocode}
396 %
397 % \RecordIndexType{\CodelineIndex}{InterfaceMacro}
398 % \RecordIndexType{\DisableCrossrefs}{InterfaceMacro}
399 % \RecordIndexType{\DocInput}{InterfaceMacro}
400 % \RecordIndexType{\EnableCrossrefs}{InterfaceMacro}
401 % \RecordIndexType{\OnlyDescription}{InterfaceMacro}
402 % \RecordIndexType{\RecordChanges}{InterfaceMacro}
403 % \RecordIndexType{\hbadness}{TeXCounter}
404 % \RecordIndexType{\hfuzz}{LaTeXDimen}
405 %
406 %
407 % \subsection{Package options}
408 %
409 % \NewIn{v3}
410 % Starting with version~3 the \DOC package now offers a small number
411 % of package options to modify its overall behavior. These are:
412 % \DescribeOption[noprint]{multicol}
413 % \DescribeOption[noprint]{nomulticol}
414 % \DescribeOption[noprint]{hyperref}
415 % \DescribeOption[noprint]{nohyperref}
416 % \DescribeOption[noprint]{debugshow}
417 % \DescribeOption[noprint]{noindex}
418 % \DescribeOption[noprint]{noprint}
419 % \DescribeOption[noprint]{reportchangedates}
420 % \begin{description}
421 % \item[\opt{hyperref}, \opt{nohyperref}] Boolean (default \texttt{true}). Load the
422 % \pkg{hyperref} package and make index references to code lines
423 % and pages and other items clickable links. \opt{nohyperref} is
424 % the complementary key.
425 %
426 % \item[\opt{multicol}, \opt{nomulticol}] Boolean (default \texttt{true}). Load the
427 % \pkg{multicol} package for use in typesetting the index and the
428 % list of changes. \opt{nomulticol} is
429 % the complementary key.
430 %
431 % \item[\opt{debugshow}] Boolean (default \texttt{false}). Provide
432 % various tracing information at the terminal and in the transcript
433 % file. In particular show which elements are indexed.
434 %
435 % \item[\opt{noindex}] Boolean (default \texttt{false}). If set, all
436 % automatic indexing is suppressed. This option can also be used on
437 % individual elements as described below.
438 %
439 % \item[\opt{noprint}] Boolean (default \texttt{false}). If set, then
440 % printing of element names in the margin will be suppressed. This
441 % option can also be used on individual elements as described
442 % below.
443 % \item[\opt{reportchangedates}] Boolean (default \texttt{false}). If
444 % set, then change entries list the date after the version number in
445 % the change log.
446 % \end{description}
447 %
448 % \DescribeInterfaceMacro{\SetupDoc} Instead of providing options to the \DOC
449 % package you can call \cs{SetupDoc} and provide them there. This
450 % allows, for example, to change default values in case \DOC was already
451 % loaded earlier.
452 %
453 %
454 %
455 % \subsection{General conventions}
456 %
457 % A \TeX{} file prepared to be used with the `doc' package
458 % consists of `documentation parts' intermixed with `definition
459 % parts'.
460 %
461 % Every line of a `documentation part' starts with a percent sign
462 % (|%|) in column one. It may contain arbitrary \TeX{} or
463 % \LaTeX{} commands except that the character `|%|' cannot be
464 % used as a comment character.
465 % \SortIndex{\string^\string^A}{\string\verb\verbatimchar
466 % \string^\string^A\verbatimchar \encapchar usage}^^A
467 % \SortIndex{\string^\string^X}{\string\verb\verbatimchar
468 % \string^\string^X\verbatimchar \encapchar usage}
469 % To allow user
470 % comments, the characters |^^A| and |^^X| are both defined as a comment character
471 % later on.\footnote{In version 2 it was only
472 % \texttt{\string^\string^A}, but many keyboards combine
473 % \texttt{\string^} and \texttt{A} and automatically turn it into
474 % ``Ä''; so \texttt{\string^\string^X} was added as an
475 % alternative in version 3.}
476 % Such `metacomments' may be also be included simply by
477 % surrounding them with |\iffalse| \ldots~|\fi|.
478 %
479 % All other parts of the file are called `definition parts'. They
480 % contain fractions of the macros described in the `documentation
481 % parts'.
482 %
483 % If the file is used to define new macros (e.g.\ as a package file in
484 % the |\usepackage| macro), the `documentation parts' are
485 % bypassed at high speed and the macro definitions are pasted
486 % together, even if they are split into several `definition parts'.
487 %
488 % \DescribeEnv{macrocode}
489 % On the other hand, if the documentation of these macros is to be
490 % produced, the `definition parts' should be typeset verbatim. To
491 % achieve this, these parts are surrounded by the \env{macrocode}
492 % environment.
493 % More exactly: before a `definition part' there should be a line
494 % containing
495 % \begin{flushleft}
496 % \hspace*{\MacroIndent}\verb*+% \begin{macrocode}+
497 % \end{flushleft}
498 % and after this part a line
499 % \begin{flushleft}
500 % \hspace*{\MacroIndent}\verb*+% \end{macrocode}+
501 % \end{flushleft}
502 % There must be {\em exactly\/} four spaces between the |%|
503 % and |\end{macrocode}| --- \TeX{} is looking for this string
504 % and not for the macro while processing a `definition part'.
505 %
506 % Inside a `definition part' all \TeX{} commands are allowed; even the
507 % percent sign could be used to suppress unwanted spaces etc.
508 %
509 % \DescribeEnv{macrocode*} Instead of the \env{macrocode}
510 % environment one can also use the \env{macrocode$*$} environment
511 % which produces the same results except that spaces are printed as
512 % \nopagebreak\verb*+ + characters.
513 %
514 %
515 %
516 % \subsection{Describing the usage of macros and environments}
517 %
518 % \DescribeInterfaceMacro\DescribeMacro
519 % When you describe a new macro you may use |\DescribeMacro| to
520 % indicate that at this point the usage of a specific macro is
521 % explained. It takes one argument which will be printed in the margin
522 % and also produces a special index entry. For example, I used
523 % |\DescribeMacro{\DescribeMacro}| to make clear that this is the
524 % point where the usage of |\DescribeMacro| is explained.
525 %
526 % As the argument to |\DescribeMacro| is a command name, many people
527 % got used to using the (incorrect) short form, i.e., omitting the
528 % braces around the argument as in |\DescribeMacro\foo|. This does
529 % work as long as the macro name consists only of ``letters''.
530 % However, if the name contains special characters that are normally
531 % not of type ``letter'' (such as |@|, or in case of \pkg{expl3} |_|
532 % and |:|) this will fail dramatically. |\DescribeMacro| would then
533 % receive only a partial command name (up to the first ``non-letter'')
534 % e.g., |\DescribeMacro\foo@bar| would be equivalent to
535 % |\DescribeMacro{\foo} @bar| and you can guess that this can
536 % resulting in both incorrect output and possibly low-level error
537 % messages.
538 %
539 % \DescribeInterfaceMacro\DescribeEnv
540 % An analogous macro |\DescribeEnv| should be used to indicate that a
541 % \LaTeX{} environment is explained. It will produce a somewhat
542 % different index entry and a slightly different display in the
543 % margin. Below I used |\DescribeEnv{verbatim}|.
544 %
545 %
546 % \NewIn{v3}
547 % Starting with version~3 the \cs{Describe...} commands accept an
548 % optional argument in which you can specify either \opt{noindex}
549 % or \opt{noprint} to suppress indexing or printing for that
550 % particular instance. Using both would be possible too, but pointless
551 % as then the commands wouldn't do anything any more.
552 %
553 %
554 % \subsection{Describing the definition of macros and environments}
555 %
556 % \DescribeEnv{macro}
557 % To describe the definition of a (new) macro we use the \env{macro}
558 % environment. It has one argument: the name of the new
559 % macro.\footnote{This is a change to the style design I described in
560 % ^^A \TUB ^^A removed in case ltugboat.sty not used
561 % \textsl{TUGboat\/}\ 10\#1 (Jan.~89). We finally decided
562 % that it would
563 % be better to use the macro name {\em with\/} the
564 % backslash as an argument.}
565 % This argument is also used to print the name in the margin and to
566 % produce an index entry.
567 % Actually the index entries for usage and definition are different to
568 % allow an easy reference.
569 % This environment might be nested. In this case the
570 % labels in the margin are placed under each other.
571 % \changes{v1.7a}{1992/02/26}{Note on need for some text in macro env.}
572 % There should be some text---even if it's just an empty
573 % |\mbox{}|---in this environment before |\begin{macrocode}| or the
574 % marginal label won't print in the right place.
575 %
576 % \NewIn{v3}
577 % In fact it is now allowed to specify several macros in the argument,
578 % separated by commas. This is a short form for starting several
579 % \env{macro} environments in direct succession. Of course, you
580 % should then have also only one matching |\end{macro}|.
581 %
582 % \DescribeLaTeXSkip\MacrocodeTopsep
583 % \DescribeLaTeXSkip\MacroTopsep
584 % There also exist four style parameters: |\MacrocodeTopsep| and
585 % |\MacroTopsep| are used to control the vertical spacing above
586 % and below the \env{macrocode} and the \env{macro}
587 % \DescribeLaTeXDimen\MacroIndent
588 % environment, |\MacroIndent| is used to indent the lines of code
589 % and
590 % \DescribeInterfaceMacro\MacroFont \label{sec:macrofont}
591 % |\MacroFont| holds the font and a possible size change command
592 % for the code lines, the |verbatim|[|*|] environment and the macro
593 % names printed in the margin. If you want
594 % to change their default values in a
595 % class file (like \texttt{ltugboat.cls}) use the |\DocstyleParms|
596 % command described below. Starting with release 2.0a it can now
597 % be changed directly as long as the redefinition happens before
598 % the |\begin{document}| (if you change it later you might see strange
599 % typesetting effects if you are unlucky).
600 %
601 % |\MacroFont| does not alter the font of
602 % |\verb| or |\verb*| because it is often used to make the font size of
603 % the code displays smaller, which would look odd if used within a
604 % paragraph. If you decide to use a different font family and want to
605 % use the same family with
606 % |\verb| you need to alter the font setup for |\ttfamily| in addition
607 % to |\MacroFont|.
608 %
609 % \DescribeEnv{environment}
610 % For documenting the definition of environments one can use the
611 % environment \texttt{environment} which works like the \texttt{macro}
612 % environment, except that it expects an \meta{env-name}
613 % (without a backslash)
614 % as its argument and internally provides different index
615 % entries suitable for environments.
616 % Nowadays you can alternatively specify a comma-separated list of environments.
617 %
618 % \NewIn{v3}
619 % Starting with version~3 these environments accept an optional
620 % argument in which you can specify \opt{noindex} or \opt{noprint} or
621 % both to suppress indexing or printing for that particular
622 % instance. If any such setting is made on the environment level it
623 % overwrites whatever default was given when the \DOC element was
624 % defined or when the package was loaded.
625 %
626 %
627 %
628 %
629 % \subsection{Formatting names in the margin}
630 %
631 % \DescribeInterfaceMacro\PrintDescribeMacro
632 % \DescribeInterfaceMacro\PrintDescribeEnv
633 % \DescribeInterfaceMacro\PrintMacroName
634 % \DescribeInterfaceMacro\PrintEnvName
635 % As mentioned earlier, some macros and environment
636 % print their arguments in the margin. The actual formatting is done by four
637 % macros which are user
638 % definable.\footnote{You may place the changed definitions in a
639 % separate package
640 % file or at the beginning of the documentation
641 % file.
642 % For example, if you don't like any names in the
643 % margin
644 % but want a fine index you can simply redefine them
645 % accept their argument and do nothing with it.}
646 % They are named |\PrintDescribeMacro| and |\PrintDescribeEnv| (defining
647 % how |\DescribeMacro| and |\DescribeEnv| behave) and
648 % |\PrintMacroName| and
649 % |\PrintEnvName| (called by the \env{macro} and \env{environment}
650 % environments, respectively).
651 %
652 %
653 % \subsection{Providing further documentation items}
654 %
655 % Out of the box the \DOC package offers the above commands and
656 % environments to document macros and environments.
657 % \NewIn{v3}
658 % With version 3
659 % this has now been extended in a generic fashion so that you can
660 % easily provide your own items, such as counters, length register,
661 % options etc.
662 %
663 % \DescribeInterfaceMacro{\NewDocElement}
664 % The general syntax for providing a new \DOC element is
665 % \begin{quote}
666 % \cs{NewDocElement}\oarg{options}\marg{element-name}\marg{env-name}
667 % \end{quote}
668 % By convention the \meta{element-name} has the first letter
669 % uppercased as in \texttt{Env} or \texttt{Macro}.
670 %
671 % Such a declaration will define for you
672 % \begin{itemize}
673 % \item the command |\Describe|\meta{element-name} which has the
674 % syntax
675 % \begin{quote}
676 % |\Describe|\meta{element-name}\oarg{options}\marg{element}
677 % \end{quote}
678 %
679 % \item the environment \meta{env-name} which has the syntax
680 % \begin{quote}
681 % \cs{begin}\marg{env-name}\oarg{options}\marg{element}
682 % \end{quote}
683 %
684 % \item the display command |\PrintDescribe|\meta{element-name} with
685 % the syntax
686 % \begin{quote}
687 % |\PrintDescribe|\meta{element-name}\marg{element}
688 % \end{quote}
689 %
690 % \item and the
691 % |\Print|\meta{element-name}|Name| display command for the
692 % environment.
693 % \end{itemize}
694 % If any of the commands or the environment is already defined (which
695 % especially with the \meta{env-name} is a danger) then you will
696 % receive an error telling you so.
697 %
698 % \DescribeInterfaceMacro{\RenewDocElement}
699 % If you want to modify an existing \DOC element use
700 % |\RenewDocElement| instead.
701 %
702 % For example, the already provided ``\texttt{Env}'' \DOC element could have been
703 % defined simply by making the declaration
704 % |\NewDocElement{Env}{environment}|
705 % though that's not quite what has been done, as we will see later.
706 %
707 % \DescribeInterfaceMacro{\ProvideDocElement}
708 % This declaration does nothing when the doc element is already
709 % declared, otherwise it works like \cs{NewDocElement}. It can be
710 % useful if you have many documentation files that you may want to
711 % process individually as well as together.
712 %
713 % \DescribeOption[noprint]{macrolike}
714 % \DescribeOption[noprint]{envlike}
715 % \DescribeOption[noprint]{toplevel}
716 % \DescribeOption[noprint]{notoplevel}
717 % \DescribeOption[noprint]{idxtype}
718 % \DescribeOption[noprint]{printtype}
719 % \DescribeOption[noprint]{idxgroup}
720 % The \meta{options} are keyword/value and define further details on
721 % how that \DOC element should behave. They are:
722 % \begin{description}
723 % \item[\opt{macrolike}] Boolean (default \opt{false}). Does this \DOC
724 % element starts with a backslash?
725 %
726 % \item[\opt{envlike}] Boolean. Complementary option to
727 % \opt{macrolike}.
728 %
729 % \item[\opt{toplevel}] Boolean (default \opt{true}). Should all
730 % a top-level index entry be made? If set to \texttt{false} then
731 % either no index entries are produced or only grouped index entries
732 % (see \opt{idxgroup} for details).
733 %
734 % \item[\opt{notoplevel}] Boolean. Complementary option to
735 % \opt{toplevel}.
736 %
737 % \item[\opt{idxtype}] String (default \meta{env-name}). What to put
738 % (in parentheses if non-empty) at the end of a top-level index entry.
739 %
740 % \item[\opt{printtype}] String (default \meta{env-name}). What to put
741 % (in parentheses if non-empty) after an element name in the margin.
742 %
743 % \item[\opt{idxgroup}] String (default
744 % \meta{env-name}\texttt{s}). Name of the top-level index entry if
745 % entries are grouped. They are only grouped if this option is
746 % non-empty.
747 %
748 % \item[\opt{noindex}] Boolean (default \texttt{false}). If set this
749 % will suppress indexing for elements of this type. This setting
750 % overwrite any global setting of \opt{noindex}.
751 %
752 % \item[\opt{noprint}] Boolean (default \texttt{false}). If set this
753 % will suppress printing the element name in the margin. This setting
754 % overwrite any global setting of \opt{noprint}.
755 % \end{description}
756 % As usual giving a boolean option without a value sets it to
757 % \texttt{true}.
758
759
760
761
762 % \subsection{Displaying sample code verbatim}
763 %
764 % \DescribeEnv{verbatim}
765 % It is often a good idea to include examples of the usage of new macros
766 % in the text. Because of the |%| sign in the first column of every
767 % row, the \env{verbatim} environment is slightly altered to suppress
768 % those
769 % characters.\footnote{These macros were written by Rainer
770 % Schöpf~\cite{art:verbatim}. He also
771 % provided a new \env{verbatim} environment
772 % which can be used inside of other macros.}
773 % \DescribeEnv{verbatim*}
774 % The \env{verbatim$*$} environment is changed in the same way.
775 % \changes{v1.7a}{1992/02/26}{Documented \cs{verb} change.}
776 % \DescribeInterfaceMacro\verb
777 % The |\verb| command is re-implemented to give an error report if a
778 % newline appears in its argument.
779 % The \env{verbatim} and \env{verbatim$*$} environments set text
780 % in the style defined by |\MacroFont|~(\S\ref{sec:macrofont}).
781 %
782 %
783
784 % \subsection{Using a special escape character}
785 %
786 % \DescribeInterfaceMacro\SpecialEscapechar
787 % If one defines complicated macros it is sometimes necessary to
788 % introduce a new escape character because the `|\|' has got a
789 % special |\catcode|. In this case one can use
790 % |\SpecialEscapechar| to indicate which character is actually
791 % used to play the r\^ole of the `|\|'. A scheme like this is
792 % needed because the \env{macrocode} environment and its counterpart
793 % \env{macrocode$*$} produce an index entry for every occurrence of a
794 % macro name. They would be very confused if you didn't tell them that
795 % you'd changed |\catcode|$\,$s. The argument to
796 % |\SpecialEscapechar| is a single-letter control sequence, that
797 % is, one has to use \verb=\|= for example to denote that `\verb+|+'
798 % is used as an escape character. |\SpecialEscapechar| only
799 % changes the behavior of the next \env{macrocode} or
800 % \env{macrocode$*$} environment.
801 %
802 % The actual index entries created will all be printed with |\|
803 % rather than \verb+|+, but this probably reflects their usage, if not
804 % their definition, and anyway must be preferable to not having any
805 % entry at all. The entries {\em could\/} be formatted appropriately,
806 % but the effort is hardly worth it, and the resulting index might be
807 % more confusing (it would certainly be longer!).
808 %
809 %
810 % \subsection{Cross-referencing all macros used}
811 %
812 % \DescribeInterfaceMacro\DisableCrossrefs \DescribeInterfaceMacro\EnableCrossrefs As
813 % already mentioned, every macro name used within a
814 % \env{macrocode} or \env{macrocode$*$} environment will produce an
815 % index entry. In this way one can easily find out where a specific
816 % macro is used. Since \TeX{} is considerably slower\footnote{This
817 % comment was written about 30 years ago. \TeX{} is still considerably
818 % slower but while it took minutes to process a large document (such
819 % as the \LaTeX{} kernel documentation) it takes seconds or less these
820 % days. Thus \cs{DisableCrossrefs} isn't really that necessary these
821 % days.} when it has to produce such a bulk of index entries one can
822 % turn off this feature by using |\DisableCrossrefs| in the driver
823 % file. To turn it on again just use
824 % |\EnableCrossrefs|.\footnote{Actually, \cs{EnableCrossrefs} changes
825 % things more drastically; any following call to \cs{DisableCrossrefs}
826 % which might be present in the source will be ignored.}
827 %
828 %
829 % \DescribeInterfaceMacro\DoNotIndex
830 % But also finer control is provided. The |\DoNotIndex| macro
831 % takes a list of macro names separated by commas. Those names won't
832 % show up in the index. You might use several |\DoNotIndex|
833 % commands: their lists will be concatenated. In this article I used
834 % |\DoNotIndex| for
835 % all macros which are already defined in \LaTeX.
836 %
837 % All three above declarations are local to the current group.
838 %
839 % Production (or not) of the index (via the |\makeindex| command) is
840 % controlled by using or omitting the following declarations in the
841 % driver file preamble; if neither is used, no index is produced.
842 % \DescribeInterfaceMacro\PageIndex Using |\PageIndex| makes all index
843 % entries refer to their page number; with
844 % \DescribeInterfaceMacro\CodelineIndex |\CodelineIndex|, index entries
845 % produced by |\DescribeMacro| and |\DescribeEnv| and possibly further
846 % |\Describe...| commands refer to a page number
847 % but those produced by the \env{macro} environment (or other \DOC
848 % element environments) refer to the
849 % code lines, which will be numbered automatically.\footnote{The line
850 % number is actually that of the first line of the first
851 % \env{macrocode} environment in the \env{macro} environment.}
852 % \DescribeInterfaceMacro\theCodelineNo
853 % The style of this numbering can be controlled by defining the macro
854 % |\theCodelineNo|. Its default definition is to use scriptsize
855 % arabic numerals; a user-supplied definition won't be overwritten.
856 %
857 % \DescribeInterfaceMacro\CodelineNumbered
858 % When you don't wish to get an index but want your code lines
859 % numbered use |\CodelineNumbered| instead of |\CodelineIndex|. This
860 % prevents the generation of an unnecessary |.idx| file.
861 %
862 %
863 % \subsection{Producing the actual index entries}
864 %
865 % Several of the aforementioned macros will produce some sort of index
866 % entries. These entries have to be sorted by an external
867 % program---the current implementation assumes that the
868 % \prg{makeindex} program by Chen~\cite{art:Chen} is used.
869 %
870 % But this isn't built in: one has only to redefine some of the
871 % following macros to be able to use any other index program. All
872 % macros which are installation
873 % dependent are defined in such a way that they won't overwrite a
874 % previous definition. Therefore it is safe to put the changed
875 % versions in a package file which might be read in before the doc
876 % package.
877 %
878 % To allow the user to change the specific characters recognized by
879 % his or her index program all characters which have special meaning
880 % in the \prg{makeindex} program are given symbolic
881 % names.\footnote{I don't know if there exists a program which needs
882 % more command characters, but I hope not.}
883 % However, all characters used should be of |\catcode| other than
884 % `letter' (11).
885 %
886 % \DescribeInterfaceMacro{\actualchar}
887 % The |\actualchar| is used to separate the `key' and the actual
888 % index entry.
889 % \DescribeInterfaceMacro{\quotechar}
890 % The |\quotechar| is used before a special index program
891 % character to suppress its special meaning.
892 % \DescribeInterfaceMacro{\encapchar}
893 % The |\encapchar| separates the indexing information from a
894 % letter string which \prg{makeindex} uses as a \TeX{} command to
895 % format the page number associated with a special entry. It is used
896 % in this package to apply the |\main| and the |\usage|
897 % commands.
898 % \DescribeInterfaceMacro{\levelchar}
899 % Additionally |\levelchar| is used to separate `item',
900 % `subitem' and `subsubitem' entries.
901 %
902 % It is a good idea to stick to these symbolic names even if you know
903 % which index program is used. In this way your files will be
904 % portable.
905 %
906 % \fmi{describe old \cs{SpecialMainIndex} and \cs{SpecialUsageIndex}}
907 %
908 % \DescribeInterfaceMacro\SpecialMainMacroIndex
909 % \DescribeInterfaceMacro\SpecialMainEnvIndex
910 % To produce a main index entry for a macro the
911 % |\SpecialMainMacroIndex| macro\footnote{This macro is called by the
912 % \env{macro} environment.} may be used. It is called `special'
913 % because it has to print its argument verbatim.
914 % A similar macro, called |\SpecialMainEnvIndex| is used for indexing
915 % the main definition point of an
916 % environment.\footnote{This macro is called by the
917 % \env{environment} environment.}
918 %
919 % \DescribeInterfaceMacro\SpecialMacroIndex
920 % \DescribeInterfaceMacro\SpecialEnvIndex
921 % To index the usage of a macro or an environment
922 % |\SpecialMacroIndex| and |\SpecialEnvIndex| may be used.
923 %
924 % All these macros are normally used by other macros; you will need
925 % them only in an emergency.
926 %
927 % \NewIn{v3}
928 % If further code elements are declared with
929 % |\NewDocElement|\marg{name}\texttt{...} then this sets up
930 % additional indexing commands, e.g.,
931 % \cs{SpecialMain\meta{name}Index}.
932 %
933 % \DescribeInterfaceMacro\SpecialIndex
934 % The \env{macrocode} environment is automatically indexing macros
935 % (normally by code line number). You can (with care) also do this
936 % manually by
937 % |\SpecialIndex|. However, note that if |\CodelineIndex| is used
938 % this will generate an entry referring to the last code line which is
939 % usually not what you want. It does, however, make some sense if you
940 % always refer to pages only, i.e., if you use |\PageIndex|.
941 %
942 % \DescribeInterfaceMacro\SpecialShortIndex
943 % \NewIn{v3}
944 % For single character macros, e.g., |\{|, doesn't always work
945 % correctly.
946 % For this reason there is now also
947 % a special variant the can produce correct index entries for them.
948 %
949 % \DescribeInterfaceMacro\SortIndex
950 % Additionally a |\SortIndex| command is provided. It takes two
951 % arguments---the sort key and the actual index entry.
952 %
953 % \DescribeInterfaceMacro\verbatimchar
954 % But there is one characteristic worth mentioning: all macro names in
955 % the index are typeset with the |\verb*| command. Therefore one
956 % special character is needed to act as a delimiter for this command.
957 % To allow a change in this respect, again this character is
958 % referenced indirectly, by the macro |\verbatimchar|. It expands
959 % by default to \verb?+? but if your code lines contain macros with
960 % `\texttt{+}' characters in their names (e.g.\ when you use \verb?\+?)
961 % then that caused a problem because you ended up with an
962 % index entry containing \verb?\verb+\++?
963 % which will be typeset as `\verb+\++' and not as `\verb?\+?'.
964 % \NewIn{v3}
965 % In version 3 this is now automatically taken care of (with the help
966 % of the |\SpecialShortIndex| command).
967 %
968 % \DescribeInterfaceMacro\*
969 % We also provide a |\*| macro. This is intended to be used for
970 % index entries like
971 % \begin{quote}
972 % index entries \\
973 % \hspace*{30pt} Special macros for \*
974 % \end{quote}
975 % Such an entry might be produced with the line
976 %\begin{verbatim}
977 % \index{index entries>Special macros for \*}
978 %\end{verbatim}
979 % assuming that \verb=>= is the \cs{levelchar} used by the index
980 % processor.
981
982 % You can't use \cs{levelchar} in this situation because if \cs{index}
983 % is directly used in the document then it's argument is written out
984 % fully verbatim. However, if you define your own index commands,
985 % expansion will happen on the way to the \texttt{.idx} file; and in
986 % that case you can use \cs{levelchar}---this is what the \pkg{doc}
987 % macros do. This then allows to change the indexing syntax easily, e.g.,
988 %\begin{verbatim}
989 % \newcommand\ltxconcept[2]{\index{#1\levelchar#2}}
990 % ...
991 % \ltxconcept{index entries}{Special macros for \*}
992 %\end{verbatim}
993 %
994 %
995 % \subsection{Setting the index entries}
996 %
997 % \changes{v1.7a}{1992/03/11}{Usage note on gind.ist.} After the first
998 % formatting pass through the \texttt{.dtx} file you need to sort the
999 % index entries written to the \texttt{.idx} file using
1000 % \prg{makeindex} or your favorite alternative. You need a
1001 % suitable style file for \prg{makeindex} (specified by the
1002 % \texttt{-s} switch). A suitable one is supplied with \DOC{},
1003 % called \texttt{gind.ist}.
1004 %
1005 % \DescribeInterfaceMacro\PrintIndex
1006 % To read in and print the sorted index, just put the
1007 % |\PrintIndex| command as the last (commented-out, and thus
1008 % executed during the documentation pass through the file) command
1009 % in your package file. Precede it by any bibliography commands
1010 % necessary for your citations.
1011 % Alternatively, it may be more convenient to put all such calls
1012 % amongst the arguments of the |\MaybeStop| macro, in
1013 % which case a |\Finale| command should appear at the end of
1014 % your file.
1015 %
1016 % \DescribeEnv{theindex}
1017 % Contrary to standard \LaTeX, the index is typeset in three columns
1018 % by default.
1019 % \DescribeLaTeXCounter{IndexColumns}
1020 % This is controlled by the \LaTeX{} counter
1021 % `\textsf{IndexColumns}' and can therefore be changed with a
1022 % |\setcounter| declaration. Additionally one doesn't want to
1023 % start a new page unnecessarily. Therefore the \env{theindex}
1024 % environment is redefined.
1025 % \DescribeLaTeXDimen\IndexMin
1026 % When the \env{theindex} environment starts it will measure how much
1027 % space is left on the current page. If this is more than
1028 % |\IndexMin| then the index will start on this page. Otherwise
1029 % |\newpage| is called.
1030 %
1031 % Then a short introduction about the meaning of several index entries
1032 % is typeset (still in onecolumn mode). Afterwards the actual index
1033 % entries follow in multi-column mode.
1034 % \DescribeInterfaceMacro\IndexPrologue
1035 % You can change this prologue with the help of the
1036 % |\IndexPrologue| macro. Actually the section heading is also
1037 % produced in this way, so you'd better write something like:
1038 % \begin{verbatim}
1039 % \IndexPrologue{\section*{Index} The index entries underlined ...}
1040 %\end{verbatim}
1041 % When the \env{theindex} environment is finished the last page will
1042 % be reformatted to produce balanced columns. This improves the layout
1043 % and allows the next article to start on the same page.
1044 % \DescribeInterfaceMacro\IndexParms
1045 % Formatting of the index columns (values for |\columnssep|
1046 % etc.)\ is controlled by the |\IndexParms| macro. It assigns the
1047 % following values:
1048 % \SpecialLaTeXDimenIndex{\parindent}\SpecialLaTeXDimenIndex{\columnsep}^^A
1049 % \SpecialLaTeXSkipIndex{\parskip}\SpecialLaTeXSkipIndex{\rightskip}^^A
1050 % \SpecialLaTeXDimenIndex{\mathsurround}\SpecialLaTeXSkipIndex{\parfillskip}
1051 % \begin{center}
1052 % \begin{tabular}{l@{\,=\,}ll@{\,=\,}l}
1053 % |\parindent| & \IndexParms \the\parindent &
1054 % |\columnsep| & \IndexParms \the\columnsep \\
1055 % |\parskip| & \IndexParms \the\parskip &
1056 % |\rightskip| & \IndexParms
1057 % \expandafter\dimenvalue\the\rightskip \\
1058 % |\mathsurround| & \IndexParms \the\mathsurround &
1059 % |\parfillskip| & \IndexParms
1060 % \expandafter\dimenvalue\the\parfillskip
1061 % \end{tabular}
1062 % \end{center}
1063 % \DescribeInterfaceMacro{\@idxitem}
1064 % Additionally it defines |\@idxitem| (which will be used when an
1065 % |\item| command is encountered) and selects |\small| size.
1066 % If you want to change any of these values you have to define them
1067 % all.
1068 %
1069 % \DescribeInterfaceMacro\main
1070 % \DescribeInterfaceMacro\usage
1071 % \DescribeInterfaceMacro\code
1072 % The page numbers for main index entries are encapsulated by the
1073 % |\main| macro (underlining its argument) and the numbers
1074 % denoting the description are encapsulated by the |\usage| macro
1075 % (which produces \textit{italics}). |\code| encapsulates page or code
1076 % line numbers in entries generated by parsing the code inside
1077 % \env{macrocode} environments. As usual these commands are user
1078 % definable.
1079 %
1080 %
1081 % \subsection{Changing the default values of style parameters}
1082 %
1083 % \DescribeInterfaceMacro\DocstyleParms If you want to overwrite some default
1084 % settings made by the \DOC{} package, you can either put your
1085 % declarations in the driver file (that is after \texttt{doc.sty} is
1086 % read in) or use a separate package file for doing this work. In the
1087 % latter case you can define the macro |\DocstyleParms| to contain all
1088 % assignments. This indirect approach is necessary if your package file
1089 % might be read before the \texttt{doc.sty}, when some of the
1090 % registers are not allocated. Its default definition is null.
1091 %
1092 % The doc package currently assigns values to the following
1093 % registers:
1094 % \SpecialLaTeXDimenIndex{\IndexMin}^^A
1095 % \SpecialLaTeXSkipIndex{\MacrocodeTopsep}^^A
1096 % \SpecialLaTeXSkipIndex{\MacroTopsep}^^A
1097 % \SpecialLaTeXDimenIndex{\MacroIndent}^^A
1098 % \SpecialLaTeXDimenIndex{\marginparpush}^^A
1099 % \SpecialLaTeXDimenIndex{\marginparwidth}^^A
1100 % \SpecialTeXCounterIndex{\tolerance}
1101 % \begin{center}
1102 % \begin{tabular}{l@{\,=\,}ll@{\,=\,}l}
1103 % |\IndexMin| & \the\IndexMin &
1104 % |\MacroTopsep| & \the\MacroTopsep \\
1105 % |\marginparwidth|& \the\marginparwidth &
1106 % |\MacroIndent| & \the\MacroIndent \\
1107 % |\marginparpush| & \the\marginparpush &
1108 % |\MacrocodeTopsep| & \the\MacrocodeTopsep \\
1109 % |\tolerance| & \the\tolerance
1110 % \end{tabular}
1111 % \end{center}
1112 %
1113 %
1114 % \subsection{Short input of verbatim text pieces}
1115 %
1116 % \DescribeInterfaceMacro\MakeShortVerb
1117 % \DescribeInterfaceMacro{\MakeShortVerb*} \DescribeInterfaceMacro\DeleteShortVerb It is
1118 % awkward to have to type, say, \verb"\verb|"\ldots\verb"|" continually when
1119 % quoting
1120 % verbatim bits (like macro names) in the text, so an abbreviation
1121 % mechanism is provided. Pick a character \meta{c}---one which
1122 % normally has catcode `other' unless you have very good reason not
1123 % to---which you don't envisage using in the text, or not using often.
1124 % (I like |"|, but you may prefer \verb"|" if you have |"| active to do
1125 % umlauts, for instance.) Then if you say
1126 % |\MakeShortVerb{\|\meta{c}|}| you can subsequently use
1127 % \meta{c}\meta{text}\meta{c} as the equivalent of
1128 % |\verb|\meta{c}\meta{text}\meta{c}; analogously, the |*|-form
1129 % |\MakeShortVerb*{\|\meta{c}|}| gives you the equivalent of
1130 % |\verb*|\meta{c}\meta{text}\meta{c}. Use
1131 % |\DeleteShortVerb{\|\meta{c}|}| if you subsequently want \meta{c} to
1132 % revert to its previous meaning---you can always turn it on again
1133 % after the unusual section. The `short verb' commands make global
1134 % changes. The abbreviated |\verb| may not appear in the argument of
1135 % another command just like |\verb|. However the `short verb'
1136 % character may be used freely in the \env{verbatim} and
1137 % \env{macrocode} environments without ill effect.
1138 % |\DeleteShortVerb| is silently ignored if its argument does not
1139 % currently represent a short verb character. Both commands type a
1140 % message to tell you the meaning of the character is being changed.
1141 %
1142 % Please remember that the command |\verb| cannot be used in arguments
1143 % of other commands. Therefore abbreviation characters for |\verb|
1144 % cannot be used there either.
1145 %
1146 % This feature is also available as a sole package, \texttt{shortvrb}.
1147 %
1148 %
1149 % \subsection{Additional bells and whistles}
1150 %
1151 % We provide macros for logos such as \Web, \AmSTeX, \BibTeX,
1152 % \SliTeX{} and \PlainTeX. Just type |\Web|, |\AmSTeX|,
1153 % |\BibTeX|, |\SliTeX| or |\PlainTeX|, respectively.
1154 % \LaTeX{} and \TeX{} are already defined in \texttt{latex.tex}.
1155 %
1156 % \DescribeInterfaceMacro\meta
1157 % Another useful macro is |\meta| which has one argument and
1158 % produces something like \meta{dimen parameter}.
1159 %
1160 % \DescribeInterfaceMacro\OnlyDescription
1161 % \DescribeInterfaceMacro\MaybeStop
1162 % \DescribeObsoleteInterfaceMacro\StopEventually
1163 % You can use the |\OnlyDescription| declaration in the driver
1164 % file to suppress the last part of your document (which presumably
1165 % exhibits the code). To make this work
1166 % \NewIn{v3}
1167 % you have to place the command |\MaybeStop| at a suitable
1168 % point in your file. This macro\footnote{For about 30 years this
1169 % macro was called \cs{StopEventually} which was due to a ``false
1170 % friend'' misunderstanding. In the German language the word
1171 % ``eventuell'' mean roughly ``perhaps'' which isn't quite the same
1172 % as ``eventually''. But given that this is now used for so long
1173 % and all over the place we can't drop the old name. So it is still
1174 % there to allow processing all the existing documentation.}
1175 % has one argument in which you put
1176 % all information you want to see printed if your document ends at
1177 % this point (for example a bibliography which is normally printed at
1178 % the very end). When the |\OnlyDescription| declaration is
1179 % missing the |\MaybeStop|
1180 % \DescribeInterfaceMacro\Finale
1181 % macro saves its argument in a macro called |\Finale| which can
1182 % afterwards be used to get things back (usually at the very end).
1183 % Such a scheme makes changes in two places unnecessary.
1184 %
1185 % Thus you can use this feature to produce a local guide for the
1186 % \TeX{} users which describes only the usage of macros (most of them
1187 % won't be interested in your definitions anyway). For the same
1188 % reason the |\maketitle| \DescribeInterfaceMacro\maketitle command is slightly
1189 % changed to allow multiple titles in one document. So you can make
1190 % one driver file reading in several articles at once.
1191 % \DescribeInterfaceMacro{\ps@titlepage} To avoid an unwanted
1192 % \textsf{pagestyle} on the title page the |\maketitle| command issues
1193 % a |\thispagestyle{titlepage}| declaration which produces a
1194 % \textsf{plain} page if the \textsf{titlepage} page style is
1195 % undefined. This allows class files like \cls{ltugboat.cls} to
1196 % define their own page styles for title pages.
1197 %
1198 % \DescribeInterfaceMacro\AlsoImplementation
1199 % Typesetting the whole document is the default. However, this default
1200 % can also be explicitly selected using the declaration
1201 % |\AlsoImplementation|. This overwrites any previous
1202 % |\OnlyDescription| declaration. The \LaTeXe{} distribution, for
1203 % example, is documented using the \texttt{ltxdoc} class which allows
1204 % for a configuration file \texttt{ltxdoc.cfg}. In such a file one
1205 % could then add the statement
1206 % \begin{quote}
1207 % |\AtBeginDocument{\AlsoImplementation}|
1208 % \end{quote}
1209 % to make sure that all documents will show the code part.
1210 %
1211 % \DescribeInterfaceMacro\IndexInput \label{..Input} Last but not least I
1212 % defined an |\IndexInput| macro which takes a file name as an
1213 % argument and produces a verbatim listing of the file, indexing every
1214 % command as it goes along. This might be handy, if you want to learn
1215 % something about macros without enough documentation. I used this
1216 % feature to cross-reference \texttt{latex.tex} getting a verbatim
1217 % copy with about 15 pages index.\footnote{It took quite a long time
1218 % and the resulting \texttt{.idx} file was longer than the
1219 % \texttt{.dvi} file. Actually too long to be handled by the
1220 % \prg{makeindex} program directly (on our MicroVAX) but the final
1221 % result was worth the trouble.}
1222 %
1223 % \changes{v2.1d}{2006/02/02}{Corrected description of \cs{changes}
1224 % macro.}
1225 % \DescribeInterfaceMacro\changes
1226 % To maintain a change history within the file, the |\changes|
1227 % command may be placed amongst the description part of the changed
1228 % code. It takes three arguments, thus:
1229 % \begin{quote}
1230 % |\changes{|\meta{version}|}{|\meta{date}|}{|^^A
1231 % \meta{text}|}|
1232 % \end{quote}
1233 % The changes may be used to produce an auxiliary file (\LaTeX's
1234 % |\glossary| mechanism is used for this) which may be printed
1235 % after suitable formatting. The |\changes| macro generates the
1236 % printed entry in such a change history; because old
1237 % versions\footnote{Before 2.6.} of the \prg{makeindex}
1238 % program limit such fields to 64 characters, care should be taken
1239 % not to exceed this limit when describing the change. The actual
1240 % entry consists of the \meta{version}, the |\actualchar|, the current
1241 % macro name, a colon, the |\levelchar|, and, finally, the \meta{text}.
1242 % The result is a glossary entry for the \meta{version}, with the name of
1243 % the current macro as subitem. Outside the |macro| environment, the
1244 % text |\generalname| is used instead of the macro name. When
1245 % referring to macros in change descriptions it is conventional to use
1246 % |\cs{|\meta{macroname}|}| rather than attempting to format it properly
1247 % and using up valuable characters in the entry with old \prg{makeindex}
1248 % versions.
1249 %
1250 % Note that in the history listing, the entry is shown with the page number
1251 % that corresponds to its place in the source, e.g., general changes put at the
1252 % very beginning of the file will show up with page number ``1'', change entries
1253 % placed elsewhere might have different numbers (not necessarily always
1254 % very useful unless you are careful).
1255 %
1256 %
1257 % \changes{v1.7a}{1992/02/26}{Description of \cs{RecordChanges} etc.
1258 % added
1259 % to interface section.} \DescribeInterfaceMacro\RecordChanges To cause the
1260 % change information to be written out, include |\RecordChanges| in
1261 % the driver file. \DescribeInterfaceMacro\PrintChanges To read in and print
1262 % the sorted change history (in two columns), just put the
1263 % |\PrintChanges| command as the last (commented-out, and thus
1264 % executed during the documentation pass through the file) command in
1265 % your package file. Alternatively, this command may form one of the
1266 % arguments of the |\MaybeStop| command, although a change
1267 % history is probably {\em not\/} required if only the description is
1268 % being printed. The command assumes that \prg{makeindex} or some
1269 % other program has processed the \texttt{.glo} file to generate a
1270 % sorted \texttt{.gls} file. You need a special \prg{makeindex}
1271 % style file; a suitable one is supplied with \DOC{}, called
1272 % \texttt{gglo.ist}.
1273 %
1274 % \DescribeLaTeXDimen\GlossaryMin
1275 % \DescribeInterfaceMacro\GlossaryPrologue
1276 % \DescribeInterfaceMacro\GlossaryParms
1277 % \DescribeLaTeXCounter{GlossaryColumns}
1278 % The
1279 % |\GlossaryMin|, |\GlossaryPrologue| and |\GlossaryParms| macros and
1280 % the counter \texttt{GlossaryColumns} are
1281 % analogous to the |\Index|\ldots\ versions. (The \LaTeX{} `glossary'
1282 % mechanism is used for the change entries.)
1283 %
1284 %
1285 % \DescribeInterfaceMacro\bslash
1286 % From time to time, it is necessary to print a |\| without
1287 % being able to use the |\verb| command because the
1288 % |\catcode|$\,$s of the symbols are already firmly
1289 % established. In this instance we can use the command
1290 % |\bslash| presupposing, of course, that the actual font in
1291 % use at this point contains a `backslash' as a symbol. Note that
1292 % this definition of |\bslash| is expandable; it inserts a
1293 % $|\|_{12}$. This means that you have to |\protect|
1294 % it if it is used in `moving arguments'.
1295 %
1296 % \DescribeInterfaceMacro\MakePrivateLetters
1297 % \changes{v1.7a}{1992/02/26}{Documented \cs{MakePrivateLetters} in
1298 % interface section}^^A
1299 % If your macros |\catcode| anything other than |@| to `letter', you
1300 % should redefine |\MakePrivateLetters| so that it also makes the
1301 % relevant characters `letters' for the benefit of the indexing. The
1302 % default definition is just |\makeatletter|.
1303 %
1304 % \DescribeInterfaceMacro\DontCheckModules \DescribeInterfaceMacro\CheckModules
1305 % \DescribeInterfaceMacro\Module \DescribeInterfaceMacro\AltMacroFont The `module'
1306 % directives of the \prg{docstrip} system \cite{art:docstrip} are
1307 % normally recognized and invoke special formatting. This can be
1308 % turned on and off in the \texttt{.dtx} file or the driver file using
1309 % |\CheckModules| and |\DontCheckModules|. If checking for module
1310 % directives is on (the default) then code in the scope of the
1311 % directives is set as determined by the hook |\AltMacroFont|, which
1312 % gives {\small\ttfamily\itshape small italic type\-writer\/} by
1313 % default in the New Font Selection Scheme but just ordinary
1314 % {\small\ttfamily small type\-writer} in the old one, where a font
1315 % such as italic typewriter can't be used portably (plug for NFSS);
1316 % you will need to override this if you don't have the italic
1317 % typewriter font available. Code is in such a scope if it's on a
1318 % line beginning with |%<| or is between lines starting with
1319 % |%<*|\meta{name list}|>| and |%</|\meta{name list}|>|. The
1320 % directive is formatted by the macro |\Module| whose single argument
1321 % is the text of the directive between, but not including, the angle
1322 % brackets; this macro may be re-defined in the driver or package file
1323 % and by default produces results like \Module{+foo\string|bar} with no
1324 % following space.
1325 %
1326 % \DescribeLaTeXCounter{StandardModuleDepth} Sometimes (as in this file) the
1327 % whole code is surrounded by modules to produce several files from a
1328 % single source. In this case it is clearly not appropriate to format
1329 % all code lines in a special |\AltMacroFont|. For this reason a
1330 % counter |StandardModuleDepth| is provided which defines the level of
1331 % module nesting which is still supposed to be formatted in
1332 % |\MacroFont| rather then |\AltMacroFont|. The default setting is
1333 % |0|, for this documentation it was set to
1334 %\begin{verbatim}
1335 % \setcounter{StandardModuleDepth}{1}
1336 %\end{verbatim}
1337 % at the beginning of the file.
1338 %
1339 %
1340 % \section{Examples and basic usage summary}
1341 %
1342 % \subsection{Basic usage summary}
1343 % \changes{v1.7a}{1992/03/11}{Added basic usage summary to spell
1344 % it out.}
1345 %
1346 % To sum up, the basic structure of a \texttt{.dtx} file without any
1347 % refinements is like this:
1348 % \begin{verse}\small
1349 % |% |\meta{waffle}\ldots\\
1350 % \quad\ldots \\
1351 % |% \DescribeMacro{\fred}|\\
1352 % |% |\meta{description of fred's use}\\
1353 % \quad\ldots\\
1354 % |% \MaybeStop{|\meta{finale code}|}|\\
1355 % \quad\ldots\\
1356 % |% \begin{macro}{\fred}|\\
1357 % |% |\meta{commentary on macro fred}\\
1358 % \verb*+% \begin{macrocode}+\\
1359 % \meta{code for macro fred}\\
1360 % \verb*+% \end{macrocode}+\\
1361 % |% \end{macro}|\\
1362 % \quad\ldots\\
1363 % |% \Finale \PrintIndex \PrintChanges|
1364 % \end{verse}
1365 % For further examples of the use of most---if not all---of the features
1366 % described above, consult the \texttt{doc.dtx} source itself.
1367 %
1368 %
1369 %
1370 % \subsection{Examples}
1371 %
1372 % The default setup includes definitions for the \DOC elements
1373 % ``macro'' and ``environment''. They correspond to the following
1374 % declarations:
1375 %\begin{verbatim}
1376 % \NewDocElement[macrolike = true ,
1377 % idxtype = ,
1378 % idxgroup = ,
1379 % printtype =
1380 % ]{Macro}{macro}
1381 %
1382 % \NewDocElement[macrolike = false ,
1383 % idxtype = env. ,
1384 % idxgroup = environments ,
1385 % printtype = \textit{env.}
1386 % ]{Env}{environment}
1387 %\end{verbatim}
1388 %
1389 % To showcase the new features of \DOC version 3 to some extend, the
1390 % current documentation is done by redefining these declarations and
1391 % also adding a few additional declarations on top.
1392 %
1393 % For any internal command we document we use \texttt{Macro} and put
1394 % all of them under the heading ``\LaTeX{} commands'' (note the use of \cs{actualchar}):
1395 %\begin{verbatim}
1396 %\RenewDocElement[macrolike = true ,
1397 % toplevel = false,
1398 % idxtype = ,
1399 % idxgroup = LaTeX commands\actualchar\LaTeX{} commands ,
1400 % printtype =
1401 % ]{Macro}{macro}
1402 %\end{verbatim}
1403 %
1404 % We only have package environments so we use \texttt{Env} for those
1405 % and group them as well:
1406 %\begin{verbatim}
1407 %\RenewDocElement[macrolike = false ,
1408 % toplevel = false,
1409 % idxtype = env. ,
1410 % idxgroup = Package environments,
1411 % printtype = \textit{env.}
1412 % ]{Env}{environment}
1413 %\end{verbatim}
1414 %
1415 %
1416 % All the interface commands are also grouped together under the label
1417 % ``Package commands'', we use \texttt{InterfaceMacro} for them:
1418 %\begin{verbatim}
1419 %\NewDocElement[macrolike = true ,
1420 % toplevel = false,
1421 % idxtype = ,
1422 % idxgroup = Package commands,
1423 % printtype =
1424 % ]{InterfaceMacro}{imacro}
1425 %\end{verbatim}
1426 %
1427 % And since we also have a few obsolete interfaces we add yet another category:
1428 %\begin{verbatim}
1429 %\NewDocElement[macrolike = true ,
1430 % toplevel = false,
1431 % idxtype = ,
1432 % idxgroup = Package commands (obsolete),
1433 % printtype =
1434 % ]{ObsoleteInterfaceMacro}{omacro}
1435 %\end{verbatim}
1436 %
1437 % Another type of category are the package keys:
1438 %\begin{verbatim}
1439 %\NewDocElement[macrolike = false ,
1440 % toplevel = false,
1441 % idxtype = key ,
1442 % idxgroup = Package keys ,
1443 % printtype = \textit{key}
1444 % ]{Key}{key}
1445 %\end{verbatim}
1446 %
1447 % Finally we have \TeX{} counters (with a backslash in front) and
1448 % \LaTeX{} counters (no backslash) and the two types of \LaTeX{}
1449 % length registers:
1450 %\begin{verbatim}
1451 %\NewDocElement[macrolike = true ,
1452 % toplevel = false,
1453 % idxtype = counter ,
1454 % idxgroup = TeX counters\actualchar \protect\TeX{} counters ,
1455 % printtype = \textit{counter}
1456 % ]{TeXCounter}{tcounter}
1457 %
1458 %\NewDocElement[macrolike = false ,
1459 % toplevel = false,
1460 % idxtype = counter ,
1461 % idxgroup = LaTeX counters\actualchar \LaTeX{} counters ,
1462 % printtype = \textit{counter}
1463 % ]{LaTeXCounter}{lcounter}
1464 %
1465 %\NewDocElement[macrolike = true ,
1466 % toplevel = false,
1467 % idxtype = skip ,
1468 % idxgroup = LaTeX length\actualchar \LaTeX{} length (skip) ,
1469 % printtype = \textit{skip}
1470 % ]{LaTeXSkip}{lskip}
1471 %
1472 %\NewDocElement[macrolike = true ,
1473 % toplevel = false,
1474 % idxtype = dimen ,
1475 % idxgroup = LaTeX length\actualchar \LaTeX{} length (dimen) ,
1476 % printtype = \textit{dimen}
1477 % ]{LaTeXDimen}{ldimen}
1478 %
1479 %\end{verbatim}
1480 %
1481 % And we modify the appearance of the index: just 2 columns not 3 and
1482 % all the code-line entries get prefixed with an ``$\ell$'' (for line)
1483 % so that they can easily be distinguished from page index entries.
1484 %\begin{verbatim}
1485 % \renewcommand\code[1]{\mbox{$\ell$-#1}}
1486 % \renewcommand\main[1]{\underline{\mbox{$\ell$-#1}}}
1487 % \setcounter{IndexColumns}{2}
1488 %\end{verbatim}
1489 %
1490 %
1491 %
1492 % \section{Incompatibilities between version 2 and 3}
1493 %
1494 % The basic approach when developing version~3 was to provide a very
1495 % high level of compatibility with version~2 so that nearly all
1496 % older documents should work out of the box without the need for
1497 % any adjustments.
1498 %
1499 % But as with any change there are situations where that change can
1500 % result in some sort of incompatibility, e.g., if a newly introduce
1501 % command name was already been defined in the user document then
1502 % there will be a conflict that is nearly impossible to avoid
1503 % 100\%.
1504 %
1505 % As mentioned earlier, \DOC now supports options on several commands
1506 % and environments and as a result it is necessary to use braces
1507 % around the argument for \cs{DescribeMaro} if the ``macro to be
1508 % described'' uses private letters such as |@| or |_| as part of its
1509 % name. That was always the official syntax but in the past you could
1510 % get away with leaving out the braces more often than you can now.
1511 %
1512 % The old \DOC documentation also claimed that redefinitions of things
1513 % like \cs{PrintDescribeMacro} could be done before loading the
1514 % package (and not only afterwards) and \DOC would in that case not
1515 % change those commands. As the setup mechanisms are now much more
1516 % powerful and general such an approach is not really good. So with
1517 % \DOC version~3 modifications have to be done after the \DOC package
1518 % got loaded and the last modification will always win.
1519 %
1520 % I'm temped to drop compatibility with \LaTeX~2.09 (but so far I
1521 % have left it in).
1522 %
1523 % In the past it was possible to use macros declared with \cs{outer}
1524 % in the argument of \verb=\begin{macro}= or \cs{DoNotIndex} even
1525 % though \cs{outer} is not a concept supported in \LaTeX{}. This is no
1526 % longer possible. More exactly, it is no longer possible to prevent
1527 % them from being indexed (as \cs{DoNotIndex} can't be used), but you
1528 % can pass them to the \env{macro} environment as follows:
1529 %\begin{verbatim}
1530 % \begin{macro}[outer]{\foo}
1531 %\end{verbatim}
1532 % if \cs{foo} is a macro declared with \cs{outer}. The technical
1533 % reason for this change is that in the past various other commands,
1534 % such as |\{| or |\}| did not work properly in these arguments when
1535 % they where passed as ``strings'' and not as single macro tokens. But
1536 % by switching to macro tokens we can't have \cs{outer} macros because
1537 % their feature is to be not allowed in arguments. So what happens
1538 % above when you use \texttt{[outer]} is that the argument is read as
1539 % a string with four character tokens so that it is not recognized as
1540 % being \cs{outer}.
1541 %
1542 %
1543 % \section{Old interfaces no longer really needed}
1544 %
1545 % Thirty years is a long time in the life of computer programs, so
1546 % there are a good number of interfaces within \DOC that are really
1547 % only of historical interest (or when processing equally old sources).
1548 % We list them here, but in general we suggest that for new
1549 % documentation they should not be used.
1550 %
1551 %
1552 % \subsection{\prg{makeindex} bugs}
1553 %
1554 % \DescribeObsoleteInterfaceMacro\OldMakeindex
1555 % Versions of \prg{makeindex} prior to 2.9 had some bugs affecting
1556 % \DOC{}. One of these,
1557 % pertaining to the |%| character doesn't have a work-around
1558 % appropriate for versions with and without the
1559 % bug.\label{makeindex:version} If
1560 % you really still have an old version, invoke |\OldMakeindex| in a
1561 % package file or the driver file to prevent problems with index entries
1562 % such as |\%|, although you'll probably normally want to turn off
1563 % indexing of |\%| anyway. Try to get an up-to-date \prg{makeindex}
1564 % from one of the \TeX{} repositories.
1565 %
1566 % \subsection{File transmission issues}
1567 %
1568 % In the early days of the Internet file transmission issues have been
1569 % a serious problem. There was a famous gateway in Rochester, UK that
1570 % handled the traffic from the European continent to the UK and that
1571 % consisted of two IBM machines running with different codepages (that
1572 % had non-reversible differences). As a result ``strange'' \TeX{}
1573 % characters got replaced with something else with the result that the
1574 % files became unusable.
1575 %
1576 % To guard against this problem (or rather to detect it if something
1577 % got broken in transfer I added code to \DOC to check a static
1578 % character table and also to have a very simple checksum feature
1579 % (counting backslashes).
1580 %
1581 % These days the \cs{CheckSum} is of little value (and a lot of pain
1582 % for the developer) and character scrambling doesn't happen any more
1583 % so the \cs{CharacterTable} is essentially useless. Thus neither
1584 % should be used in new developments.
1585 %
1586 % \label{sec:checksum}
1587 % \DescribeObsoleteInterfaceMacro\CharacterTable
1588 % \DescribeObsoleteInterfaceMacro\CheckSum
1589 % To overcome some of the problems of sending files over the networks
1590 % we developed two macros which should detect corrupted files. If one
1591 % places the lines
1592 % \begin{flushleft}
1593 % \small\ttfamily ^^A \ttfamily to get the blanks between "..."s
1594 % ^^A right
1595 %|%%\CharacterTable|\\
1596 %|%% {Upper-case |
1597 %|\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|\\
1598 %|%% Lower-case |
1599 %|\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|\\
1600 %|%% Digits \0\1\2\3\4\5\6\7\8\9|\\
1601 %|%% Exclamation \! Double quote "|
1602 %| Hash (number) \#|\\
1603 %|%% Dollar \$ Percent \% Ampersand \&|\\
1604 %|%% Acute accent \' Left paren \( Right paren \)|\\
1605 %|%% Asterisk \* Plus \+ Comma \,|\\
1606 %|%% Minus \- Point \. Solidus \/|\\
1607 %|%% Colon \: Semicolon \; Less than \<|\\
1608 %|%% Equals \= Greater than \> Question mark \?|\\
1609 %|%% Commercial at \@ Left bracket \[ Backslash \\|\\
1610 %|%% Right bracket \] Circumflex \^ Underscore \_|\\
1611 %|%% Grave accent \` Left brace \{ Vertical bar |\verb=|=\\
1612 %|%% Right brace \} Tilde \~}|\\
1613 %|%%|
1614 %\end{flushleft}
1615 % at the beginning of the file then character translation failures
1616 % will be detected, provided of course, that the used \DOC{}
1617 % package has a correct default table. The percent
1618 % signs\footnote{There are two percent signs in each line. This has
1619 % the effect that these lines are not removed by the
1620 % \texttt{docstrip.tex} program.} at the beginning of the lines should
1621 % be typed in, since only the \DOC{} package should look at this
1622 % command.
1623 %
1624 %
1625 % Another problem of mailing files is possible truncation. To detect
1626 % these sort of errors we provide a |\CheckSum| macro. The check-sum
1627 % of a file is simply the number of backslashes in the code, i.e.\ all
1628 % lines between the \env{macrocode} environments. But don't be
1629 % afraid: you don't have count the code-lines yourself; this is done
1630 % by the \DOC{} package for you. You simply have add
1631 % \begin{quote}
1632 % |% \CheckSum{0}|
1633 % \end{quote}
1634 % near the beginning of the file and use the |\MaybeStop| (which
1635 % starts looking for backslashes) and the |\Finale| command. The
1636 % latter will inform you either that your file has no check-sum
1637 % (telling you the right number) or that your number is incorrect if
1638 % you put in anything other than zero but guessed wrong (this time
1639 % telling you both the correct and the incorrect one). Then you go to
1640 % the top of your file again and change the line to the right number,
1641 % i.e., line
1642 % \begin{quote}
1643 % |% \CheckSum{|\meta{number}|}|
1644 % \end{quote}
1645 % and that's all.
1646 %
1647 % While |\CharacterTable| and |\CheckSum| have been important features
1648 % in the early days of the public internet when \DOC{} was written as
1649 % the mail gateways back then were rather unreliable and often mangled
1650 % files they are these days more a nuisance than any help. They are
1651 % therefore now fully optional and no longer recommended for use with
1652 % new files.
1653 %
1654 %
1655
1656
1657
1658 % ^^A =============================================================
1659
1660
1661
1662 % \begin{multicols}{2}[\medskip \noindent\rule{\textwidth}{.3pt}
1663 % \section{Introduction to previous releases}]
1664 %
1665 % \begin{quote}
1666 % \textbf{Original abstract:}
1667 % This package contains the definitions that are necessary to
1668 % format the documentation of package files. The package was
1669 % developed in Mainz in cooperation with the Royal Military College
1670 % of Science. This is an update which documents various changes
1671 % and new features in \DOC{} and integrates the features of
1672 % \env{newdoc}.
1673 % \end{quote}
1674 %
1675 % The \TeX{} macros which are described here allow definitions and
1676 % documentation to be held in one and the same file. This has the
1677 % advantage that normally very complicated instructions are made
1678 % simpler to understand by comments inside the definition. In addition
1679 % to this, updates are easier and only one source file needs to be
1680 % changed. On the other hand, because of this, the package files are
1681 % considerably longer: thus \TeX{} takes longer to load them. If this
1682 % is a problem, there is an easy remedy: one needs only to run the
1683 % \texttt{docstrip.tex} program that removes nearly all lines that begin
1684 % with a
1685 % percent sign.
1686 %
1687 % The idea of integrated documentation was born with the development
1688 % of the \TeX{} program; it was crystallized in Pascal with the \Web{}
1689 % system. The advantages of this method are plain to see (it's easy
1690 % to make comparisons \cite{art:Knuthliterat}). Since this
1691 % development, systems similar to \Web{} have been developed for other
1692 % programming languages. But for one of the most complicated
1693 % programming languages (\TeX) the documentation has however been
1694 % neglected. The \TeX{} world seems to be divided between:---
1695 % \begin{itemize} \item a couple of ``wizards'', who produce many
1696 % lines of completely unreadable code ``off the cuff'', and \item many
1697 % users who are amazed that it works just how they want it to do. Or
1698 % rather, who despair that certain macros refuse to do what is
1699 % expected of them.\end{itemize}
1700 %
1701 % I do not think that the \Web{} system is {\em the\/} reference work;
1702 % on the contrary, it is a prototype which suffices for the
1703 % development of programs within the \TeX{} world. It is sufficient,
1704 % but not totally sufficient.\footnote{I know that this will be seen
1705 % differently by a few people, but this product should not be seen as
1706 % the finished product, at least as far as applications concerning
1707 % \TeX{} are concerned. The long-standing debate over `multiple
1708 % change files' shows this well.} As a result of \Web, new programming
1709 % perspectives have been demonstrated; unfortunately, though, they
1710 % haven't been developed further for other programming languages.
1711 %
1712 % The method of documentation of \TeX{} macros which I have introduced
1713 % here should also only be taken as a first sketch. It is designed
1714 % explicitly to run under \LaTeX{} alone. Not because I was of the
1715 % opinion that this was the best starting point, but because from this
1716 % starting point it was the quickest to develop.\footnote{This
1717 % argument is a bad one, however, it is all too often trotted out.} As
1718 % a result of this design decision, I had to move away from the
1719 % concept of modularization; this was certainly a step backward.
1720 %
1721 % I would be happy if this article could spark off discussion over
1722 % \TeX\ documentation. I can only advise anyone who thinks that they
1723 % can cope without documentation to ``Stop Time'' until he or she
1724 % completely understands the \AmSTeX{} source code.
1725 %
1726 % \subsection*{Using the \DOC{} package}
1727 %
1728 % Just like any other package, invoke it by requesting it with a
1729 % |\usepackage| command in the preamble. \DOC's use of
1730 % |\reversemarginpars| may make it incompatible with some classes.
1731 % \changes{v1.7a}{1992/02/25}{Altered usage info}
1732 %
1733 %
1734 % \end{multicols}
1735 %
1736 %
1737 %
1738 %
1739 % \begin{multicols}{2}[\subsection*{Preface to version 1.7 (from
1740 % around 1992)}]
1741 %
1742 % This version of \texttt{doc.dtx} documents changes which have occurred
1743 % since the last published version \cite{art:doc} but which have been
1744 % present in distributed versions of \texttt{doc.sty} for some time. It
1745 % also integrates the (undocumented) features of the distributed
1746 % \texttt{newdoc.sty}.
1747 %
1748 % The following changes and additions have been made to the user
1749 % interface since the published version~\cite{art:doc}. See
1750 % \S\ref{sec:interface} for more details.
1751 % \begin{description}
1752 % \item[Driver mechanism] |\DocInput| is now used in the driver file
1753 % to input possibly multiple independent \DOC{} files and \DOC{} no
1754 % longer has to be the last package. |\IndexListing| is replaced
1755 % by |\IndexInput|;
1756 % \item[Indexing] is controlled by |\PageIndex| and |\CodelineIndex|,
1757 % one of which must be specified to produce an index---there is no
1758 % longer a |\makeindex| in the default |\DocstyleParms|;
1759 % \item[The \texttt{macro} environment] now takes as argument the
1760 % macro name {\em with\/} the backslash;
1761 % \item[Verbatim text] Newlines are now forbidden inside |\verb| and
1762 % commands |\MakeShortVerb| and |\DeleteShortVerb| are provided for
1763 % verbatim shorthand;
1764 % \item[\texttt{\bslash par}] can now be used in |\DoNotIndex|;
1765 % \item[Checksum/character table support] for ensuring the integrity
1766 % of distributions is added;
1767 % \item[\texttt{\bslash printindex}] becomes |\PrintIndex|;
1768 % \item[\texttt{multicol.sty}] is no longer necessary to use \DOC{} or
1769 % print the documentation (although it is recommended);
1770 % \item[`Docstrip' modules] are recognized and formatted specially.
1771 % \end{description}
1772 %
1773 % As well as adding some completely new stuff,
1774 % the opportunity has been taken to add some commentary to the code
1775 % formerly in \pkg{newdoc} and that added after version 1.5k of
1776 % \DOC. Since (as noted in the sections concerned) this
1777 % commentary wasn't written by Frank Mittelbach but the code was, it is
1778 % probably {\em not\/} true in this case that ``if the code and
1779 % comments disagree both are probably wrong''!
1780 %
1781 % \subsubsection*{Bugs}
1782 %
1783 % There are some known bugs in this version:
1784 % \begin{itemize}
1785 % \item The |\DoNotIndex| command doesn't work for some single
1786 % character commands most noticeable |\%|.
1787 % \item The `General changes' glossary entry would come out after
1788 % macro names with a leading |!| and possibly a leading |"|;
1789 % \item If you have an old version of \prg{makeindex} long |\changes|
1790 % entries will come out strangely and you may find the section
1791 % header amalgamated with the first changes entry. Try to get an
1792 % up-to-date one (see p.~\pageref{makeindex:version});
1793 % \item Because the accompanying \prg{makeindex} style files support
1794 % the inconsistent attribute specifications of older and newer
1795 % versions \prg{makeindex} always complains about three `unknown
1796 % specifier's when sorting the index and changes entries.
1797 % \item If |\MakeShortVerb| and |\DeleteShortVerb| are used with
1798 % single character arguments, e.g., \verb"{|}" instead of \verb"{\|}" chaos
1799 % may happen.
1800 % \end{itemize}
1801 % (Some `features' are documented below.)
1802 %
1803 % \subsubsection*{Wish list}
1804 %
1805 % \begin{itemize}
1806 % \item Hooks to allow |\DescribeMacro| and |\DescribeEnv| to write
1807 % out to a special file information about the package's `exported'
1808 % definitions which they describe. This could subsequently be
1809 % included in the \texttt{docstrip}ped \texttt{.sty} file in a
1810 % suitable form for use by smart editors in command completion,
1811 % spelling checking etc., based on the packages used in a document.
1812 % This would need agreement on a `suitable form'. \item Indexing of
1813 % the modules used in \texttt{docstrip}'s |%<| directives. I'm not
1814 % sure how to index directives containing module combinations; \item
1815 % Writing out bibliographic information about the package; \item Allow
1816 % turning off use of the special font for, say, the next guarded
1817 % block.
1818 % \end{itemize}
1819 %
1820 %
1821 % \end{multicols}
1822
1823
1824 % \subsection*{Acknowledgements}
1825 %
1826 % I would like to thank all folks at Mainz and at the Royal Military
1827 % College of Science for their help in this project. Especially Brian
1828 % and Rainer who pushed everything with their suggestions, bug fixes,
1829 % etc.
1830 %
1831 % A big thank you to David Love who brought the documentation
1832 % up-to-date again, after I neglected this file for more than two
1833 % years. This was most certainly a tough job as many features added to
1834 % \texttt{doc.dtx} after its publication in \textsl{TUGboat\/} have
1835 % been never properly described. Beside this splendid work he kindly
1836 % provided additional code (like ``docstrip'' module formatting) which
1837 % I think every \DOC user will be grateful for.
1838 %
1839 %
1840 % \MaybeStop{
1841 % \begin{thebibliography}{1}
1842 % \bibitem{book:Buerger} \textsc{G. A. B\"urger}.
1843 % \newblock Wunderbare Reisen zu Wasser und zu Lande, Feldzüge
1844 % und lustige Abenteuer des Freyherrn v.\ Münchhausen.
1845 % \newblock London, 1786 \& 1788.
1846 % \bibitem{art:Knuthliterat} \textsc{D. E. Knuth}.
1847 % \newblock Literate Programming.
1848 % \newblock Computer Journal, Vol.~27, \textit{pp}.~97--111,
1849 % May 1984.
1850 % \bibitem{book:KnuthA} \textsc{D. E. Knuth}.
1851 % \newblock Computers \& Typesetting (The \TeX book).
1852 % \newblock Addison-Wesley, Vol. A, 1986.
1853 % \bibitem{art:Chen} \textsc{L. Lamport}.
1854 % \newblock MakeIndex: An Index Processor for \LaTeX.
1855 % \newblock 17 February 1987.
1856 % \newblock (Taken from the file \texttt{makeindex.tex} provided
1857 % with
1858 % the program source code.)
1859 % \bibitem{art:doc} \textsc{Frank Mittelbach}.
1860 % \newblock The \DOC{}-option.
1861 % \newblock \textsl{TUGboat}, Vol.~10(2), \textit{pp}.~245--273,
1862 % July 1989.
1863 % \bibitem{art:docstrip} \textsc{Frank Mittelbach, Denys Duchier and
1864 % Johannes Braams}.
1865 % \newblock \texttt{docstrip.dtx}.
1866 % \newblock The file is part of core \LaTeX{}.
1867 % \bibitem{book:Raspe} \textsc{R. E. Raspe} (*1737, \dag 1797).
1868 % \newblock Baron Münchhausens narrative of his marvelous
1869 % travels and campaigns in Russia.
1870 % \newblock Oxford, 1785.
1871 % \bibitem{art:verbatim} \textsc{Rainer Schöpf}.
1872 % \newblock A New Implementation of \LaTeX's \texttt{verbatim} and
1873 % \texttt{verbatim*} Environments.
1874 % \newblock File \texttt{verbatim.doc}, version 1.4i.
1875 % \end{thebibliography}
1876 %
1877 % \addtocontents{toc}{\protect\end{multicols}}
1878 %
1879 % \PrintIndex
1880 %
1881 % } ^^A end \MaybeStop
1882 %
1883 %
1884 % \section{The Description of Macros}
1885 %
1886 % Most of the following code is destined for \texttt{doc.sty} after
1887 % processing with \texttt{docstrip} to include the module
1888 % \textbf{style} indicated here. (All code in this file not
1889 % appropriate to \texttt{doc.sty} has to be included explicitly by
1890 % docstrip so that this \texttt{.dtx} file can be used as directly as
1891 % a package file rather than the stripped version.) The usual font
1892 % change for the conditionally-included lines between the
1893 % \Module{*style} and \Module{/style} directives is suppressed since
1894 % only the lines with an explicit directive are special in this file.
1895 % \begin{macrocode}
1896 %<*package>
1897 % \end{macrocode}
1898 % Under \LaTeXe{} the test to avoid reading
1899 % \DOC{} in twice is normally unnecessary. It was kept to only to
1900 % stay compatible with \LaTeX209 styles that |\input| \DOC{}
1901 % directly.
1902 % \changes{v1.5i}{1989/06/07}{Avoid reading the file twice.}
1903 % \begin{macrocode}
1904 \@ifundefined{macro@cnt}{}{\endinput}
1905 % \end{macrocode}
1906 %
1907 % \DescribeObsoleteInterfaceMacro\fileversion
1908 % \DescribeObsoleteInterfaceMacro\filedate
1909 % \DescribeObsoleteInterfaceMacro\docdate
1910 % As you can see I used macros like |\fileversion| to denote the
1911 % version number and the date. They are defined at the very beginning
1912 % of the package file (without a surrounding \env{macrocode}
1913 % environment), so I don't have to search for this place here when I
1914 % change the version number. You can see their actual outcome in a
1915 % footnote to the title.
1916 %
1917 %
1918 % The first thing that we do next is to get ourselves two alternative comment
1919 % signs. Because all sensible signs are already occupied, we will
1920 % choose some that can only be entered indirectly:
1921 % {\DoNotIndex{\^}^^A avoid misinterpretation !!!!! VERIFY
1922 % \begin{macrocode}
1923 \catcode`\^^A=14
1924 \catcode`\^^X=14
1925 % \end{macrocode}
1926 % We repeat this statement at the beginning of the document in case
1927 % the \texttt{inputenc} package is used disabling it again.
1928 % \changes{v2.0b}{1998/05/19}{Init docs private comment char at begin
1929 % of document again (pr2581)}
1930 % \begin{macrocode}
1931 \AtBeginDocument{\catcode`\^^A=14\relax\catcode`\^^X=14\relax}
1932 % \end{macrocode}
1933 % \SortIndex{\string^\string^A}{\string\verb\verbatimchar
1934 % \string^\string^A\verbatimchar
1935 % \encapchar main}^^A
1936 % \SortIndex{\string^\string^X}{\string\verb\verbatimchar
1937 % \string^\string^X\verbatimchar
1938 % \encapchar main}
1939 % }
1940 %
1941 %
1942 % \subsection{Keys supported by \DOC{}}
1943 %
1944 % In the past this used \pkg{kvoptions} but this will be
1945 % replaced by using \texttt{l3keys} at some point in the future.
1946 % Right now this is only a lightweight shift---the code could and
1947 % should be altered further.
1948 % \fmi{cleanup replacement of kvoptions}
1949 %
1950 % Some keys are available as options for use in \cs{usepackage} some are
1951 % for the generated item \api's:
1952 % \changes{v3.0k}{2022/06/22}{Use \cs{DeclareKeys}}
1953 % \changes{v3.0h}{2022/06/01}{fix choice key name (gh/750)}
1954 % \changes{v3.0h}{2022/06/01}{fix default key name (gh/750)}
1955 % \begin{macrocode}
1956 \DeclareKeys
1957 {
1958 noprint .if = {doc@noprint},
1959 noindex .if = {doc@noindex},
1960 hyperref .if = {doc@hyperref},
1961 nohyperref .ifnot = {doc@hyperref},
1962 multicol .if = {doc@multicol},
1963 nomulticol .ifnot = {doc@multicol},
1964 debugshow .if = {doc@debugshow},
1965 reportchangedates .if = {doc@reportchangedates},
1966 toplevel .if = {doc@toplevel},
1967 notoplevel .ifnot = {doc@toplevel},
1968 macrolike .if = {doc@macrolike},
1969 envlike .ifnot = {doc@macrolike},
1970 idxtype .store = \doc@idxtype,
1971 idxgroup .store = \doc@idxgroup,
1972 printtype .store = \doc@printtype,
1973 outer .if = {doc@outer},
1974 }
1975 % \end{macrocode}
1976 %
1977 % Setting these options to true initially.
1978 % \begin{macrocode}
1979 \doc@hyperreftrue
1980 \doc@multicoltrue
1981 \doc@topleveltrue
1982 % \end{macrocode}
1983 %
1984 % \subsection{Processing the package keys}
1985 %
1986 % \begin{macrocode}
1987 \ProcessKeyOptions
1988 % \end{macrocode}
1989 %
1990 %
1991 % \begin{macro}{\ifscan@allowed}
1992 % \begin{macro}{\scan@allowedtrue}
1993 % \begin{macro}{\scan@allowedfalse}
1994 % |\ifscan@allowed| is the switch used to determine if
1995 % the |\active@escape@char|\SpecialIndex{\active@escape@char}
1996 % should start the macro scanning mechanism.
1997 % \begin{macrocode}
1998 \newif\ifscan@allowed \scan@allowedtrue
1999 % \end{macrocode}
2000 % \end{macro}
2001 % \end{macro}
2002 % \end{macro}
2003 %
2004 % \begin{imacro}{\SetupDoc}
2005 %
2006 % We need to save the default value for some options because \DOC elements
2007 % can locally set them.
2008 % \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
2009 % \begin{macrocode}
2010 \def\SetupDoc#1{%
2011 \csname keys_set:nn\endcsname{doc}{#1}%
2012 \edef\doc@noprintdefault{\ifdoc@noprint true\else false\fi}%
2013 \ifdoc@noindex
2014 % \end{macrocode}
2015 % If we do not index by default then we should also turn off
2016 % \cs{scan@allowed}.
2017 % \begin{macrocode}
2018 \def\doc@noindexdefault{true}%
2019 \scan@allowedfalse
2020 \else
2021 \def\doc@noindexdefault{false}%
2022 \fi
2023 }
2024 % \end{macrocode}
2025 % \end{imacro}
2026 %
2027 % \begin{macrocode}
2028 \SetupDoc{} % just save the default values
2029 % \end{macrocode}
2030 %
2031 %
2032 %
2033 % \subsection{Macros surrounding the `definition parts'}
2034 %
2035 % \begin{environment}{macrocode}
2036 % Parts of the macro definition will be surrounded by the
2037 % environment \env{macrocode}. Put more precisely, they will be
2038 % enclosed by a macro whose argument (the text to be set
2039 % `verbatim') is terminated by the string
2040 % \verb*+% \end{macrocode}+. Carefully note the number of spaces.
2041 % |\macrocode| is defined completely analogously to
2042 % |\verbatim|, but because a few small changes were carried
2043 % out, almost all internal macros have got new names. We start by
2044 % calling the macro |\macro@code|, the macro which bears the
2045 % brunt of most of the work, such as |\catcode| reassignments,
2046 % etc.
2047 % \changes{v1.5r}{1989/11/04}{Support for code line no. (Undoc)}
2048 % \begin{macrocode}
2049 \def\macrocode{\macro@code
2050 % \end{macrocode}
2051 % Then we take care that all spaces have the same width, and that
2052 % they are not discarded.
2053 % \begin{macrocode}
2054 \frenchspacing \@vobeyspaces
2055 % \end{macrocode}
2056 % Before closing, we need to call |\xmacro@code|. It is this
2057 % macro that expects an argument which is terminated by the above
2058 % string. This way it is possible to keep the |\catcode|
2059 % changes local.
2060 % \changes{v1.5r}{1989/11/04}{Support for code line no. (Undoc)}
2061 % \changes{v1.5t}{1989/11/07}{Common code moved to \cs{macro@code}.}
2062 % \begin{macrocode}
2063 \xmacro@code}
2064 % \end{macrocode}
2065 % \end{environment}
2066 %
2067 %
2068 % \begin{macro}{\macro@code}
2069 % We will now begin with the macro that does the actual work:
2070 % \begin{macrocode}
2071 \def\macro@code{%
2072 % \end{macrocode}
2073 % In theory it should consist of a \env{trivlist} environment, but
2074 % the empty space before and after the environment should not be
2075 % too large.
2076 % \begin{macrocode}
2077 \topsep \MacrocodeTopsep
2078 % \end{macrocode}
2079 % The next parameter we set is |\@beginparpenalty|, in order
2080 % to prevent a page break before such an environment.
2081 % \begin{macrocode}
2082 \@beginparpenalty \predisplaypenalty
2083 % \end{macrocode}
2084 % We then start a |\trivlist|, set |\parskip| back to
2085 % zero and start an empty |\item|.
2086 % \changes{v1.9b}{1993/12/03}{Forcing any label from macro env.}
2087 % \begin{macrocode}
2088 \if@inlabel\leavevmode\fi
2089 \trivlist \parskip \z@ \item[]%
2090 % \end{macrocode}
2091 % The \cs{item} command sets the \cs{@labels} box but that box is
2092 % never typeset (as \cs{everypar} that normally does this gets
2093 % redefined later). That is normally not an issue, but produces a
2094 % problem when typesetting in mixed directions, (e.g., in
2095 % Japanese), so we explicitly clear it for that use case.
2096 % \changes{v2.1m}{2020/06/15}{Void \cs{@labels} for vertical
2097 % typesetting (gh/344)}
2098 % \begin{macrocode}
2099 \global\setbox\@labels\box\voidb@x
2100 % \end{macrocode}
2101 % Additionally, everything should be set in \texttt{typewriter} font.
2102 % Some people might prefer it somewhat differently; because of this
2103 % the font choice is
2104 % macro-driven.\footnote{The font change has to be placed
2105 % {\em after\/}
2106 % the \texttt{\bslash item}. Otherwise a change to
2107 % \texttt{\bslash baselineskip} will affect the
2108 % paragraph above.}
2109 % \begin{macrocode}
2110 \macro@font
2111 % \end{macrocode}
2112 % Because |\item| sets various parameters, we have found it
2113 % necessary to alter some of these retrospectively.
2114 % \begin{macrocode}
2115 \leftskip\@totalleftmargin \advance\leftskip\MacroIndent
2116 \rightskip\z@ \parindent\z@ \parfillskip\@flushglue
2117 % \end{macrocode}
2118 % The next line consists of the \LaTeX{} definition of |\par|
2119 % used in |\verbatim| and should result in blank lines being
2120 % shown as blank lines.
2121 % \changes{v1.5l}{1989/09/10}{Code line numbers supported.}
2122 % \changes{v1.5t}{1989/11/07}{Call \cs{leavevmode} to get \cs{everypar}
2123 % on blank lines.}
2124 % \changes{v1.7c}{1992/03/24}{Added \cs{interlinepenalty} to
2125 % \cs{par} from
2126 % verbatim.sty}
2127 % \begin{macrocode}
2128 \blank@linefalse \def\par{\ifblank@line
2129 \leavevmode\fi
2130 \blank@linetrue\@@par
2131 \penalty\interlinepenalty}
2132 % \end{macrocode}
2133 % What use is this definition of |\par|\,? We use the macro
2134 % |\obeylines| of \cite{book:KnuthA} which changes all |^^M|
2135 % to |\par| so that each can control its own indentation.
2136 % Next we must also ensure that all special signs are normalized;
2137 % that is, they must be given |\catcode| $12$.
2138 % \changes{v1.8b}{1993/09/21}{Changed to conform to new LaTeX verbatim,
2139 % which handles more ligatures.}
2140 % \changes{v3.0o}{2023/12/30}{Use \cs{@noligs} from the \LaTeX\
2141 % kernel, so that the \texttt{upquote} package can
2142 % add its patch (gh/1230)}
2143 % \begin{macrocode}
2144 \obeylines
2145 \@noligs
2146 \let\do\@makeother \dospecials
2147 % \end{macrocode}
2148 % \changes{v1.5t}{1989/11/07}{Common code added.}
2149 % \changes{v1.5w}{1990/02/05}{Skip of \cs{@totalleftmargin} added.} If
2150 % indexing by code lines is switched on the line number is incremented
2151 % and set appropriately. We also check whether the start of the next
2152 % line indicates a \texttt{docstrip} module directive and process it
2153 % appropriately if so using |\check@module|.
2154 % \begin{macrocode}
2155 \global\@newlistfalse
2156 \global\@minipagefalse
2157 \ifcodeline@index
2158 \everypar{\global\advance\c@CodelineNo\@ne
2159 \llap{\theCodelineNo\ \hskip\@totalleftmargin}%
2160 \check@module}%
2161 \else \everypar{\check@module}%
2162 \fi
2163 % \end{macrocode}
2164 % We also initialize the cross-referencing feature by calling
2165 % |\init@crossref|. This will start the scanning mechanism
2166 % when encountering an escape character.
2167 % \begin{macrocode}
2168 \init@crossref}
2169 % \end{macrocode}
2170 % \end{macro}
2171 %
2172 %
2173 % \begin{macro}{\ifblank@line}
2174 % \begin{macro}{\blank@linetrue}
2175 % \begin{macro}{\blank@linefalse}
2176 % |\ifblank@line| is the switch used in the definition above.
2177 % In the original \env{verbatim} environment the |\if@tempswa|
2178 % switch is used. This is dangerous because its value may change
2179 % while processing lines in the \env{macrocode} environment.
2180 % \begin{macrocode}
2181 \newif\ifblank@line
2182 % \end{macrocode}
2183 % \end{macro}
2184 % \end{macro}
2185 % \end{macro}
2186 %
2187 % \begin{macro}{\endmacrocode}
2188 % Because we have begun a \env{trivlist} environment in the
2189 % \env{macrocode} environment, we must also end it. We must
2190 % also act on the value of the |pm@module| flag (see below) and
2191 % empty |\everypar|.
2192 % \changes{v1.5r}{1989/11/04}{Support for code line no. (Undoc)}
2193 % \begin{macrocode}
2194 \def\endmacrocode{%
2195 \ifpm@module \endgroup \pm@modulefalse \fi
2196 \everypar{}%
2197 \global\@inlabelfalse
2198 \endtrivlist
2199 % \end{macrocode}
2200 % Additionally |\close@crossref| is used to do anything needed
2201 % to end the cross-referencing mechanism.
2202 % \begin{macrocode}
2203 \close@crossref}
2204 % \end{macrocode}
2205 % \end{macro}
2206 %
2207 %
2208 % \begin{imacro}{\MacroFont}
2209 % Here is the default definition for the |\MacroFont| macro.
2210 % With the new math font handling in NFSS2 it isn't any longer
2211 % correct to suppress the math font setup since this is now handled
2212 % differently. But to keep the font change fast we use only a
2213 % single |\selectfont| (in |\small|) and do the rest by hand.
2214 % \changes{v1.5x}{1990/02/17}{\cs{math@fontsfalse} added for NFSS.}
2215 % \changes{v1.7a}{1992/03/13}{Added \cs{reset@font} for NFSS.}
2216 % \changes{v1.8c}{1993/10/25}{NFSS standard}
2217 % \changes{v1.9t}{1995/05/26}{Removed \cs{math@fontsfalse} (different
2218 % math setup /pr1622)}
2219 % \begin{macrocode}
2220 \@ifundefined{MacroFont}{%
2221 \if@compatibility
2222 % \end{macrocode}
2223 % Despite the above statement we will call |\small| first if
2224 % somebody is using a \LaTeX2.09 document with doc. I wouldn't have
2225 % bothered since doc-sources should be up-to-date but since the
2226 % request came from someone called David Carlisle \ldots :-)
2227 % \changes{v1.9y}{1996/01/26}{Support compat mode}
2228 % \changes{v2.1l}{2019/12/16}{Use \cs{shapedefault} not
2229 % \cs{updefault} for extended NFSS}
2230 % \begin{macrocode}
2231 \def\MacroFont{\small
2232 \usefont\encodingdefault
2233 \ttdefault
2234 \mddefault
2235 \shapedefault
2236 }%
2237 \else
2238 \def\MacroFont{\fontencoding\encodingdefault
2239 \fontfamily\ttdefault
2240 \fontseries\mddefault
2241 \fontshape\shapedefault
2242 \small}%
2243 \fi
2244 }{}
2245 % \end{macrocode}
2246 % \end{imacro}
2247 %
2248 % \begin{imacro}{\AltMacroFont}
2249 % \begin{macro}{\macro@font}
2250 % \changes{v1.7a}{1992/03/12}{Added to support distinction of modules.}
2251 % \changes{v1.7c}{1992/03/26}{Altered font change for OFSS.}
2252 % \changes{v1.7m}{1992/10/11}{Use sltt as default.}
2253 % \changes{v1.8c}{1993/10/25}{NFSS standard}
2254 % \changes{v1.9t}{1995/05/26}{Removed \cs{math@fontsfalse} (different
2255 % math setup /pr1622)}
2256 % Although most of the macro code is set in |\MacroFont| we want to be
2257 % able to switch to indicate module code set in |\AltMacroFont|.
2258 % |\macro@font| keeps track of which one we're using. We can't do the
2259 % same thing sensibly in OFSS as in NFSS.
2260 % \begin{macrocode}
2261 \@ifundefined{AltMacroFont}{%
2262 \if@compatibility
2263 % \end{macrocode}
2264 % Again have |\small| first if we are in compat mode.
2265 % \changes{v1.9y}{1996/01/26}{Support compat mode}
2266 % \begin{macrocode}
2267 \def\AltMacroFont{\small
2268 \usefont\encodingdefault
2269 \ttdefault
2270 \mddefault
2271 \sldefault
2272 }%
2273 \else
2274 \def\AltMacroFont{\fontencoding\encodingdefault
2275 \fontfamily\ttdefault
2276 \fontseries\mddefault
2277 \fontshape\sldefault
2278 \small
2279 }%
2280 \fi
2281 }{}
2282 % \end{macrocode}
2283 % To allow changing the |\MacroFont| in the preamble we defer
2284 % defining the internally used |\macro@font| until after the
2285 % preamble.
2286 % \changes{v2.0a}{1998/05/16}{Support changing \cs{MacroFont} in
2287 % preamble}
2288 % \begin{macrocode}
2289 \AtBeginDocument{\let\macro@font\MacroFont}
2290 % \end{macrocode}
2291 % \end{macro}
2292 % \end{imacro}
2293 %
2294 % \begin{macro}{\check@module}
2295 % \begin{macro}{\ifpm@module}
2296 % \changes{v1.7a}{1992/03/12}{Added.}
2297 % This is inserted by |\everypar| at the start of each macrocode line to
2298 % check whether it starts with module information. (Such information is
2299 % of the form |%<|\meta{switch}|>|, where the |%| must be at the
2300 % start of the line and \meta{switch} comprises names with various
2301 % possible separators and a possible leading |+|, |-|, |*| or |/|
2302 % \cite{art:docstrip}. All that concerns us here is what the first
2303 % character of \meta{switch} is.) First it checks the |pm@module|
2304 % flag in case the previous line had a non-block module
2305 % directive i.e., not |%<*| or |%</|; if it did we need to close the
2306 % group it started and unset the flag. |\check@module| looks ahead at
2307 % the next token and then calls |\ch@percent| to take action depending
2308 % on whether or not it's a |%|; we don't want to expand the token at
2309 % this stage. This is all done conditionally so it can be turned off
2310 % if it causes problems with code that wasn't designed to be
2311 % \texttt{docstrip}ped.
2312 % \begin{macrocode}
2313 \def\check@module{%
2314 \ifcheck@modules
2315 \ifpm@module \endgroup \pm@modulefalse \fi
2316 \expandafter\futurelet\expandafter\next\expandafter\ch@percent
2317 \fi}
2318 \newif\ifpm@module
2319 % \end{macrocode}
2320 % \end{macro}
2321 % \end{macro}
2322 % \begin{imacro}{\DontCheckModules}
2323 % \begin{imacro}{\CheckModules}
2324 % \changes{v1.7a}{1992/03/12}{Added.}
2325 % \begin{macro}{\ifcheck@modules}
2326 % Here are two driver-file interface macros for turning the module
2327 % checking on and off using the |check@modules| switch.
2328 % \begin{macrocode}
2329 \def\DontCheckModules{\check@modulesfalse}
2330 \def\CheckModules{\check@modulestrue}
2331 \newif\ifcheck@modules \check@modulestrue
2332 % \end{macrocode}
2333 % \end{macro}
2334 % \end{imacro}
2335 % \end{imacro}
2336 %
2337 %
2338 % \begin{macro}{\ch@percent}
2339 % \changes{v1.7a}{1992/03/12}{Added.}
2340 % If the lookahead token in |\next| is $|%|_{12}$ we go on to check
2341 % whether the following one is |<| and otherwise do nothing. Note the
2342 % |\expandafter| to get past the |\fi|.
2343 % \begin{macrocode}
2344 \def\ch@percent{%
2345 \if \percentchar\next
2346 \expandafter\check@angle
2347 \fi}
2348 % \end{macrocode}
2349 % \end{macro}
2350 %
2351 % \begin{macro}{\check@angle}
2352 % \changes{v1.7a}{1992/03/12}{Added.}
2353 % Before looking ahead for the |<| the |%| is gobbled by the
2354 % argument here.
2355 % \begin{macrocode}
2356 \def\check@angle#1{\futurelet\next\ch@angle}
2357 % \end{macrocode}
2358 % \end{macro}
2359 % \begin{macro}{\ch@angle}
2360 % \changes{v1.7a}{1992/03/12}{Added.}
2361 % \changes{v1.9k}{1994/02/22}{Have \texttt{<} active}
2362 % If the current lookahead token is |<| we are defined to be
2363 % processing a module directive can go on to look for |+| etc.;
2364 % otherwise we must put back the gobbled |%|. With \LaTeXe{}
2365 % \texttt{<} is active so we have to be a bit careful.
2366 % \begin{macrocode}
2367 \begingroup
2368 \catcode`\<\active
2369 \gdef\ch@angle{\ifx<\next
2370 \expandafter\ch@plus@etc
2371 \else \percentchar \fi}
2372 % \end{macrocode}
2373 % \end{macro}
2374 %
2375 % \begin{macro}{\ch@plus@etc}
2376 % \begin{macro}{\check@plus@etc}
2377 % \changes{v1.7a}{1992/03/12}{Added.}
2378 % We now have to decide what sort of a directive we're dealing with
2379 % and do the right thing with it.
2380 % \begin{macrocode}
2381 \gdef\ch@plus@etc<{\futurelet\next\check@plus@etc}
2382 \gdef\check@plus@etc{%
2383 \if +\next
2384 \let\next\pm@module
2385 \else\if -\next
2386 \let\next\pm@module
2387 \else\if *\next
2388 \let\next\star@module
2389 \else\if /\next
2390 \let\next\slash@module
2391 % \end{macrocode}
2392 % At some point in the past the \texttt{docstrip} program was
2393 % partly rewritten and at that time it also got support for a very
2394 % special directive of the form |%<<| followed by an arbitrary
2395 % string. This is used for ``verbatim'' inclusion in case of
2396 % certain problem. We do not really attempt to pretty print that
2397 % case but we need at least account for it since otherwise we get
2398 % an error message since this is the only case where we will not
2399 % have a closing |>|.
2400 % \changes{v2.0n}{2001/05/16}{Partly support docstrip's ``verbatim''
2401 % directive (pr/3331)}
2402 % \begin{macrocode}
2403 \else\ifx <\next
2404 \percentchar
2405 \else
2406 \let\next\pm@module
2407 \fi\fi\fi\fi\fi
2408 \next}
2409 \endgroup
2410 % \end{macrocode}
2411 % \end{macro}
2412 % \end{macro}
2413 % \begin{macro}{\pm@module}
2414 % If we're not dealing with a block
2415 % directive (|*| or |/|) i.e., it's a single special line, we set
2416 % everything up to the next |>| appropriately and then change to the
2417 % special macro font inside a group which will be ended at the start
2418 % of the next line. If the apparent module directive is missing the
2419 % terminating |>| this will lose, but then so will the \texttt{docstrip}
2420 % implementation. An alternative strategy would be to have
2421 % |\pm@module| make |>| active and clear a flag set here to indicate
2422 % processing the directive. Appropriate action could then be taken if
2423 % the flag was found still to be set when processing the next line.
2424 % \changes{v1.7a}{1992/03/12}{Added.}
2425 % \changes{v1.7i}{1992/07/11}{Support for fonts depending on nesting.}
2426 % \begin{macrocode}
2427 \begingroup
2428 \catcode`\~=\active
2429 \lccode`\~=`\>
2430 \lowercase{\gdef\pm@module#1~}{\pm@moduletrue
2431 \Module{#1}\begingroup
2432 % \end{macrocode}
2433 % We switch to a special font as soon the nesting is higher than
2434 % the current value of |\c@StandardModuleDepth|. We do a local
2435 % update to the |\guard@level| here which will be restored after
2436 % the current input line.
2437 % \begin{macrocode}
2438 \advance\guard@level\@ne
2439 \ifnum\guard@level>\c@StandardModuleDepth\AltMacroFont\fi
2440 }
2441 % \end{macrocode}
2442 % \end{macro}
2443 % \begin{macro}{\star@module}
2444 % \begin{macro}{\slash@module}
2445 % \changes{v1.7a}{1992/03/12}{Added.}
2446 % \changes{v1.7f}{1992/05/16}{Take account of nested guards.}
2447 % \changes{v1.7i}{1992/07/11}{Add counter to determine when to switch to
2448 % special font.}
2449 % If the start or end of a module {\em block\/} is indicated, after
2450 % setting the guard we have to check whether a change in the macrocode
2451 % font should be done. This will be the case if we are already inside
2452 % a block or are ending the outermost block. If so, we globally
2453 % toggle the font for subsequent macrocode sections between the normal
2454 % and special form, switching to the new one immediately.
2455 % \changes{v1.7i}{1992/07/17}{Support for fonts depending on module
2456 % nesting}
2457 % \begin{macrocode}
2458 \lowercase{\gdef\star@module#1~}{%
2459 \Module{#1}%
2460 \global \advance \guard@level\@ne
2461 \ifnum \guard@level>\c@StandardModuleDepth
2462 \global\let\macro@font=\AltMacroFont \macro@font
2463 \fi}
2464 \catcode`\>=\active
2465 \gdef\slash@module#1>{%
2466 \Module{#1}%
2467 \global \advance \guard@level\m@ne
2468 \ifnum \guard@level=\c@StandardModuleDepth
2469 \global\let\macro@font\MacroFont \macro@font
2470 \fi
2471 }
2472 \endgroup
2473 % \end{macrocode}
2474 % \end{macro}
2475 % \end{macro}
2476 %
2477 % \begin{lcounter}{StandardModuleDepth}
2478 % \changes{v1.7i}{1992/07/11}{Counter added.}
2479 % Counter defining up to which level modules are considered part of
2480 % the main code. If, for example, the whole code is surrounded by
2481 % a |%<*package>| module we better set this counter to |1| to avoid
2482 % getting the whole code be displayed in typewriter italic.
2483 % \begin{macrocode}
2484 \newcounter{StandardModuleDepth}
2485 % \end{macrocode}
2486 % \end{lcounter}
2487 %
2488 %
2489 % \begin{tcounter}{\guard@level}
2490 % \changes{v1.7f}{1992/05/16}{Added.}
2491 % We need a counter to keep track of the guard nesting.
2492 % \begin{macrocode}
2493 \newcount \guard@level
2494 % \end{macrocode}
2495 % \end{tcounter}
2496
2497 % \begin{macro}{\Module}
2498 % \changes{v1.7a}{1992/03/12}{Added.}
2499 % \changes{v1.7d}{1992/04/25}{Use sans font for modules.}
2500 % This provides a hook to determine the way the module directive is
2501 % set. It gets as argument everything between the angle brackets.
2502 % The default is to set the contents in sans serif text between
2503 % $\langle\,\rangle$ with the special characters suitably |\mathcode|d
2504 % by |\mod@math@codes|. (You can't just set it in a sans text font
2505 % because normally \verb"|" will print as an em-dash.) This is done
2506 % differently depending on whether we have the NFSS or the old one. In
2507 % the latter case we can easily change |\fam| appropriately.
2508 % \changes{v1.8c}{1993/10/25}{NFSS standard}
2509 % \begin{macrocode}
2510 \@ifundefined{Module}{%
2511 % \end{macrocode}
2512 % With NFSS what we probably {\em should\/} do is change to a new
2513 % |\mathversion| but I (Dave Love) haven't spotted an easy way to
2514 % do so correctly if the document uses a version other than
2515 % |normal|. (We need to know in what font to set the other
2516 % groups.) This uses a new math alphabet rather than version and
2517 % consequently has to worry about whether we're using
2518 % \env{oldlfnt} or not. I expect there's a better
2519 % way\ldots
2520 % \begin{macrocode}
2521 \def\Module#1{\mod@math@codes$\langle\mathsf{#1}\rangle$}
2522 }{}
2523 % \end{macrocode}
2524 % \end{macro}
2525 %
2526 % \begin{macro}{\mod@math@codes}
2527 % \changes{v1.7c}{1992/03/26}{Added.}
2528 % \changes{v2.1e}{2010/02/04}{Added mathcodes for +,-,:, and = (pr/4096)}
2529 % As well as `words', the module
2530 % directive text might contain any of the characters \verb"*/+-,&|!()"
2531 % for the current version of \prg{docstrip}. We only need
2532 % special action for two of them in the math code changing required
2533 % above: \verb"|" is changed to a |\mathop| (it's normally |"026A|) and
2534 % |&| is also made a |\mathop|, but in family 0. Remember that |&|
2535 % will not have a special catcode when it's encountered.
2536 % \begin{macrocode}
2537 \def\mod@math@codes{\mathcode`\|="226A \mathcode`\&="2026
2538 \mathcode`\-="702D \mathcode`\+="702B
2539 \mathcode`\:="703A \mathcode`\=="703D }
2540 % \end{macrocode}
2541 % \end{macro}
2542 %
2543 %
2544 % \begin{lskip}{\MacrocodeTopsep}
2545 % \begin{ldimen}{\MacroIndent}
2546 % In the code above, we have used two registers. Therefore we have
2547 % to allocate them. The default values might be overwritten with
2548 % the help of the |\DocstyleParms| macro.
2549 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
2550 % \changes{v1.5y}{1990/02/24}{Default changed.}
2551 % \changes{v1.6b}{1990/06/15}{\cs{rm} moved before \cs{scriptsize} to
2552 % avoid unnecessary fontwarning.}
2553 % \begin{macrocode}
2554 \newskip\MacrocodeTopsep \MacrocodeTopsep = 3pt plus 1.2pt minus 1pt
2555 \newdimen\MacroIndent
2556 \settowidth\MacroIndent{\rmfamily\scriptsize 00\ }
2557 % \end{macrocode}
2558 % \end{ldimen}
2559 % \end{lskip}
2560 %
2561 %
2562 %
2563 %
2564 % \begin{environment}{macrocode*}
2565 % \begin{macro}{\endmacrocode*}
2566 % Just as in the \env{verbatim} environment, there is also a
2567 % `star' variant of the \env{macrocode} environment in which a
2568 % space is shown by the symbol \verb*+ +. Until this moment, I
2569 % have not yet used it (it will be used in the description of the
2570 % definition of |\xmacro@code| below) but it's exactly on this one
2571 % occasion {\em here\/} that you can't use it (cf.\ Münchhausens
2572 % Marsh problem)\footnote{Karl Friedrich Hieronymus Frhr.\ v.\
2573 % Münchhausen (*1720, \dag1797). Several books were written
2574 % about fantastic adventures supposedly told by him (see
2575 % \cite{book:Raspe} or \cite{book:Buerger}). In one story he
2576 % escaped from the marsh by pulling himself out by his hair.}
2577 % directly. Because of this, on this one occasion we'll cheat
2578 % around the problem with an additional comment character. But now
2579 % back to |\macrocode*|. We start with the macro |\macro@code|
2580 % which prepares everything and then call the macro |\sxmacro@code|
2581 % whose argument is terminated by the string
2582 %\verb*+% \end{macrocode*}+.
2583 % \begin{macrocode}
2584 \@namedef{macrocode*}{\macro@code\sxmacro@code}
2585 % \end{macrocode}
2586 % As we know, |\sxmacro@code| and then |\end{macrocode*}|
2587 % (the macro, not the string), will be executed, so that for a
2588 % happy ending we still need to define the macro
2589 % |\endmacrocode*|.
2590 % \begin{macrocode}
2591 \expandafter\let\csname endmacrocode*\endcsname = \endmacrocode
2592 % \end{macrocode}
2593 % \end{macro}
2594 % \end{environment}
2595 %
2596 %
2597 %
2598 %
2599 %
2600 %
2601 %
2602 % \begin{macro}{\xmacro@code}
2603 \catcode`\!=\catcode`\% ^^A In this section there must not be
2604 ^^A any exclamation marks.
2605 ^^A
2606 % As already mentioned, the macro |\xmacro@code| expects an
2607 % argument delimited by the string \verb*+% \end{macrocode}+. At
2608 % the moment that this macro is called, the |\catcode| of
2609 % \TeX's special characters are 12 (`other') or 13 (`active').
2610 % Because of this we need to utilize a different escape character
2611 % during the definition. This happens locally.
2612 % \begin{macrocode*}
2613 \begingroup
2614 \catcode`\|=\z@ \catcode`\[=\@ne \catcode`\]=\tw@
2615 % \end{macrocode*}
2616 % Additionally, we need to ensure that the symbols in the above
2617 % string contain the |\catcode|$\,$s which are available
2618 % within the \env{macrocode} environment.
2619 % \begin{macrocode*}
2620 \catcode`\{=12 \catcode`\}=12
2621 \catcode`\%=12 \catcode`\ =\active \catcode`\\=\active
2622 !% \end{macrocode*}
2623 ! Next follows the actual definition of |\macro@code|;
2624 ! notice the
2625 ! use of the new escape character. We manage to get the argument
2626 ! surrounded by the string |\end{macrocode}|, but at the end
2627 ! however, in spite of the actual characters used during the
2628 ! definition of
2629 ! this macro, |\end| with the argument |{macrocode}|
2630 ! will be executed, to ensure a balanced environment.
2631 ! \begin{macrocode*}
2632 |gdef|xmacro@code#1% \end{macrocode}[#1|end[macrocode]]
2633 !% \end{macrocode*}
2634 ! \begin{macro}{\sxmacro@code}
2635 ! The definition of |\sxmacro@code| is completely analogous,
2636 ! only
2637 ! here a slightly different terminating string will be used.
2638 ! Note that the space is not active in this environment.
2639 ! \begin{macrocode}
2640 |catcode`| =12
2641 |gdef|sxmacro@code#1% \end{macrocode*}[#1|end[macrocode*]]
2642 !% \end{macrocode}
2643 ! because the |\catcode| changes have been made local by
2644 ! commencing a
2645 ! new group, there now follows the matching |\endgroup|
2646 ! in a rather
2647 ! unusual style of writing.
2648 ! \begin{macrocode}
2649 |endgroup
2650 !% \end{macrocode}
2651 \catcode`\!=12
2652 % \end{macro}
2653 % \end{macro}
2654 %
2655 %
2656 %
2657 %
2658 % \subsection{Macros for the `documentation parts'}
2659 %
2660 %
2661
2662 % To put the labels in the left margin we have to use the
2663 % |\reversemarginpar| declaration. (This means that the
2664 % \texttt{doc.sty} can't be used with all classes or packages.)
2665 % We also
2666 % make the |\marginparpush| zero and |\marginparwidth| suitably
2667 % wide.
2668 % \changes{v1.5d}{1989/04/28}{\cs{marginparwidth} setting added.}
2669 % \begin{macrocode}
2670 \reversemarginpar
2671 \setlength\marginparpush{0pt} \setlength\marginparwidth{8pc}
2672 % \end{macrocode}
2673 %
2674 % \begin{macrocode}
2675 \setlength\marginparsep{\labelsep}
2676 % \end{macrocode}
2677 %
2678 % \begin{imacro}{\bslash}
2679 % \changes{v1.7a}{1992/02/26}{Moved \cs{bslash} documentation to `user
2680 % interface' part}
2681 % We start a new group in which to hide the alteration of
2682 % |\catcode|$\,$s, and make \verb+|+ introduce commands,
2683 % whilst |\| becomes an `other' character.
2684 %
2685 % \begin{macrocode}
2686 {\catcode`\|=\z@ \catcode`\\=12
2687 % \end{macrocode}
2688 % Now we are able to define |\bslash| (globally) to generate a
2689 % backslash of |\catcode| `other'. We then close this group,
2690 % restoring original |\catcode|$\,$s.
2691 % \SpecialEscapechar{\|}
2692 % \begin{macrocode}
2693 |gdef|bslash{\}}
2694 % \end{macrocode}
2695 % \end{imacro}
2696 %
2697 %
2698 %
2699 % \begin{environment}{verbatim}
2700 % \begin{environment}{verbatim*}
2701 % \changes{v1.7i}{1992/07/12}{Added changed definition for verbatim!*.}
2702 % The \env{verbatim} environment holds no secrets; it consists of
2703 % the normal \LaTeX{} environment. We also set the
2704 % |\@beginparpenalty| and change to the font given by
2705 % |\MacroFont|.
2706 % \begin{macrocode}
2707 \def\verbatim{\@beginparpenalty \predisplaypenalty \@verbatim
2708 \MacroFont \frenchspacing \@vobeyspaces \@xverbatim}
2709 % \end{macrocode}
2710 % We deal in a similar way with the star form of this environment.
2711 % \begin{macrocode}
2712 \@namedef{verbatim*}{\@beginparpenalty \predisplaypenalty \@verbatim
2713 % \end{macrocode}
2714 %
2715 % \changes{v2.1j}{2019/11/03}{Kernel now sets up \cs{verbvisiblespace} (gh/205)}
2716 % \changes{v2.1k}{2019/11/10}{Put the definition into the right command (gh/205)}
2717 % \begin{macrocode}
2718 \@setupverbvisiblespace
2719 \MacroFont \@vobeyspaces \@sxverbatim}
2720 % \end{macrocode}
2721 % \end{environment}
2722 % \end{environment}
2723 %
2724 % \begin{macro}{\@verbatim}
2725 % Additionally we redefine the |\@verbatim| macro so that it
2726 % suppresses |%| characters at the beginning of the line. The
2727 % first lines are copied literally from \texttt{latex.tex}.
2728 % \changes{v1.7i}{1992/07/12}{Added \cs{@@par} to clear possible
2729 % \cs{parshape}.}
2730 % \changes{v3.0m}{2022/11/13}{Redefinitions of \cs{@verbatim} changed
2731 % to match the kernel definition (gh/953)}
2732 % \begin{macrocode}
2733 \def\@verbatim{\trivlist \item\relax
2734 \if@minipage\else\vskip\parskip\fi
2735 \leftskip\@totalleftmargin\rightskip\z@
2736 \parindent\z@\parfillskip\@flushglue\parskip\z@
2737 \language\l@nohyphenation
2738 \@@par
2739 \@tempswafalse
2740 % \end{macrocode}
2741 % |\@verbatim| sets |^^M|, the end of line character, to
2742 % be equal to |\par|. This control sequence is redefined
2743 % here; |\@@par| is the paragraph primitive of \TeX.
2744 % \changes{v1.7c}{1992/03/24}{Added \cs{interlinepenalty} to
2745 % \cs{par} from verbatim.sty}
2746 % \begin{macrocode}
2747 \def\par{%
2748 \if@tempswa
2749 \leavevmode \null \@@par\penalty\interlinepenalty
2750 \else
2751 \@tempswatrue
2752 \ifhmode\@@par\penalty\interlinepenalty\fi
2753 \fi
2754 % \end{macrocode}
2755 % We add a control sequence |\check@percent| to the definition
2756 % of |\par| whose task it is to check for a percent character.
2757 % \begin{macrocode}
2758 \check@percent}%
2759 % \end{macrocode}
2760 % The rest is again copied literally from \texttt{latex.tex} (less
2761 % "\tt").
2762 % \changes{v1.7a}{1992/02/26}{Removed redundant \cs{tt}.}
2763 % \changes{v1.8b}{1993/09/21}{Changed to conform to new LaTeX verbatim,
2764 % which handles more ligatures.}
2765 % \begin{macrocode}
2766 \let\do\@makeother \dospecials
2767 \obeylines \verbatim@font \@noligs
2768 \everypar \expandafter{\the\everypar \unpenalty}%
2769 }
2770 % \end{macrocode}
2771 % \end{macro}
2772 %
2773 % \begin{macro}{\check@percent}
2774 % Finally we define |\check@percent|. Since this must compare a
2775 % character with a percent sign we must first (locally) change
2776 % percent's |\catcode| so that it is seen by \TeX. The definition
2777 % itself is nearly trivial: grab the following character, check if
2778 % it is a |%|, and insert it again if not. At the end of the
2779 % \env{verbatim} environment this macro will peek at the next
2780 % input line. In that case the argument to |\check@percent| might
2781 % be a |\par| or a macro with arguments. Therefore we make the
2782 % definition |\long| (|\par| allowed) and use the normal |\next|
2783 % mechanism to reinsert the argument after the |\fi| if necessary.
2784 % \changes{v1.5i}{1989/06/07}{Definition changed to `long'}
2785 % \changes{v1.5i}{1989/06/07}{Macro \cs{next} used to guard against
2786 % macro with arguments}
2787 % There is a subtle problem here, the equal sign between
2788 % |\next| and |#1| is actually necessary. Do you see why?
2789 % The omission of this token once caused a funny error.
2790 % \changes{v1.5u}{1989/11/14}{equal sign added.}
2791 % \begin{macrocode}
2792 {\catcode`\%=12
2793 \long\gdef\check@percent#1{\ifx #1%\let\next\@empty \else
2794 \let\next=#1\fi \next}}
2795 % \end{macrocode}
2796 % \end{macro}
2797 %
2798 %
2799 % In the early versions of the package it also redefined \cs{verb}
2800 % because that didn't include the useful test for \enquote{newline} in
2801 % the verbatim text. This is nowadays part of \LaTeX{} so we do not
2802 % redefine it any longer (the original code is still kept in the file
2803 % after \cs{endinput} to keep the long history intact).
2804 %
2805 % \begin{tcounter}{\macro@cnt}
2806 % \label{page:macro} The \env{macro} environment is implemented as
2807 % a \env{trivlist} environment, whereby in order that the macro
2808 % names can be placed under one another in the margin
2809 % (corresponding to the macro's nesting depth), the macro
2810 % |\makelabel| must be altered. In order to store the nesting
2811 % depth, we use a counter. We also need a counter to count the
2812 % number of nested \env{macro} environments.
2813 % \changes{v1.5k}{1989/08/17}{Fix for save stack problem.}
2814 % \changes{v1.9k}{1994/02/22}{Fix probably no longer necessary}
2815 % \begin{macrocode}
2816 \newcount\macro@cnt \macro@cnt=0
2817 % \end{macrocode}
2818 % \end{tcounter}
2819 %
2820 %
2821 % \begin{lskip}{\MacroTopsep}
2822 % Here is the default value for the |\MacroTopsep| parameter
2823 % used above.
2824 % \begin{macrocode}
2825 \newskip\MacroTopsep \MacroTopsep = 7pt plus 2pt minus 2pt
2826 % \end{macrocode}
2827 % \end{lskip}
2828 %
2829 %
2830 %
2831 %
2832 %
2833 % \subsection{Formatting the margin}
2834 %
2835 % The following three macros should be user definable.
2836 % Therefore we define those macros only if they have not already
2837 % been defined.
2838 %
2839 %
2840 % \subsection{Creating index entries by scanning `macrocode'}
2841 %
2842 % The following macros ensure that index entries are created for each
2843 % occurrence of a \TeX-like command (something starting with
2844 % `|\|') providing indexing has been turned on with |\PageIndex|
2845 % or |\CodelineIndex|. With the default definitions of
2846 % |\specialMainMacroIndex|, etc., the index file generated is
2847 % intended to be processed by Chen's \prg{makeindex} program
2848 % \cite{art:Chen}.
2849 %
2850 %
2851 % Of course, in {\em this\/} package file itself we've sometimes had to
2852 % make \verb+|+ take the r\^ole of \TeX's escape character to
2853 % introduce command names at places where |\| has to belong to
2854 % some other category. Therefore, we may also need to recognize
2855 % \verb+|+ as the introducer for a command when setting the text
2856 % inside the \env{macrocode} environment. Other users may have the
2857 % need to make similar reassignments for their macros.
2858 %
2859 %
2860 % \begin{imacro}{\SpecialEscapechar}\label{sect:specialescapechar}
2861 % \begin{macro}{\active@escape@char}
2862 % \begin{macro}{\special@escape@char}
2863 % The macro |\SpecialEscapechar| is used to denote a special escape
2864 % character for the next \env{macrocode} environment. It has one
2865 % argument---the new escape character given as a `single-letter'
2866 % control sequence. Its main purpose is defining
2867 % |\special@escape@char| to produce the chosen escape character
2868 % |\catcode|$\,$d to 12 and |\active@escape@char| to produce the
2869 % same character but with |\catcode| 13.
2870 %
2871 % The macro |\special@escape@char| is used to {\em print\/}
2872 % the escape character while |\active@escape@char| is needed
2873 % in the definition of |\init@crossref| to start the scanning
2874 % mechanism.
2875 %
2876 % In the definition of |\SpecialEscapechar| we need an
2877 % arbitrary character with |\catcode| 13. We use `\~{}' and
2878 % ensure that it is active. The |\begingroup| is used to make
2879 % a possible change local to the expansion of
2880 % |\SpecialEscapechar|.
2881 % \changes{v1.7g}{1992/06/19}{Making tilde active moved outside
2882 % definition}
2883 % \begin{macrocode}
2884 \begingroup
2885 \catcode`\~\active
2886 \gdef\SpecialEscapechar#1{%
2887 \begingroup
2888 % \end{macrocode}
2889 % Now we are ready for the definition of
2890 % |\active@escape@char|. It's a little tricky: we first
2891 % define locally the uppercase code of `\~{}' to be the new escape
2892 % character.
2893 % \begin{macrocode}
2894 \uccode`\~`#1%
2895 % \end{macrocode}
2896 % Around the definition of |\active@escape@char| we place an
2897 % |\uppercase| command. Recall that the expansion of
2898 % |\uppercase| changes characters according to their
2899 % |\uccode|, but leaves their |\catcode|$\,$s untouched
2900 % (cf.\ \TeX{}book page 41).
2901 % \begin{macrocode}
2902 \uppercase{\gdef\active@escape@char{~}}%
2903 % \end{macrocode}
2904 % The definition of |\special@escape@char| is easier, we use
2905 % |\string| to |\catcode| the argument of
2906 % |\SpecialEscapechar| to 12 and suppress the preceding
2907 % |\escapechar|.
2908 % \begin{macrocode}
2909 \escapechar\m@ne \xdef\special@escape@char{\string#1}%
2910 % \end{macrocode}
2911 % Now we close the group and end the definition: the value of
2912 % |\escapechar| as well as the |\uccode| and
2913 % |\catcode| of `\~{}' will be restored.
2914 % \begin{macrocode}
2915 \endgroup}
2916 \endgroup
2917 % \end{macrocode}
2918 % \end{macro}
2919 % \end{macro}
2920 % \end{imacro}
2921 %
2922 %
2923 %
2924 %
2925 % \begin{macro}{\init@crossref}
2926 % The replacement text of |\init@crossref| should fulfill the
2927 % following tasks:
2928 % \begin{itemize}
2929 % \parindent4em
2930 % \item[(1)]
2931 % |\catcode| all characters used in macro names to
2932 % 11 (i.e., `letter').
2933 % \item[(2)]
2934 % |\catcode| the `|\|' character to 13
2935 % (i.e., `active').
2936 % \item[(3a)]
2937 % |\let| the `|\|' equal |\scan@macro|
2938 % (i.e., start the macro scanning mechanism) if there is
2939 % no special escape character (i.e., the
2940 % |\special@escape@char| is `|\|').
2941 % \item[(3b)]
2942 % Otherwise |\let| it equal |\bslash|, i.e.\
2943 % produce a printable |\|.
2944 % \item[(4)]
2945 % Make the \meta{special escape character} active.
2946 % \item[(5)]
2947 % |\let| the active version of the special escape
2948 % character
2949 % (i.e., the expansion of |\active@escape@char|) equal
2950 % |\scan@macro|.
2951 % \end{itemize}
2952 % The reader might ask why we bother to |\catcode| the
2953 % `|\|' first to 12 (at the end of |\macro@code|) then
2954 % re-|\catcode| it to 13 in order to produce a $|\|_{12}$
2955 % in case (3b) above. This is done because we have to ensure that
2956 % `|\|' has |\catcode| 13 within the \env{macrocode}
2957 % environment. Otherwise the delimiter for the argument of
2958 % |\xmacro@code| would not be found (parameter matching
2959 % depends on |\catcode|$\,$s).
2960 %
2961 % Therefore we first re-|\catcode| some characters.
2962 % \begin{macrocode}
2963 \begingroup \catcode`\|=\z@ \catcode`\\=\active
2964 % \end{macrocode}
2965 % We carry out tasks (2) and (3b) first.
2966 % \SpecialEscapechar\|
2967 % \begin{macrocode}
2968 |gdef|init@crossref{|catcode`|\|active |let\|bslash
2969 % \end{macrocode}
2970 % Because of the popularity of the `|@|' character as a
2971 % `letter' in macros, we normally have to change its
2972 % |\catcode| here, and thus fulfill task (1). But the macro
2973 % designer might use other characters as private letters as well,
2974 % so we use a macro to do the |\catcode| switching.
2975 % \SpecialEscapechar\|
2976 % \begin{macrocode}
2977 |MakePrivateLetters
2978 % \end{macrocode}
2979 % Now we |\catcode| the special escape character to 13 and
2980 % |\let| it equal |\scan@macro|, i.e., fulfill tasks (4)
2981 % and (5). Note the use of |\expandafter| to insert the chosen
2982 % escape character saved in |\special@escape@char| and
2983 % |\active@escape@char|.
2984 % \SpecialEscapechar\|
2985 % \begin{macrocode}
2986 |catcode|expandafter`|special@escape@char|active
2987 |expandafter|let|active@escape@char|scan@macro}
2988 |endgroup
2989 % \end{macrocode}
2990 % If there is no special escape character, i.e., if
2991 % |\SpecialEscapechar| is |\\|, the second last line will
2992 % overwrite the previous definition of $|\|_{13}$. In this
2993 % way all tasks are fulfilled.
2994 %
2995 % For happy documenting we give default values to
2996 % |\special@escape@char| and |\active@escape@char| with
2997 % the following line:
2998 % \begin{macrocode}
2999 \SpecialEscapechar{\\}
3000 % \end{macrocode}
3001 % \end{macro}
3002 %
3003 %
3004 %
3005 % \begin{imacro}{\MakePrivateLetters}
3006 % Here is the default definition of this command, which makes just
3007 % the |@| into a letter. The user may change it if he/she
3008 % needs more or other characters masquerading as letters.
3009 % \begin{macrocode}
3010 \@ifundefined{MakePrivateLetters}
3011 {\let\MakePrivateLetters\makeatletter}{}
3012 % \end{macrocode}
3013 % \end{imacro}
3014 %
3015 % \begin{macro}{\close@crossref}
3016 % At the end of a cross-referencing part we prepare ourselves for
3017 % the next one by setting the escape character to `|\|'.
3018 % \begin{macrocode}
3019 \def\close@crossref{\SpecialEscapechar\\}
3020 % \end{macrocode}
3021 % \end{macro}
3022 %
3023 %
3024 %
3025 %
3026 % \subsection{Macros for scanning macro names}
3027 %
3028 % \begin{macro}{\scan@macro}
3029 % \changes{v1.5k}{1989/09/04}{Support for checksum added.}
3030 % \begin{macro}{\macro@namepart}
3031 % The |\init@crossref| will have made |\active| our
3032 % |\special@escape@char|, so that each
3033 % |\active@escape@char| will invoke |\scan@macro| when
3034 % within the \env{macrocode} environment. By this means, we can
3035 % automatically add index entries for every \TeX-like command which
3036 % is met whilst setting (in verbatim) the contents of
3037 % \env{macrocode} environments.
3038 % \begin{macrocode}
3039 \def\scan@macro{%
3040 % \end{macrocode}
3041 % First we output the character which triggered this macro. Its
3042 % version |\catcode|$\,$d to 12 is saved in
3043 % |\special@escape@char|. We also call |\step@checksum|
3044 % to generate later on a proper check-sum (see section
3045 % \ref{sec:checksum} for details).
3046 % \begin{macrocode}
3047 \special@escape@char
3048 \step@checksum
3049 % \end{macrocode}
3050 % If the \env{macrocode} environment contains, for example, the
3051 % command |\\|, the second |\| should not start the
3052 % scanning mechanism. Therefore we use a switch to decide if
3053 % scanning of macro names is allowed.
3054 % \begin{macrocode}
3055 \ifscan@allowed
3056 % \end{macrocode}
3057 % The macro assembles the letters forming a \TeX\ command in
3058 % |\macro@namepart| so this is initially cleared; we then set
3059 % |\next| to the \textit{first\/} character following the
3060 % |\| and call |\macro@switch| to determine whether that
3061 % character is a letter or not.
3062 % \begin{macrocode}
3063 \let\macro@namepart\@empty
3064 \def\next{\futurelet\next\macro@switch}%
3065 % \end{macrocode}
3066 % As you recognize, we actually did something else, because we have
3067 % to defer the |\futurelet| call until after the final
3068 % |\fi|. If, on the other hand, the scanning is disabled we
3069 % simply |\let| |\next| equal `empty'.
3070 % \begin{macrocode}
3071 \else \let\next\@empty \fi
3072 % \end{macrocode}
3073 % Now we invoke |\next| to carry out what's needed.
3074 % \begin{macrocode}
3075 \next}
3076 % \end{macrocode}
3077 % \end{macro}
3078 % \end{macro}
3079 %
3080 %
3081 %
3082 % \begin{imacro}{\EnableCrossrefs}
3083 % \begin{imacro}{\DisableCrossrefs}
3084 % At this point we might define two macros which allow the user to
3085 % disable or enable the cross-referencing mechanism. Processing of
3086 % files will be faster if only main index entries are generated
3087 % (i.e., if |\DisableCrossrefs| is in force).
3088 % \begin{macrocode}
3089 \def\DisableCrossrefs{\@bsphack\scan@allowedfalse\@esphack}
3090 % \end{macrocode}
3091 % The macro |\EnableCrossrefs| will also disable any
3092 % |\DisableCrossrefs| command encountered afterwards.
3093 % \begin{macrocode}
3094 \def\EnableCrossrefs{\@bsphack\scan@allowedtrue
3095 \def\DisableCrossrefs{\@bsphack\@esphack}\@esphack}
3096 % \end{macrocode}
3097 % \end{imacro}
3098 % \end{imacro}
3099 %
3100 %
3101 %
3102 %
3103 % \begin{macro}{\macro@switch}
3104 % Now that we have the character which follows the escape character
3105 % (in |\next|), we can determine whether it's a `letter'
3106 % (which probably includes |@|).
3107 %
3108 % If it is, we let |\next| invoke a macro which assembles the
3109 % full command name.
3110 % \begin{macrocode}
3111 \def\macro@switch{\ifcat\noexpand\next a%
3112 \let\next\macro@name
3113 % \end{macrocode}
3114 % Otherwise, we have a `single-character' command name. For all
3115 % those single-character names, we use |\short@macro| to
3116 % process them into suitable index entries.
3117 % \begin{macrocode}
3118 \else \let\next\short@macro \fi
3119 % \end{macrocode}
3120 % Now that we know what macro to use to process the macro name, we
3121 % invoke it~\ldots
3122 % \begin{macrocode}
3123 \next}
3124 % \end{macrocode}
3125 % \end{macro}
3126 %
3127 %
3128 % \begin{macro}{\short@macro}
3129 %
3130 % \changes{v1.5c}{1989/04/27}{Corrected bad bug by putting the
3131 % scan@allowedfalse macro before printing
3132 % the argument.}
3133 % \changes{v1.7a}{1992/03/10}{Ensure character stored in
3134 % \cs{macro@namepart} as `letter' so index exclusion works.}
3135 % This macro will be invoked (with a single character as parameter)
3136 % when a single-character macro name has been spotted whilst
3137 % scanning within the \env{macrocode} environment.
3138 %
3139 % First we take a look at the |\index@excludelist| to see
3140 % whether this macro name should produce an index entry. This is
3141 % done by the |\ifnot@excluded| macro which assumes that the
3142 % macro name is saved in |\macro@namepart|. The character
3143 % mustn't be stored with a special category code or exclusion from
3144 % the index won't work, so we use \cs{string} to normalize it
3145 % the same way it is done in \cs{DoNotIndex}, i.e. everything ends up
3146 % catcode 12 except for the space character.
3147 % \changes{v2.0e}{1998/12/28}{Correctly use the case-changing trick.}
3148 % \changes{v3.0l}{2022/11/03}{No longer using the case-changing trick.}
3149 % \begin{macrocode}
3150 \def\short@macro#1{%
3151 \edef\macro@namepart{\string#1}%
3152 % \end{macrocode}
3153 % Any indexing is then delegated to
3154 % |\maybe@index@short@macro|. Depending on the actual character seen,
3155 % this macro has to do different things, which is why we keep it separate from
3156 % |\maybe@index@macro| to avoid the special tests in the more
3157 % common case of a multi-letter macro name.
3158 % \begin{macrocode}
3159 \maybe@index@short@macro\macro@namepart
3160 % \end{macrocode}
3161 % Then we disable the cross-referencing mechanism with
3162 % |\scan@allowedfalse| and print the actual character. The
3163 % index entry was generated first to ensure that no page break
3164 % intervenes (recall that a |^^M| will start a new line).
3165 % \begin{macrocode}
3166 \scan@allowedfalse#1%
3167 % \end{macrocode}
3168 % After typesetting the character we can safely enable the
3169 % cross-referencing feature again. Note that this macro won't be
3170 % called (since |\macro@switch| won't be called) if
3171 % cross-referencing is globally disabled.
3172 % \begin{macrocode}
3173 \scan@allowedtrue }
3174 % \end{macrocode}
3175 % \end{macro}
3176 %
3177 %
3178 %
3179 % \begin{macro}{\macro@name}
3180 % We now come to the macro which assembles command names which
3181 % consist of one or more `letters' (which might well include
3182 % |@| symbols, or anything else which has a |\catcode| of
3183 % 11).
3184 %
3185 % To do this we add the `letter' to the existing definition of
3186 % |\macro@namepart| (which you will recall was originally set
3187 % to |\@empty|).
3188 % \begin{macrocode}
3189 \def\macro@name#1{\edef\macro@namepart{\macro@namepart#1}%
3190 % \end{macrocode}
3191 % Then we grab hold of the {\em next\/} single character and let
3192 % |\more@macroname| determine whether it belongs to the letter
3193 % string forming the command name or is a `non-letter'.
3194 % \begin{macrocode}
3195 \futurelet\next\more@macroname}
3196 % \end{macrocode}
3197 % \end{macro}
3198 %
3199 %
3200 %
3201 %
3202 %
3203 % \begin{macro}{\more@macroname}
3204 %
3205 % This causes another call of |\macro@name| to add in the next
3206 % character, if it is indeed a `letter'.
3207 % \begin{macrocode}
3208 \def\more@macroname{\ifcat\noexpand\next a%
3209 \let\next\macro@name
3210 % \end{macrocode}
3211 % Otherwise, it finishes off the index entry by invoking
3212 % |\macro@finish|.
3213 % \begin{macrocode}
3214 \else \let\next\macro@finish \fi
3215 % \end{macrocode}
3216 % Here's where we invoke whatever macro was |\let| equal to
3217 % |\next|.
3218 % \begin{macrocode}
3219 \next}
3220 % \end{macrocode}
3221 % \end{macro}
3222 %
3223 %
3224 %
3225 %
3226 %
3227 % \begin{macro}{\macro@finish}
3228 % When we've assembled the full `letter'-string which forms the
3229 % command name, we set the characters forming the entire command
3230 % name, and generate an appropriate |\index| command (provided
3231 % the command name is not on the list of exclusions). The
3232 % `|\|' is already typeset; therefore we only have to output
3233 % all `letters' saved in |\macro@namepart|.
3234 % \begin{macrocode}
3235 \def\macro@finish{%
3236 \macro@namepart
3237 % \end{macrocode}
3238 % Then we call |\ifnot@excluded| to decide whether we have to
3239 % produce an index entry. The construction with |\@tempa| is
3240 % needed because we want the expansion of |\macro@namepart| in
3241 % the |\index| command.\footnote{The \texttt{\bslash index}
3242 % command will expand its argument in the \texttt{\bslash output}
3243 % routine. At this time \texttt{\bslash macro@namepart} might have a
3244 % new value.}
3245 % \begin{macrocode}
3246 % \ifnot@excluded
3247 % \edef\@tempa{\noexpand\SpecialIndex{\bslash\macro@namepart}}%
3248 % \@tempa \fi
3249 \maybe@index@macro \macro@namepart
3250 }
3251 % \end{macrocode}
3252 % \end{macro}
3253 %
3254 %
3255 %
3256 %
3257 %
3258 % \subsection[The index exclude list]{The index exclude
3259 % list\footnotemark}
3260 % \footnotetext{Info: the incomplete commentary on
3261 % \texttt{\bslash DoNotIndex} and the macros it calls
3262 % was written by Dave Love.}
3263 %
3264 %
3265 %
3266
3267 % \def\MakePrivateLetters{%
3268 % \makeatletter
3269 % \catcode`\_11
3270 % \catcode`\:11}
3271 %
3272 %
3273 % The following part of the code is a new implementation using the
3274 % \LaTeX3 programming layer as the constructs and types
3275 % provided therein are making programming much easier. Over time I
3276 % will probably replace the rest of that \DOC code too.
3277 % \begin{macrocode}
3278 \ExplSyntaxOn
3279 % \end{macrocode}
3280 %
3281 %
3282 % \DescribeMacro\l__doc_donotindex_seq
3283 % Local sequence that holds names (as strings) of commands that
3284 % should not be indexed. Within a \DOC element environment that
3285 % element is placed into the sequence so that it isn't
3286 % unnecessarily index within that part of the code. As the sequence
3287 % is local it will revert this setting at the end of the
3288 % environment so that the command is indexed elsewhere (unless it
3289 % is generally disabled from indexing).
3290 %
3291 % \DescribeMacro\g__doc_idxtype_prop
3292 % Global property list that holds for all commands that are special
3293 % \DOC elements the type of the element. The key is the command
3294 % name without backslash and the value is \DOC element type
3295 % identifier, e.g., |\texttt{Length}| for length registers if that
3296 % type has been set up. \DOC only indexes commands, that is things
3297 % starting with an escape character, i.e., a backslash (by
3298 % default). \DOC elements that do not start with an escape
3299 % character, e.g., environments are not identified when parsing
3300 % code so that aren't indexed automatically inside. Thus for them
3301 % there is no point in keeping them in that property list.
3302 %
3303 % \DescribeMacro{\doc_dont_index:n}
3304 % \DescribeInterfaceMacro{\DoNotIndex}
3305 % Takes a clist of commands (with backslash) as input and exclude
3306 % all of them from the index. User facing we make this available as
3307 % |\DoNotIndex|.
3308 %
3309 %
3310 % \DescribeInterfaceMacro\ShowIndexingState
3311 % Displays the current list of the exclude index list in a fairly
3312 % low-level form.
3313 %
3314 % \DescribeInterfaceMacro\RecordIndexType
3315 % This command takes two arguments: a command (with escape char)
3316 % and its type (i.e., first mandatory
3317 % argument of a |\NewDocElement| declaration). If |#1| should not be
3318 % included from the index, then the data is used to record that
3319 % this command is of this type. The information is then used to
3320 % generate appropriate index entries. Obviously, index entries
3321 % generated earlier will be listing the wrong type. Therefore this
3322 % information is also placed into the \texttt{.aux} file so that it
3323 % will be available at the beginning of further runs.
3324 %
3325 % This command is internally executed as part of any \DOC element
3326 % environment so it only needs to be explicitly given if for some
3327 % reason a command with a special type has no corresponding environment.
3328 %
3329 %
3330 %
3331 %
3332 % \begin{macro}{\l__doc_donotindex_seq}
3333 % \begin{macro}{\g__doc_idxtype_prop}
3334 % Declarations.
3335 % \begin{macrocode}
3336 \seq_new:N \l__doc_donotindex_seq
3337 \prop_new:N \g__doc_idxtype_prop
3338 % \end{macrocode}
3339 % \end{macro}
3340 % \end{macro}
3341 %
3342 % ^^A --------------------------------------------------
3343 %
3344 %
3345 % \begin{macro}{\__doc_trace:x}
3346 % A helper for tracing\ldots
3347 % \begin{macrocode}
3348 \cs_new:Npn\__doc_trace:x {
3349 \legacy_if:nTF{ doc@debugshow }{ \iow_term:x } { \use_none:n }
3350 }
3351 % \end{macrocode}
3352 % \end{macro}
3353 %
3354 %
3355 % ^^A --------------------------------------------------
3356 %
3357 % \begin{macro}{\doc_dont_index:n}
3358 % \begin{macro}{\__doc_dont_index:n}
3359 % \begin{macro}{\__doc_dont_index_aux:n}
3360 %
3361 % Parses the argument a clist of commands with
3362 % |\MakePrivateLetters| in force (so that special characters are
3363 % recognized as being part of command names) and puts each command
3364 % without is backslash as a string into the sequence
3365 % |\l__doc_donotindex_seq|.
3366 % \begin{macrocode}
3367 \cs_new:Npn \doc_dont_index:n {
3368 \group_begin:
3369 \MakePrivateLetters
3370 \__doc_dont_index:n
3371 }
3372 % \end{macrocode}
3373 %
3374 % \begin{macrocode}
3375 \cs_new:Npn \__doc_dont_index:n #1 {
3376 \group_end:
3377 % \end{macrocode}
3378 %
3379 % \begin{macrocode}
3380 \__doc_trace:x{Disable~ indexing~ for~ '\tl_to_str:n{#1}' }
3381 % \end{macrocode}
3382 % Adding the commands to the |\l__doc_donotindex_seq| sequence is
3383 % done by mapping the function |\__doc_dont_index_aux:n| on each
3384 % element in the clist.
3385 % \begin{macrocode}
3386 \clist_map_function:nN {#1} \__doc_dont_index_aux:n
3387 }
3388 % \end{macrocode}
3389 % We record each command by using its name as a string.
3390 % This means more tokens in the sequence but it allows
3391 % to compare names not ``action'' which is important as different
3392 % commands may have the same meaning (e.g., they may not be defined
3393 % at all),
3394 % \begin{macrocode}
3395 \cs_new:Npn \__doc_dont_index_aux:n #1 {
3396 \seq_put_right:Nx \l__doc_donotindex_seq {\expandafter\@gobble \string#1}
3397 }
3398 % \end{macrocode}
3399 % \end{macro}
3400 % \end{macro}
3401 % \end{macro}
3402 %
3403 % \begin{macro}{\DoNotIndex}
3404 % The document-level interface
3405 % \begin{macrocode}
3406 \cs_set_eq:NN \DoNotIndex \doc_dont_index:n
3407 % \end{macrocode}
3408 % \end{macro}
3409 %
3410 %
3411 % \begin{macro}{\ShowIndexingState}
3412 % Some tracing information that may be helpful.
3413 % \begin{macrocode}
3414 \def \ShowIndexingState {
3415 \__doc_trace:x{Show~ doc~ indexing~ state:}
3416 \seq_show:N \l__doc_donotindex_seq
3417 \prop_show:N \g__doc_idxtype_prop
3418 }
3419 % \end{macrocode}
3420 % \end{macro}
3421
3422
3423
3424 % ^^A --------------------------------------------------
3425 %
3426 %
3427 % \begin{macro}{\__doc_idxtype_put:Nn}
3428 % \begin{imacro}{\RecordIndexType}
3429 % \fmi{Change name of interface command!}
3430 % \begin{macro}{\RecordIndexTypeAux}
3431 % This is the internal form for |\RecordIndexType|. The first
3432 % argument is turned into a string and the rest of the processing
3433 % is then done by |\__doc_idxtype_put:nn|
3434 % \begin{macrocode}
3435 \cs_new:Npn \__doc_idxtype_put:Nn #1#2 {
3436 \exp_args:Nx \__doc_idxtype_put:nn { \cs_to_str:N #1 }{#2}
3437 % \end{macrocode}
3438 % We also make an entry in the \texttt{.aux} file so that this
3439 % declaration becomes immediately available in the next
3440 % run. However, for this we aren't reusing |\__doc_idxtype_put:N|
3441 % (a.k.a.\ |\RecordIndexType|) since that would result in doubling
3442 % such lines each time the document is run. Instead we use
3443 % |\RecordIndexTypeAux| which is only updating the data structures
3444 % without writing to the \texttt{.aux} file.
3445 % \begin{macrocode}
3446 \protected@write\@auxout{}
3447 {\string\RecordIndexTypeAux {\string#1 }{#2} }
3448 }
3449 % \end{macrocode}
3450 % When we execute this code from the \texttt{.aux} we better not
3451 % generate a new line in the \texttt{.aux}. Otherwise those would
3452 % cumulate over time.
3453 % \begin{macrocode}
3454 \cs_new:Npn \RecordIndexTypeAux #1#2 {
3455 \exp_args:Nx \__doc_idxtype_put:nn { \cs_to_str:N #1 }{#2}
3456 }
3457 % \end{macrocode}
3458 % Similarly, when the \texttt{.aux} is read at the end of the run we
3459 % should disable that command to avoid unnecessary processing.
3460 % \begin{macrocode}
3461 \AtEndDocument{
3462 \cs_set_eq:NN \RecordIndexTypeAux \use_none:nn
3463 }
3464 % \end{macrocode}
3465 % Finally, we provide the user-level interface
3466 % \begin{macrocode}
3467 \cs_set_eq:NN \RecordIndexType \__doc_idxtype_put:Nn
3468 % \end{macrocode}
3469 % \end{macro}
3470 % \end{imacro}
3471 % \end{macro}
3472 %
3473 %
3474 % \begin{macro}{\__doc_idxtype_put_scan:nn}
3475 % When we want to record an index type for a scanned name we can't
3476 % turn that into a csname and then call |\__doc_idxtype_put:Nn|
3477 % because turning it into a csname may change the meaning of the
3478 % name from ``undefined'' to |\relax|. Got bitten by that when
3479 % processing the kernel sources containing |\@undefined| within the
3480 % code: suddenly that wasn't undefined any longer.
3481 % So here is another version that works only on characters as
3482 % input. As we don't know whether or not they are proper strings
3483 % already we first make sure that this is the case.
3484 % \begin{macrocode}
3485 \cs_new:Npn \__doc_idxtype_put_scan:nn #1#2 {
3486 \exp_args:Nf \__doc_idxtype_put:nn { \tl_to_str:n {#1} }{#2}
3487 % \end{macrocode}
3488 % In this case we also have to append a backslash when writing to
3489 % the \texttt{.aux} file.
3490 % \begin{macrocode}
3491 \protected@write\@auxout{}
3492 {\string\RecordIndexTypeAux {\bslash #1 }{#2} }
3493 }
3494 % \end{macrocode}
3495 % \end{macro}
3496 %
3497 % \begin{macro}{\__doc_idxtype_put_scan:on}
3498 % And here is the one we really need since the characters are
3499 % stored in some macro.
3500 % \begin{macrocode}
3501 \cs_generate_variant:Nn \__doc_idxtype_put_scan:nn {o}
3502 % \end{macrocode}
3503 % \end{macro}
3504 %
3505 % \begin{macro}{\record@index@type@save}
3506 % And here is the interface to the rest of the code:
3507 % \begin{macrocode}
3508 \cs_set_eq:NN \record@index@type@save \__doc_idxtype_put_scan:on
3509 % \end{macrocode}
3510 % \end{macro}
3511 %
3512 %
3513 % \begin{macro}{\__doc_idxtype_put:nn}
3514 % This internal command takes two arguments: a command name as
3515 % string (no backslash) and its type (i.e., first mandatory
3516 % argument of a |\NewDocElement| declaration). If |#1| is not in
3517 % |\l__doc_donotindex_seq| it will add this data to the property
3518 % list |\g__doc_idxtype_prop| using |#1| as key and |#2| as its
3519 % value. If the key already exist its value will be overwritten. If
3520 % the command is later marked for exclusion from the index the
3521 % property list setting remains unchanged but as long as no index
3522 % is produced for the command it will not be consulted.
3523 %
3524 % Note: the command assumes that |#1| is already in string form
3525 % \begin{macrocode}
3526 \cs_new:Npn \__doc_idxtype_put:nn #1#2 {
3527 % \end{macrocode}
3528 % No mystery here: if the command is not marked for exclusion from
3529 % the index add the property. The extra |\tl_to_str:n| is a safety
3530 % measure in case the input wasn't already in that form (should
3531 % only be the case with broken input but \ldots)
3532 % \begin{macrocode}
3533 \exp_args:NNf
3534 \seq_if_in:NnTF \l__doc_donotindex_seq {\tl_to_str:n{#1}}
3535 % \end{macrocode}
3536 % Some tracing info \ldots{}
3537 % \begin{macrocode}
3538 {
3539 \__doc_trace:x{Not~ recording~ index~ type~ for~ '\bslash #1' }
3540 }
3541 {
3542 \__doc_trace:x{Recording~ index~ type~ for~ '\bslash #1' ~ as~ #2 }
3543 % \end{macrocode}
3544 % Stick the data into the property list:
3545 % \begin{macrocode}
3546 \prop_gput:Nnn \g__doc_idxtype_prop {#1}{#2}
3547 }
3548 }
3549 % \end{macrocode}
3550 % \end{macro}
3551 %
3552 % ^^A --------------------------------------------------
3553 %
3554 %
3555 % \begin{macro}{\exp_args:co}
3556 % A helper: construct a function and call it with its first argument
3557 % expanded once:
3558 % \begin{macrocode}
3559 \cs_new:Npn \exp_args:co #1#2
3560 { \cs:w #1 \exp_after:wN \cs_end:\exp_after:wN {#2} }
3561 % \end{macrocode}
3562 % \end{macro}
3563 %
3564 % \begin{macro}{\tl_to_str:o}
3565 % Another helper: take some token list variable, expand it and turn
3566 % it into a string.
3567 % \begin{macrocode}
3568 \cs_generate_variant:Nn \tl_to_str:n {o}
3569 % \end{macrocode}
3570 % \end{macro}
3571 %
3572 %
3573 %
3574 % ^^A --------------------------------------------------
3575 %
3576 %
3577 %
3578 % \DescribeMacro\maybe@index@macro
3579 %
3580 % This takes a macro name (without backslash) as parsed within a
3581 % \env{macrocode} environment and checks if it should get indexed
3582 % (i.e., is not on the exclude list) and if so how (i.e., gets it
3583 % index type property and makes the right choice depending on that.
3584 %
3585
3586
3587 % \begin{macro}{\maybe@index@macro}
3588 % \begin{macro}{\__doc_maybe_index:o}
3589 % We first make sure that the argument is really a string (so that
3590 % we have a defined situation) and then
3591 % pass it on to |\__doc_maybe_index_aux:nN| to do the work.
3592 % The second argument defines the indexing operation
3593 % \cs{SpecialIndex} for multi-letter macros and below
3594 % \cs{SpecialShortIndex} for single character macros.
3595 % \begin{macrocode}
3596 \cs_new:Npn \__doc_maybe_index:o #1 {
3597 \exp_args:Nf \__doc_maybe_index_aux:nN { \tl_to_str:o {#1} }
3598 \SpecialIndex
3599 }
3600 % \end{macrocode}
3601 % And here is what we call it in the older non-expl3 code:
3602 % \begin{macrocode}
3603 \cs_set_eq:NN \maybe@index@macro \__doc_maybe_index:o
3604 % \end{macrocode}
3605 % \end{macro}
3606 % \end{macro}
3607 %
3608 %
3609 % \begin{macro}{\maybe@index@short@macro}
3610 % \begin{macro}{\__doc_maybe_index_short:o}
3611 % Single character macros are handled similarly but there the
3612 % indexing is done by \cs{SpecialShortIndex} and it is simpler
3613 % because we know that the argument contains a string token not letters.
3614 % \changes{v3.0l}{2022/11/03}{We know the argument expands to a single string token}
3615 % \begin{macrocode}
3616 \cs_new:Npn \__doc_maybe_index_short:o #1 {
3617 \exp_args:No \__doc_maybe_index_aux:nN #1
3618 \SpecialShortIndex
3619 }
3620 \cs_set_eq:NN \maybe@index@short@macro \__doc_maybe_index_short:o
3621 % \end{macrocode}
3622 % \end{macro}
3623 % \end{macro}
3624 %
3625 %
3626 %
3627 % \begin{macro}{\__doc_maybe_index_aux:nN}
3628 % Take a string (representing a macro without backslash) and make
3629 % the right choices with respect to indexing.
3630 % \begin{macrocode}
3631 \cs_new:Npn \__doc_maybe_index_aux:nN #1#2 {
3632 % \end{macrocode}
3633 % A bit of tracing:
3634 % \begin{macrocode}
3635 \__doc_trace:x{Searching~ for~ '\bslash #1'}
3636 % \end{macrocode}
3637 % If the name is on the exclude list do nothing.
3638 % \begin{macrocode}
3639 \seq_if_in:NnTF \l__doc_donotindex_seq {#1}
3640 % \end{macrocode}
3641 %
3642 % \begin{macrocode}
3643 {
3644 \__doc_trace:x{Not~ indexing~ '\bslash #1' }
3645 }
3646 % \end{macrocode}
3647 % Otherwise check if this name has an index type property attached
3648 % to it.
3649 % \begin{macrocode}
3650 {
3651 \prop_get:NnNTF \g__doc_idxtype_prop {#1} \l__doc_idxtype_tl
3652 % \end{macrocode}
3653 % If so construct and execute
3654 % |\Code|\meta{idxtype}|Index|\footnote{I guess this should really
3655 % be an internal name not a user-level one.} which is done inside
3656 % |\__doc_maybe_index_aux|
3657 % \begin{macrocode}
3658 {
3659 \exp_args:Ncno \__doc_maybe_index_aux:Nnn
3660 { Code \tl_use:N \l__doc_idxtype_tl Index }
3661 {code} {\bslash #1}
3662 }
3663 % \end{macrocode}
3664 % Otherwise execute |\SpecialIndex| which is a short form for
3665 % |\CodeMacroIndex{code}| or execute \cs{SpecialShortIndex} which
3666 % deals with some special cases for single letter macros.
3667 % \begin{macrocode}
3668 {
3669 \__doc_trace:x{Indexing~ '\bslash #1'\space (\string #2)}
3670 \exp_args:No #2 {\bslash #1}
3671 }
3672 }
3673 }
3674 % \end{macrocode}
3675 % \end{macro}
3676 %
3677 %
3678 %
3679 % \begin{macro}{\SpecialShortIndex}
3680 % \fmi{to be documented; also needs cleaning up as it is a mix of
3681 % old and new right now}
3682 % \begin{macrocode}
3683 \cs_new:Npn \SpecialShortIndex #1 {
3684 \@SpecialIndexHelper@ #1\@nil
3685 \@bsphack
3686 \ifdoc@noindex \else
3687 \str_case_e:nnF {\@gtempa }
3688 {
3689 {\cs_to_str:N \^^M } {\def\reserved@a{ \string \space \actualchar }
3690 \def\reserved@b { \space }
3691 \let\reserved@c \@empty }
3692 % \end{macrocode}
3693 % With the fix for
3694 % \verb*=\ = we now have to look for a real space to handle that command sequence.
3695 % \changes{v3.0l}{2022/11/03}{look for the right token}
3696 % \begin{macrocode}
3697 { ~ } {\def\reserved@a{ \string \space \actualchar }
3698 \def\reserved@b { \space }
3699 \let\reserved@c \@empty }
3700 {\c_left_brace_str} { \def\reserved@a{ \bgroup \actualchar }
3701 \def\reserved@b { \c_left_brace_str }
3702 \def\reserved@c { \noexpand\iffalse
3703 \c_right_brace_str
3704 \noexpand\fi } }
3705 {\c_right_brace_str} { \def\reserved@a{ \egroup \actualchar
3706 \noexpand\iffalse
3707 \c_left_brace_str
3708 \noexpand\fi }
3709 \def\reserved@b { \c_right_brace_str }
3710 \let\reserved@c \@empty }
3711 % \end{macrocode}
3712 % The case of \cs{verbatimchar} is tricky. We can't stick it into
3713 % the normal \cs{verb} because we would then get something like
3714 % \verb=\verb+\++= which would comes out as ``\verb+\++'' instead
3715 % of \verb=\+=. So we use the \cs{verb} to only generate the
3716 % backslash and then use \cs{texttt} on the \cs{verbatimchar}
3717 % itself. However, that is not enough if we are unlucky and
3718 % somebody (like Will :-)) has used something like \verb=&= with a
3719 % special catcode for the \cs{verbatimchar}. We therefore also
3720 % apply \cs{string} to it when we read it back.
3721 % \begin{macrocode}
3722 {\verbatimchar} { \def\reserved@a{ \quotechar\verbatimchar
3723 \actualchar }
3724 \let\reserved@b \@empty
3725 \def\reserved@c
3726 { \string\texttt{\string\string\verbatimchar} } }
3727 }
3728 { \def\reserved@a {\quotechar \@gtempa \actualchar }
3729 \def\reserved@b {\quotechar \@gtempa }
3730 \let\reserved@c \@empty }
3731 \special@index {
3732 \reserved@a
3733 \string\verb
3734 \quotechar *\verbatimchar \quotechar \bslash
3735 \reserved@b
3736 \verbatimchar
3737 \reserved@c
3738 \encapchar code}
3739 \fi
3740 \@esphack
3741 }
3742 % \end{macrocode}
3743 % \end{macro}
3744
3745
3746
3747
3748
3749 % \begin{macro}{\__doc_maybe_index_aux:Nnn}
3750 % Execute the function passed on as first argument taking argument
3751 % 2 and 3 as input.
3752 % \begin{macrocode}
3753 \cs_new:Npn \__doc_maybe_index_aux:Nnn #1#2#3 {
3754 % \end{macrocode}
3755 % We have to be a little careful: as that function name is
3756 % constructed it may not actually exist (as constructions generate
3757 % |\relax| in \TeX{} in that case). In that case we raise an error,
3758 % otherwise we execute (with a little bit of tracing info):
3759 % \begin{macrocode}
3760 \cs_if_exist:NTF #1
3761 {
3762 \__doc_trace:x{Indexing~ '#3'\space as~
3763 \tl_use:N \l__doc_idxtype_tl }
3764 #1{#2}{#3}
3765 }
3766 {
3767 \PackageError{doc}{Doc~ element~
3768 '\tl_use:N \l__doc_idxtype_tl'~ unknown}%
3769
3770 {When~ using~ '\string\RecordIndexType'~ the~ type~ must~
3771 be~ known~\MessageBreak
3772 to~ the~ system,~ i.e.,~ declared~ via~
3773 '\string\NewDocElement'\MessageBreak
3774 before~ it~ can~ be~ used~ in~ indexing.}
3775 }
3776 }
3777 % \end{macrocode}
3778 % \end{macro}
3779 %
3780 %
3781 % Back to old style coding \ldots
3782 % \begin{macrocode}
3783 \ExplSyntaxOff
3784 % \end{macrocode}
3785 %
3786 %
3787 %
3788 % \subsection{Macros for generating index entries}
3789 %
3790 % Here we provide default definitions for the macros invoked to create
3791 % index entries; these are either invoked explicitly, or automatically
3792 % by |\scan@macro|. As already mentioned, the definitions given
3793 % here presuppose that the |.idx| file will be processed by
3794 % Chen's \prg{makeindex} program --- they may be redefined for use
3795 % with the user's favorite such program.
3796 %
3797 % To assist the reader in locating items in the index, all such
3798 % entries are sorted alphabetically {\em ignoring\/} the initial
3799 % `|\|'; this is achieved by issuing an |\index| command which
3800 % contains the `actual' operator for \prg{makeindex}. The default
3801 % value for the latter operator is `|@|', but the latter character is
3802 % so popular in \LaTeX\ package files that it is necessary to substitute
3803 % another character. This is indicated to \prg{makeindex} by means
3804 % of an `index style file'; the character selected for this function
3805 % is |=|, and therefore this character too must be specially treated
3806 % when it is met in a \TeX\ command. A suitable index style file is
3807 % provided amongst the supporting files for this style file in
3808 % \texttt{gind.ist} and is generated from this source by processing
3809 % with \texttt{docstrip} to extract the module \textbf{gind}. A
3810 % similar style file \texttt{gglo.ist} is supplied for sorting the
3811 % change information in the glossary file and is extracted as module
3812 % \textbf{gglo}. First of all we add some information to the front of
3813 % the \texttt{.ist} files. \changes{v1.7a}{1992/03/11}{glo.ist and
3814 % gind.ist now derivable from doc.dtx with docstrip.}
3815 % \begin{macrocode}
3816 %</package>
3817 %<+gind|gglo>%% This is a MAKEINDEX style file which should be used to
3818 %<+gind>%% generate the formatted index for use with the doc
3819 %<+gglo>%% generate the formatted change history for use with the doc
3820 %<+gind|gglo>%% package. The TeX commands used below are defined in
3821 %<+gind|gglo>%% doc.sty. The commands for MAKEINDEX like `level'
3822 %<+gind|gglo>%% `item_x1' are described in `` Makeindex, A General
3823 %<+gind|gglo>%% Purpose, Formatter-Independent Index Processor'' by
3824 %<+gind|gglo>%% Pehong Chen.
3825 %<+gind|gglo>
3826 % \end{macrocode}
3827 %
3828 % \begin{imacro}{\actualchar}
3829 % \begin{imacro}{\quotechar}
3830 % \begin{imacro}{\levelchar}
3831 % First come the definitions of |\actualchar|,
3832 % |\quotechar| and |\levelchar|. Note, that our defaults
3833 % are not the ones used by the \prg{makeindex} program without a
3834 % style file.
3835 % \begin{macrocode}
3836 %<*package>
3837 \@ifundefined{actualchar}{\def\actualchar{=}}{}
3838 \@ifundefined{quotechar}{\def\quotechar{!}}{}
3839 \@ifundefined{levelchar}{\def\levelchar{>}}{}
3840 %</package>
3841 %<+gind|gglo>actual '='
3842 %<+gind|gglo>quote '!'
3843 %<+gind|gglo>level '>'
3844 %<*package>
3845 % \end{macrocode}
3846 % \end{imacro}
3847 % \end{imacro}
3848 % \end{imacro}
3849 %
3850 %
3851 % \begin{imacro}{\encapchar}
3852 % The \prg{makeindex} default for the |\encapchar| isn't
3853 % changed.
3854 % \begin{macrocode}
3855 \@ifundefined{encapchar}{\def\encapchar{|}}{}
3856 % \end{macrocode}
3857 % \end{imacro}
3858 %
3859 %
3860 % \begin{imacro}{\verbatimchar}
3861 % We also need a special character to be used as a delimiter for
3862 % the |\verb*| command used in the definitions below.
3863 % \begin{macrocode}
3864 \@ifundefined{verbatimchar}{\def\verbatimchar{+}}{}
3865 % \end{macrocode}
3866 % \end{imacro}
3867 %
3868 %
3869 %
3870 % \begin{macro}{\@SpecialIndexHelper@}
3871 % \fmi{doc or drop}
3872 % \begin{macrocode}
3873 \begingroup
3874 \catcode`\|=0
3875 \catcode`\\=12
3876 % \end{macrocode}
3877 % \SpecialEscapechar\|
3878 % \begin{macrocode}
3879 |gdef|@SpecialIndexHelper@#1#2|@nil{%
3880 |if |noexpand#1\%
3881 |gdef|@gtempa{#2}%
3882 |else
3883 |begingroup
3884 |escapechar|m@ne
3885 |expandafter|gdef|expandafter|@gtempa|expandafter{|string#1#2}%
3886 |endgroup
3887 |fi}
3888 |endgroup
3889 % \end{macrocode}
3890 %
3891 % \end{macro}
3892 %
3893 %
3894 %
3895 % \begin{imacro}{\SortIndex}
3896 % This macro is used to generate the index entries for any
3897 % single-character command that |\scan@macro| encounters. The
3898 % first parameter specifies the lexical order for the character,
3899 % whilst the second gives the actual characters to be printed in
3900 % the entry. It can also be used directly to generate index entries
3901 % which differ in sort key and actual entry.
3902 % \begin{macrocode}
3903 \def\SortIndex#1#2{%
3904 \ifdoc@noindex\else
3905 \index{#1\actualchar#2}%
3906 \fi
3907 }
3908 % \end{macrocode}
3909 % \end{imacro}
3910 %
3911 %
3912 %
3913 %
3914 % \begin{imacro}{\LeftBraceIndex}
3915 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
3916 % \begin{imacro}{\RightBraceIndex}
3917 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)} These
3918 % two macros fix the problems with \prg{makeindex}. Note the
3919 % `hack' with \iffalse{-to get matching braces\fi |\iffalse}\fi|
3920 % to satisfy both \TeX{} and the
3921 % \prg{makeindex} program. When this is written to the
3922 % \texttt{.idx} file \TeX{} will see both braces (so we get a
3923 % balanced text). \prg{makeindex} will also see balanced braces
3924 % but when the actual index entry is again processed by \TeX{} the
3925 % brace in between |\iffalse| |\fi| will vanish.
3926 % \begin{macrocode}
3927 \@ifundefined{LeftBraceIndex}{\def\LeftBraceIndex{%
3928 \special@index{\bgroup\actualchar
3929 \string\verb% % to fool emacs highlighting
3930 \quotechar*\verbatimchar
3931 \quotechar\bslash{\verbatimchar\string\iffalse}\string\fi}}}{}
3932
3933 \@ifundefined{RightBraceIndex}{\def\RightBraceIndex{%
3934 \special@index{\egroup\actualchar\string\iffalse{\string\fi
3935 \string\verb% % to fool emacs highlighting
3936 \quotechar*\verbatimchar\quotechar\bslash}\verbatimchar}}}{}
3937 % \end{macrocode}
3938 % \end{imacro}
3939 % \end{imacro}
3940 %
3941 %
3942 % \begin{imacro}{\PercentIndex}
3943 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
3944 % \changes{v1.7c}{1992/03/25}{Default now for bug-fixed makeindex}
3945 % By default we assume a version of \prg{makeindex} without the
3946 % percent bug is being used.
3947 % \begin{macrocode}
3948 \@ifundefined{PercentIndex}
3949 {\def\PercentIndex{\it@is@a\percentchar}}{}
3950 % \end{macrocode}
3951 % \end{imacro}
3952 %
3953 %
3954 % \begin{omacro}{\OldMakeindex}
3955 % \changes{v1.7c}{1992/03/26}{Replaced \cs{NewMakeIndex}.}
3956 % \begin{imacro}{\percentchar}
3957 % Here is one solution for the percent bug in \prg{makeindex}.
3958 % The macro |\percentchar| denotes a |%|$_{12}$. Calling this from
3959 % a package or the driver file sets things up
3960 % appropriately.\label{bug:fixes}
3961 % \begin{macrocode}
3962 \def\OldMakeindex{\def\PercentIndex{%
3963 \special@index{\quotechar\percentchar\actualchar
3964 \string\verb% % to fool emacs highlighting
3965 \quotechar*\verbatimchar\quotechar\bslash
3966 \percentchar\percentchar\verbatimchar}}}
3967 {\catcode`\%=12 \gdef\percentchar{%}}
3968 % \end{macrocode}
3969 % \end{imacro}
3970 % \end{omacro}
3971 %
3972 %
3973 % \begin{macro}{\it@is@a}
3974 % This macro is supposed to produce a correct |\SortIndex|
3975 % entry for a given character. Since this character might be
3976 % recognized as a `command' character by the index program used,
3977 % all characters are quoted with the |\quotechar|.
3978 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
3979 % \begin{macrocode}
3980 \def\it@is@a#1{\special@index{\quotechar #1\actualchar
3981 \string\verb% % to fool emacs highlighting
3982 \quotechar*\verbatimchar
3983 \quotechar\bslash\quotechar#1\verbatimchar}}
3984 % \end{macrocode}
3985 % \end{macro}
3986 %
3987 %
3988 %
3989 %
3990 %
3991 %
3992 % \subsection{Redefining the \env{index} environment}
3993 %
3994 %\changes{v1.4r}{1989/04/22}{twocols env. placed into separate file}
3995 %\changes{v1.4?}{1989/04/19}{use DEK's algorithm and implement
3996 % a twocols env.}
3997 %\changes{v1.4?}{1989/04/16}{changes to the index env.}
3998 %\changes{v1.5a}{1989/04/26}{Now input multicol.sty instead of
3999 % multcols.sty}
4000
4001 %
4002 % \begin{ldimen}{\IndexMin}
4003 % \begin{lcounter}{IndexColumns}
4004 % \changes{v1.4t}{1989/04/24}{Counter added.}
4005 % If \texttt{multicol} is in use,
4006 % when the index is started we compute the remaining space on the
4007 % current page; if it is greater than |\IndexMin|, the first
4008 % part of the index will then be placed in the available space.
4009 % The number of columns set is controlled by the counter
4010 % |\c@IndexColumns| which can be changed with a
4011 % |\setcounter| declaration.
4012 % \begin{macrocode}
4013 \newdimen\IndexMin \IndexMin = 80pt
4014 \newcount\c@IndexColumns \c@IndexColumns = 3
4015 % \end{macrocode}
4016 % \end{lcounter}
4017 % \end{ldimen}
4018 %
4019 %
4020 %
4021 % \begin{environment}{theindex}
4022 % Now we start the multi-column mechanism, if appropriate. We use the
4023 % \LaTeX{} counter |\c@IndexColumns| declared above to denote
4024 % the number of columns and insert the `index prologue' text (which
4025 % might contain a |\section| call, etc.). See the default
4026 % definition for an example.
4027 % \changes{v1.4t}{1989/04/24}{Incorporated new multicols env.}
4028 % \changes{v1.5a}{1989/04/26}{Call multicols first}
4029 % \changes{v1.6e}{1991/04/03}{Turned into env definition.}
4030 % \changes{v1.7a}{1992/03/04}{Include test for multicols.}
4031 % \begin{macrocode}
4032 \ifdoc@multicol
4033 % \end{macrocode}
4034 %
4035 % \begin{macrocode}
4036 \RequirePackage{multicol}
4037 % \end{macrocode}
4038 %
4039 % \begin{macrocode}
4040 \renewenvironment{theindex}
4041 {\begin{multicols}\c@IndexColumns[\index@prologue][\IndexMin]%
4042 % \end{macrocode}
4043 % Then we make a few last minute assignments to read the individual
4044 % index |\item|$\,$s and finish off by ignoring any initial
4045 % space.
4046 % \begin{macrocode}
4047 \IndexParms \let\item\@idxitem \ignorespaces}%
4048 % \end{macrocode}
4049 %
4050 % \begin{macro}{\endtheindex}
4051 % \changes{v1.4t}{1989/04/24}{Incorporated new multicols env.}
4052 % At the end of the index, we have only to end the \env{multicols}
4053 % environment.
4054 % \begin{macrocode}
4055 {\end{multicols}}
4056 % \end{macrocode}
4057 % If we can't use \env{multicols} we warn the user and use an
4058 % environment that's basically the one from \texttt{article.sty}.
4059 % \begin{macrocode}
4060 \else
4061 \def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
4062 \columnseprule \z@ \columnsep 35\p@
4063 \twocolumn[\index@prologue]%
4064 \IndexParms \let\item\@idxitem \ignorespaces}
4065 \def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
4066 \fi
4067 % \end{macrocode}
4068 % \end{macro}
4069 % \end{environment}
4070 %
4071 % Here are the necessary \prg{makeindex} declarations. We disable
4072 % scanning of macro names inside the index with |\scan@allowedfalse\n|
4073 % to avoid recursion.
4074 % \begin{macrocode}
4075 %</package>
4076 %<+gind>preamble
4077 %<+gind>"\n \\begin{theindex} \n \\makeatletter\\scan@allowedfalse\n"
4078 %<+gind>postamble
4079 %<+gind>"\n\n \\end{theindex}\n"
4080 %<*package>
4081 % \end{macrocode}
4082 %
4083 %
4084 % \begin{imacro}{\IndexPrologue}
4085 % \begin{macro}{\index@prologue}
4086 % \changes{v1.9w}{1995/12/27}{Text changed}
4087 % \changes{v1.9x}{1996/01/11}{Text depends on code lines used}
4088 % The |\IndexPrologue| macro is used to place a short message
4089 % into the document above the index. It is implemented by
4090 % redefining |\index@prologue|, a macro which holds the
4091 % default text. We'd better make it a |\long| macro to allow
4092 % |\par| commands in its argument.
4093 % \begin{macrocode}
4094 \long\def\IndexPrologue#1{\@bsphack\def\index@prologue{#1}\@esphack}
4095 % \end{macrocode}
4096 % Now we test whether the default is already defined by another
4097 % package file. If not we define it.
4098 % \changes{v2.0j}{2000/05/22}{Less obscure wording? (CAR pr/3202)}
4099 % \begin{macrocode}
4100 \@ifundefined{index@prologue}
4101 {\def\index@prologue{\section*{Index}%
4102 \markboth{Index}{Index}%
4103 Numbers written in italic refer to the page
4104 where the corresponding entry is described;
4105 numbers underlined refer to the
4106 \ifcodeline@index
4107 code line of the
4108 \fi
4109 definition; numbers in roman refer to the
4110 \ifcodeline@index
4111 code lines
4112 \else
4113 pages
4114 \fi
4115 where the entry is used.
4116 }}{}
4117 % \end{macrocode}
4118 % \end{macro}
4119 % \end{imacro}
4120 %
4121 %
4122 %
4123 % \begin{imacro}{\IndexParms}
4124 % These are some last-minute assignments for formatting the index
4125 % entries. They are defined in a separate macro so that a user can
4126 % substitute different definitions. We start by defining the
4127 % various parameters controlling leading and the separation between
4128 % the two columns. The entire index is set in |\small| size.
4129 % \begin{macrocode}
4130 \@ifundefined{IndexParms}
4131 {\def\IndexParms{%
4132 \parindent \z@
4133 \columnsep 15pt
4134 \parskip 0pt plus 1pt
4135 \rightskip 15pt
4136 \mathsurround \z@
4137 \parfillskip=-15pt
4138 \small
4139 % \end{macrocode}
4140 % \begin{macro}{\@idxitem}
4141 % \begin{macro}{\subitem}
4142 % \begin{macro}{\subsubitem}
4143 % Index items are formatted with hanging indentation for any items
4144 % which may require more than one line.
4145 % \begin{macrocode}
4146 \def\@idxitem{\par\hangindent 30pt}%
4147 % \end{macrocode}
4148 % Any sub-item in the index is formatted with a 15pt indentation
4149 % under its main heading.
4150 % \begin{macrocode}
4151 \def\subitem{\@idxitem\hspace*{15pt}}%
4152 % \end{macrocode}
4153 % Whilst sub-sub-items go in a further 10pt.
4154 % \begin{macrocode}
4155 \def\subsubitem{\@idxitem\hspace*{25pt}}%
4156 % \end{macrocode}
4157 % \begin{macro}{\indexspace}
4158 % The \prg{makeindex} program generates an |\indexspace|
4159 % before each new alphabetic section commences. After this final
4160 % definition we end the |\@ifundefined| and the definition of
4161 % |\IndexParms|.
4162 % \begin{macrocode}
4163 \def\indexspace{\par\vspace{10pt plus 2pt minus 3pt}}%
4164 }}{}
4165 % \end{macrocode}
4166 % \end{macro}
4167 % \end{macro}
4168 % \end{macro}
4169 % \end{macro}
4170 % \end{imacro}
4171 %
4172 %
4173 % \begin{imacro}{\efill}
4174 % This definition of |\efill| is intended to be used after index
4175 % items which have no following text (for example, ``\textit{
4176 % see\/}'' entries). It just ensures that the current line is
4177 % filled, preventing ``|Underfull \hbox|'' messages.
4178 % \begin{macrocode}
4179 \def\efill{\hfill\nopagebreak}%
4180 %</package>
4181 %<+gind|gglo>item_x1 "\\efill \n \\subitem "
4182 %<+gglo>item_x2 "\\ "
4183 %<+gind>item_x2 "\\efill \n \\subsubitem "
4184 %<*package>
4185 % \end{macrocode}
4186 % \end{imacro}
4187 %
4188 %
4189 %
4190 % \begin{imacro}{\pfill}
4191 % The following definitions provide the |\pfill| command; if
4192 % this is specified in the index style file to \prg{makeindex} as
4193 % the delimiter to appear after index items, then the intervening
4194 % space before the referenced page numbers will be filled with
4195 % dots, with a little white space interpolated at each end of the
4196 % dots. If the line is broken the dots will show up on both lines.
4197 % \begin{macrocode}
4198 \def\pfill{\unskip~%
4199 \leaders\hbox to.6em{\hss .\hss}\hfill
4200 \penalty500\strut\nobreak
4201 \leaders\hbox to.6em{\hss .\hss}\hfil
4202 ~\ignorespaces}%
4203 %</package>
4204 %<+gind|gglo>delim_0 "\\pfill "
4205 %<+gind|gglo>delim_1 "\\pfill "
4206 %<+gind|gglo>delim_2 "\\pfill "
4207 %<*package>
4208 % \end{macrocode}
4209 % \end{imacro}
4210 %
4211 %
4212 %
4213 % \begin{imacro}{\*}
4214 % Here is the definition for the |\*| macro. It isn't used in
4215 % this set of macros.
4216 % \begin{macrocode}
4217 \def\*{\leavevmode\lower.8ex\hbox{$\,\widetilde{\ }\,$}}
4218 % \end{macrocode}
4219 % \end{imacro}
4220 %
4221 %
4222 % \begin{imacro}{\main}
4223 % The \textit{defining\/} entry for a macro name is flagged with
4224 % the string \texttt{\encapchar main}\footnote{With the current
4225 % definition of \texttt{\bslash encapchar} substituted for
4226 % \texttt{\encapchar}} in the |\index| command; \prg{makeindex}
4227 % processes this so that the |\main| macro will be invoked to
4228 % underline the page number(s) on which the {\em definition\/} of
4229 % the macro will be found.
4230 % \begin{macrocode}
4231 \@ifundefined{main}{\def\main#1{\underline{#1}}}{}
4232 % \end{macrocode}
4233 % \end{imacro}
4234 %
4235 % \begin{imacro}{\usage}
4236 % The |\usage| macro is used to indicate entries describing
4237 % the usage of a macro. The corresponding page number(s) will be
4238 % set in \textit{italics}.
4239 % \begin{macrocode}
4240 \@ifundefined{usage}{\def\usage#1{\textit{#1}}}{}
4241 % \end{macrocode}
4242 % \end{imacro}
4243 %
4244 % \begin{imacro}{\code}
4245 % The |\code| macro is used to indicate index entries to code lines
4246 % that aren't main entries.
4247 % By default we do nothing special with them
4248 % the usage of a macro.
4249 % \begin{macrocode}
4250 \@ifundefined{code}{\def\code#1{#1}}{}
4251 % \end{macrocode}
4252 % \end{imacro}
4253 %
4254 %
4255 % \begin{imacro}{\PrintIndex}
4256 % \changes{v1.5k}{1989/09/04}{\cs{printindex} changed to
4257 % \cs{PrintIndex}}
4258 % \changes{v1.7a}{1992/02/26}{Documentation moved to interface section.}
4259 % \changes{v1.9h}{1994/02/10}{Use \cs{@input@} instead of \cs{@input}.}
4260 % \changes{v1.9w}{1995/12/29}{Turn the cmd into a noop after use.}
4261 % This is the same as |\printindex| in the \pkg{makeidx} package.
4262 % \begin{macrocode}
4263 \def\PrintIndex{\@input@{\jobname.ind}%
4264 \global\let\PrintIndex\@empty}
4265 % \end{macrocode}
4266 % \end{imacro}
4267 %
4268 %
4269 % We want headings in the index (and changes list) according to the
4270 % initial character of the next block of entries and have to instruct
4271 % \prg{makeindex} appropriately. Unfortunately the specification
4272 % for this changed sometime between versions 2.4 and 2.11 of
4273 % \prg{makeindex}. We provide both ways of doing it but
4274 % unfortunately this will always produce a warning message from
4275 % \prg{makeindex}. This is for older versions:
4276 % \changes{v1.7h}{1992/07/01}{Turn off headings in gls file}
4277 % \begin{macrocode}
4278 %</package>
4279 %<+gind,gglo>% The next lines will produce some warnings when
4280 %<+gind,gglo>% running Makeindex as they try to cover two different
4281 %<+gind,gglo>% versions of the program:
4282 %<+gind,gglo>lethead_prefix "{\\bfseries\\hfil "
4283 %<+gind,gglo>lethead_suffix "\\hfil}\\nopagebreak\n"
4284 %<+gind>lethead_flag 1
4285 %<+gglo>lethead_flag 0
4286 % \end{macrocode}
4287 % This works for newer ones:
4288 % \begin{macrocode}
4289 %<+gind,gglo>heading_prefix "{\\bfseries\\hfil "
4290 %<+gind,gglo>heading_suffix "\\hfil}\\nopagebreak\n"
4291 %<+gind>headings_flag 1
4292 %<+gglo>headings_flag 0
4293 %<*package>
4294 % \end{macrocode}
4295 %
4296 %
4297 %
4298 % \subsection[Dealing with the change history]
4299 % {Dealing with the change history\footnotemark}
4300 % \footnotetext{The whole section was proposed by Brian \textsc{Hamilton
4301 % Kelly}. He also documented and debugged the macros as
4302 % well as many other parts of this package.}
4303 %
4304 % To provide a change history log, the |\changes| command has
4305 % been introduced. This takes three arguments, respectively, the
4306 % version number of the file, the date of the change, and some detail
4307 % regarding what change has been made. The second of these arguments
4308 % is otherwise ignored, but the others are written out and may be used
4309 % to generate a history of changes, to be printed at the end of the
4310 % document. However, note that older versions of Chen's standard
4311 % \prg{makeindex}
4312 % program limit any textual field to just 64 characters; therefore,
4313 % is important that the number of characters in the second and third
4314 % parameters should not exceed 61 altogether (to allow for the
4315 % parentheses placed around the date).
4316 %
4317 % \begin{imacro}{\changes}
4318 % \changes{BHK}{1989/04/26}{Documented \texttt{\protect\bslash changes}
4319 % command.}
4320 % \changes{BHK}{1989/04/26}{Changed definition of
4321 % \texttt{\protect\bslash protect}.} The output of the |\changes|
4322 % command goes into the \meta{Glossary\_File} and therefore uses
4323 % the normal |\glossaryentry| commands.\footnote{Note that a recent
4324 % change in \LaTeX{} 2.09 changed the command name in the
4325 % \texttt{.glo} file from \texttt{\bslash indexentry} to
4326 % \texttt{\bslash glossaryentry}. It is therefore necessary to
4327 % have a special \prg{makeindex} style file called
4328 % \texttt{gglo.ist} to process this file correctly.} Thus
4329 % \prg{makeindex} or a similar program can be used to process
4330 % the output into a sorted ``glossary''. The |\changes| command
4331 % commences by taking the usual measures to hide its spacing, and
4332 % then redefines |\protect| for use within the argument of the
4333 % generated |\indexentry| command.
4334 %
4335 % We re-code nearly all chars found in |\sanitize| to letter
4336 % since the use of special package which make some characters
4337 % active might upset the |\changes| command when writing its
4338 % entries to the file. However we have to leave |%| as comment
4339 % and \verb*+ + as \meta{space} otherwise chaos will happen.
4340 % And, of course the |\| should be available as escape
4341 % character.
4342 % \changes{v1.5v}{1990/01/28}{`Re-code a lot of chars.}
4343 % \changes{v1.5m}{1989/09/20}{\cs{actualchar} in second level removed.}
4344 % \changes{v1.5o}{1989/09/24}{New sorting.}
4345 % \changes{v1.6c}{1990/06/29}{Again new sorting.}
4346 % \changes{v1.9u}{1995/08/06}{Use \cs{protected@edef}}
4347 % \begin{macrocode}
4348 \def\changes{\@bsphack\begingroup\@sanitize
4349 \catcode`\\\z@ \catcode`\ 10 \MakePercentIgnore
4350 \changes@}
4351 \def\changes@#1#2#3{%
4352 \protected@edef\@tempa{\noexpand\glossary{#1%
4353 % \end{macrocode}
4354 % If asked for we also show the date of in the change log (after
4355 % the version).
4356 % \changes{v3.0g}{2022/06/01}{Show change dates if asked for (gh/531)}
4357 % \begin{macrocode}
4358 \ifdoc@reportchangedates
4359 \space -- #2\fi
4360 \levelchar
4361 % \end{macrocode}
4362 % \changes{v1.9u}{1995/08/06}{Use value of \cs{saved@macroname} to
4363 % find out about change entries at outer level}
4364 % If the macro |\saved@macroname| doesn't contain any macro name
4365 % (ie is empty) the current changes entry was done at top-level.
4366 % In this case we precede it by |\generalname|.
4367 % \begin{macrocode}
4368 \ifx\saved@macroname\@empty
4369 % \end{macrocode}
4370 % Putting a |!| at the beginning of the entry hopefully moves this
4371 % entry to the very beginning during sorting.
4372 % \begin{macrocode}
4373 \quotechar!%
4374 \actualchar
4375 \generalname
4376 \else
4377 % \end{macrocode}
4378 % \changes{v2.1g}{2016/02/15}{Use \cs{saved@indexname}}
4379 % \begin{macrocode}
4380 \saved@indexname
4381 \actualchar
4382 \string\verb% % to fool emacs highlighting
4383 \quotechar*%
4384 \verbatimchar\saved@macroname
4385 \verbatimchar
4386 \fi
4387 :\levelchar #3}}%
4388 \@tempa\endgroup\@esphack}
4389 % \end{macrocode}
4390 % \end{imacro}
4391 %
4392 %
4393 % \begin{macro}{\saved@macroname}
4394 % \changes{BHK}{1989/04/26}{Provided for sorting outside \env{macro}
4395 % environment} The entries are sorted for convenience by the name
4396 % of the most recently introduced macroname (i.e., that in the most
4397 % recent |\begin{macro}| command). We therefore provide
4398 % |\saved@macroname| to record that argument, and provide a default
4399 % definition in case |\changes| is used outside a \env{macro}
4400 % environment. (This is a {\em wicked\/} hack to get such entries
4401 % at the beginning of the sorted list! It works providing no macro
4402 % names start with |!| or |"|.) \changes{v1.7a}{1992/03/02}{Changed
4403 % string used for better sorting.}
4404 % \changes{v1.9u}{1995/08/06}{Now empty by default}
4405 % \begin{macrocode}
4406 \def\saved@macroname{}
4407 % \end{macrocode}
4408 % \end{macro}
4409 %
4410 % \begin{macro}{\saved@indexname}
4411 % \changes{v2.1g}{2016/02/15}{Use \cs{saved@indexname}}
4412 % The macroname being document without a backslash for the index
4413 % (or the environment name which doesn't have one in the first place).
4414 % \begin{macrocode}
4415 \def\saved@indexname{}
4416 % \end{macrocode}
4417 % \end{macro}
4418 %
4419 % \begin{imacro}{\generalname}
4420 % \changes{v1.9u}{1995/08/06}{Macro added}
4421 % This macro holds the string placed before changes entries on
4422 % top-level.
4423 % \begin{macrocode}
4424 \def\generalname{General}
4425 % \end{macrocode}
4426 % \end{imacro}
4427 %
4428 %
4429 % \begin{imacro}{\RecordChanges}
4430 % \changes{BHK}{1989/04/26}{Renames former \texttt{\protect\bslash
4431 % PrintChanges} command.}
4432 % To cause the changes to be written (to a \texttt{.glo}) file, we
4433 % define |\RecordChanges| to invoke \LaTeX's usual
4434 % |\makeglossary| command.
4435 % \begin{macrocode}
4436 \let\RecordChanges\makeglossary
4437 % \end{macrocode}
4438 % \end{imacro}
4439 %
4440 %
4441 % \begin{ldimen}{\GlossaryMin}
4442 % \changes{BHK}{1989/04/26}{Added to support
4443 % \texttt{\protect\bslash changes}.}
4444 % \begin{lcounter}{GlossaryColumns}
4445 % \changes{BHK}{1989/04/26}{Added to support \texttt{\protect\bslash
4446 % changes}.} The remaining macros are all analogues of those used
4447 % for the \env{theindex} environment. When the glossary is
4448 % started we compute the space which remains at the bottom of the
4449 % current page; if this is greater than |\GlossaryMin| then the
4450 % first part of the glossary will be placed in the available space.
4451 % The number of columns set are controlled by the counter
4452 % |\c@GlossaryColumns| which can be changed with a |\setcounter|
4453 % declaration.
4454 % \begin{macrocode}
4455 \newdimen\GlossaryMin \GlossaryMin = 80pt
4456 \newcount\c@GlossaryColumns \c@GlossaryColumns = 2
4457 % \end{macrocode}
4458 % \end{lcounter}
4459 % \end{ldimen}
4460 %
4461 %
4462 % \begin{environment}{theglossary}
4463 % \changes{BHK}{1989/04/26}{Added to support
4464 % \texttt{\protect\bslash changes}.}
4465 % \changes{v1.5p}{1989/09/28}{Now call \cs{multicols} first.}
4466 % \changes{v1.6e}{1991/04/03}{Turned into env definition.}
4467 % \changes{v1.7a}{1992/03/10}{Changed to work without multicols if
4468 % necessary.}
4469 % \changes{BHK}{1989/04/26}{Added to support
4470 % \texttt{\protect\bslash changes}.}
4471 % The environment \env{theglossary} is defined in the same manner
4472 % as the \env{theindex} environment.
4473 % \begin{macrocode}
4474 \ifdoc@multicol
4475 \newenvironment{theglossary}{%
4476 \begin{multicols}\c@GlossaryColumns
4477 [\glossary@prologue][\GlossaryMin]%
4478 \GlossaryParms \let\item\@idxitem \ignorespaces}%
4479 {\end{multicols}}
4480 \else
4481 \newenvironment{theglossary}{%
4482 \@restonecoltrue\if@twocolumn\@restonecolfalse\fi
4483 \columnseprule \z@ \columnsep 35\p@
4484 \twocolumn[\glossary@prologue]%
4485 \GlossaryParms \let\item\@idxitem \ignorespaces}
4486 {\if@restonecol\onecolumn\else\clearpage\fi}
4487 \fi
4488 % \end{macrocode}
4489 % \end{environment}
4490 %
4491 % Here are the necessary \prg{makeindex} declarations with scanning
4492 % disabled as for the index.
4493 % \begin{macrocode}
4494 %</package>
4495 %<+gglo>preamble
4496 %<+gglo>"\n \\begin{theglossary} \n
4497 %<+gglo> \\makeatletter\\scan@allowedfalse\n"
4498 %<+gglo>postamble
4499 %<+gglo>"\n\n \\end{theglossary}\n"
4500 % \end{macrocode}
4501 % This difference from \texttt{gind.ist} is necessary if you have an
4502 % up-to-date \LaTeX.
4503 % \begin{macrocode}
4504 %<+gglo>keyword "\\glossaryentry"
4505 %<*package>
4506 % \end{macrocode}
4507 %
4508 %
4509 % \begin{imacro}{\GlossaryPrologue}
4510 % \changes{BHK}{1989/04/26}{Added to support
4511 % \texttt{\protect\bslash changes}.}
4512 % \begin{macro}{\glossary@prologue}
4513 % \changes{BHK}{1989/04/26}{Added to support
4514 % \texttt{\protect\bslash changes}.}
4515 % The |\GlossaryPrologue| macro is used to place a short
4516 % message above the glossary into the document. It is implemented
4517 % by redefining |\glossary@prologue|, a macro which holds the
4518 % default text. We better make it a long macro to allow
4519 % |\par| commands in its argument.
4520 % \begin{macrocode}
4521 \long\def\GlossaryPrologue#1{\@bsphack
4522 \def\glossary@prologue{#1}%
4523 \@esphack}
4524 % \end{macrocode}
4525 % Now we test whether the default is already defined by another
4526 % package file. If not we define it.
4527 % \begin{macrocode}
4528 \@ifundefined{glossary@prologue}
4529 {\def\glossary@prologue{\section*{{Change History}}%
4530 \markboth{{Change History}}{{Change History}}%
4531 }}{}
4532 % \end{macrocode}
4533 % \end{macro}
4534 % \end{imacro}
4535 %
4536 % \begin{imacro}{\GlossaryParms}
4537 % \changes{BHK}{1989/04/26}{Added to support
4538 % \texttt{\protect\bslash changes}.}
4539 % Unless the user specifies otherwise, we set the change history
4540 % using the same parameters as for the index except that we make it sort
4541 % of ragged right as it contains text that often doesn't break nicely in
4542 % small columns.
4543 % \changes{v2.1g}{2016/02/15}{Use ragged setting by default}
4544 % \begin{macrocode}
4545 \@ifundefined{GlossaryParms}{\let\GlossaryParms\IndexParms
4546 \expandafter\def\expandafter\GlossaryParms\expandafter{\GlossaryParms
4547 \rightskip 15pt plus 1fil
4548 \parfillskip -15pt plus -1fil\relax}
4549 }{}
4550 % \end{macrocode}
4551 % \end{imacro}
4552 %
4553 % \begin{imacro}{\PrintChanges}
4554 % \changes{BHK}{1989/04/26}{Added to support
4555 % \texttt{\protect\bslash changes}.}
4556 % To read in and print the sorted change history, just put the
4557 % |\PrintChanges| command as the last (commented-out, and thus
4558 % executed during the documentation pass through the file) command
4559 % in your package file. Alternatively, this command may form one of
4560 % the arguments of the |\MaybeStop| command, although a
4561 % change history is probably {\em not\/} required if only the
4562 % description is being printed.
4563 %
4564 % The command assumes that \prg{makeindex} or some other program
4565 % has processed the \texttt{.glo} file to generate a sorted
4566 % \texttt{.gls} file.
4567 % \changes{v1.9h}{1994/02/10}{Use \cs{@input@} instead of \cs{@input}.}
4568 % \changes{v1.9w}{1995/12/29}{Turn the cmd into a noop after use.}
4569 % \begin{macrocode}
4570 \def\PrintChanges{\@input@{\jobname.gls}%
4571 \global\let\PrintChanges\@empty}
4572 % \end{macrocode}
4573 % \end{imacro}
4574 %
4575 %
4576 %
4577 %
4578 %
4579 % \subsection{Bells and whistles}
4580 %
4581 % \begin{imacro}{\MaybeStop}
4582 % \changes{v1.5k}{1989/09/04}{Support for checksum.}
4583 % \begin{imacro}{\Finale}
4584 % \changes{v1.5k}{1989/09/04}{Support for checksum.}
4585 % \changes{v1.5z}{1990/04/22}{Define \cs{Finale} globally.}
4586 % \begin{imacro}{\AlsoImplementation}
4587 % \changes{v1.9w}{1995/12/27}{Macro added}
4588 % \begin{imacro}{\OnlyDescription}
4589 % If |\AlsoImplementation| is in force the whole documentation
4590 % including the code part will be typeset. This is the default.
4591 % \begin{macrocode}
4592 \newcommand\AlsoImplementation{%
4593 % \end{macrocode}
4594 % To make this happen we have to define
4595 % |\MaybeStop| in a way that its argument is typeset at the
4596 % very end or more exactly at |\Finale|. For this we
4597 % save its argument in the macro |\Finale|.
4598 % \begin{macrocode}
4599 \long\def\MaybeStop##1{\@bsphack\gdef\Finale{##1%
4600 % \end{macrocode}
4601 % But |\Finale| will be called at the very end of a file. This
4602 % is exactly the point were we want to know if the file is
4603 % uncorrupted. Therefore we also call |\check@checksum| at this
4604 % point.
4605 % \begin{macrocode}
4606 \check@checksum}%
4607 % \end{macrocode}
4608 % On the other hand: |\MaybeStop| is more or less a
4609 % dividing point between description and code. So we start to look
4610 % for the check-sum of the documented file by calling
4611 % |\init@checksum|.
4612 % \begin{macrocode}
4613 \init@checksum
4614 \@esphack}%
4615 }
4616 % \end{macrocode}
4617 %
4618 % Since |\AlsoImplementation| should be the default we execute it
4619 % and thus |\MaybeStop| gets the desired meaning.
4620 % \begin{macrocode}
4621 \AlsoImplementation
4622 % \end{macrocode}
4623 % When the user places an |\OnlyDescription| declaration in
4624 % the driver file the document should only be typeset up to
4625 % |\MaybeStop|. We therefore have to redefine this macro.
4626 % \begin{macrocode}
4627 \def\OnlyDescription{\@bsphack\long\def\MaybeStop##1{%
4628 % \end{macrocode}
4629 % In this case the argument of |\MaybeStop| should be set
4630 % and afterwards \TeX{} should stop reading from this file.
4631 % Therefore we finish this macro with
4632 % \begin{macrocode}
4633 ##1\endinput}\@esphack}
4634 % \end{macrocode}
4635 % If no |\MaybeStop| command is given we silently ignore a
4636 % |\Finale| issued.
4637 % \changes{v1.9n}{1994/04/28}{Ignore \cs{Finale} if no
4638 % \cs{MaybeStop} is given}
4639 % \begin{macrocode}
4640 \let\Finale\relax
4641 % \end{macrocode}
4642 % \end{imacro}
4643 % \end{imacro}
4644 % \end{imacro}
4645 % \end{imacro}
4646 %
4647 %
4648 % \begin{omacro}{\StopEventually}
4649 % The old wrong name for |\MaybeStop|. We need to use |\def|
4650 % (i.e., expansion) as |\MaybeStop| gets redefined once in a while.
4651 % \begin{macrocode}
4652 \def\StopEventually{\MaybeStop}
4653 % \end{macrocode}
4654 % \end{omacro}
4655 %
4656 % \begin{imacro}{\meta}
4657 % \changes{v1.4t}{1989/04/24}{Macro added.}
4658 % \changes{v1.5w}{1990/02/03}{Breaks at space allowed.}
4659 % \changes{v1.6a}{1990/05/24}{Extra space bug corrected.}
4660 % The |\meta| macro is a bit tricky. We want to allow line
4661 % breaks at blanks in the argument but we don't want a break
4662 % in between. In the past this was done by defining |\meta| in a way that a
4663 % \verb*+ + is active when the argument is scanned. Words are then
4664 % scanned into |\hbox|es. The active \verb*+ + will end the
4665 % preceding |\hbox| add an ordinary space and open a new
4666 % |\hbox|. In this way breaks are only possible at spaces. The
4667 % disadvantage of this method was that |\meta| was neither robust
4668 % nor could it be |\protect|ed. The new implementation fixes this
4669 % problem by defining |\meta| in a radically different way: we
4670 % prevent hyphenation by defining a |\language| which has no
4671 % patterns associated with it and use this to typeset the words
4672 % within the angle brackets.
4673 % \changes{v2.0i}{2000/05/21}{New implementation (pr/3170)}
4674 % \begin{macrocode}
4675 \ifx\l@nohyphenation\undefined
4676 \newlanguage\l@nohyphenation
4677 \fi
4678 % \end{macrocode}
4679 %
4680 % \begin{macrocode}
4681 \DeclareRobustCommand\meta[1]{%
4682 % \end{macrocode}
4683 % Since the old implementation of |\meta| could be used in math we
4684 % better ensure that this is possible with the new one as
4685 % well. So we use |\ensuremath| around |\langle| and
4686 % |\rangle|. However this is not enough: if |\meta@font@select|
4687 % below expands to |\itshape| it will fail if used in math
4688 % mode. For this reason we hide the whole thing inside an
4689 % |\nfss@text| box in that case.
4690 % \changes{v2.0l}{2000/06/10}{Fixing changes for (pr/3170)}
4691 % \begin{macrocode}
4692 \ensuremath\langle
4693 \ifmmode \expandafter \nfss@text \fi
4694 {%
4695 \meta@font@select
4696 % \end{macrocode}
4697 % Need to keep track of what we changed just in case the user
4698 % changes font inside the argument so we store the font explicitly.
4699 % \changes{v2.0m}{2000/07/04}{More fixing changes for (pr/3170)}
4700 % \begin{macrocode}
4701 \edef\meta@hyphen@restore
4702 {\hyphenchar\the\font\the\hyphenchar\font}%
4703 \hyphenchar\font\m@ne
4704 \language\l@nohyphenation
4705 #1\/%
4706 \meta@hyphen@restore
4707 }\ensuremath\rangle
4708 }
4709 % \end{macrocode}
4710 % \end{imacro}
4711 %
4712 %
4713 % \begin{macro}{\meta@font@select}
4714 % \changes{v2.0k}{2000/05/26}{Macro added (pr/3170)}
4715 % Make font used inside |\meta| customizable.
4716 % \begin{macrocode}
4717 \def\meta@font@select{\itshape}
4718 % \end{macrocode}
4719 % \end{macro}
4720 %
4721 %
4722 % \begin{imacro}{\IndexInput}
4723 % This next macro may be used to read in a separate file (possibly
4724 % a package file that is {\em not\/} documented by this means) and
4725 % set it verbatim, whilst scanning for macro names and indexing the
4726 % latter. This could be a useful first pass in preparing to
4727 % generate documentation for the file read.
4728 % \begin{macrocode}
4729 \def\IndexInput#1{%
4730 % \end{macrocode}
4731 % We commence by setting up a group, and initializing a
4732 % |\trivlist| as is normally done by a
4733 % |\begin{macrocode}| command.
4734 % \begin{macrocode}
4735 \begingroup \macro@code
4736 % \end{macrocode}
4737 % We also make spacing behave as in the \env{macrocode}
4738 % environment, because otherwise all the spaces will be shown
4739 % explicitly.
4740 % \begin{macrocode}
4741 \frenchspacing \@vobeyspaces
4742 % \end{macrocode}
4743 % Then it only remains to read in the specified file, and finish
4744 % off the |\trivlist|.
4745 % \changes{v1.5t}{1989/11/07}{Call \cs{endmacrocode} instead
4746 % of \cs{endtrivlist}.}
4747 % \begin{macrocode}
4748 \input{#1}\endmacrocode
4749 % \end{macrocode}
4750 % Of course, we need to finish off the group as well.
4751 % \begin{macrocode}
4752 \endgroup}
4753 % \end{macrocode}
4754 % \end{imacro}
4755 %
4756 %
4757 % \begin{imacro}{\maketitle}
4758 % The macro to generate titles is easily altered in order that it
4759 % can be used more than once (an article with many titles). In the
4760 % original, diverse macros were concealed after use with
4761 % |\relax|. We must cancel anything that may have been put
4762 % into |\@thanks|, etc., otherwise {\em all\/} titles will
4763 % carry forward any earlier such setting!
4764 % \changes{v1.5j}{1989/06/09}{thispagestyle plain removed}
4765 % \changes{v1.9r}{1994/06/09}{Added new definitions of
4766 % \cs{@makefnmark} and \cs{@makefntext}}
4767 % \begin{macrocode}
4768 \def\maketitle{\par
4769 \begingroup \def \thefootnote {\fnsymbol {footnote}}%
4770 \setcounter {footnote}\z@
4771 \def\@makefnmark{\hbox to\z@{$\m@th^{\@thefnmark}$\hss}}%
4772 \long\def\@makefntext##1{\parindent 1em\noindent
4773 \hbox to1.8em{\hss$\m@th^{\@thefnmark}$}##1}%
4774 \if@twocolumn \twocolumn [\@maketitle ]%
4775 \else \newpage \global \@topnum \z@ \@maketitle \fi
4776 % \end{macrocode}
4777 % \changes{v1.5k}{1989/09/04}{Added \cs{ps@titlepage}}
4778 % For special formatting requirements (such as in TUGboat), we use
4779 % pagestyle |titlepage| for this; this is later defined to be
4780 % |plain|, unless already defined, as, for example, by
4781 % |ltugboat.sty|.
4782 % \begin{macrocode}
4783 \thispagestyle{titlepage}\@thanks \endgroup
4784 % \end{macrocode}
4785 % If the driver file documents many files, we don't want parts of a
4786 % title of one to propagate to the next, so we have to cancel
4787 % these:
4788 % \begin{macrocode}
4789 \setcounter {footnote}\z@
4790 \gdef\@date{\today}\gdef\@thanks{}%
4791 \gdef\@author{}\gdef\@title{}}
4792 % \end{macrocode}
4793 % \end{imacro}
4794 %
4795 %
4796 % \begin{imacro}{\ps@titlepage}
4797 % \changes{v1.5k}{1989/09/04}{Added \texttt{\protect\bslash
4798 % ps@titlepage}} When a number of articles are concatenated into a
4799 % journal, for example, it is not usual for the title pages of such
4800 % documents to be formatted differently. Therefore, a class
4801 % such as \cls{ltugboat} can define this macro in advance.
4802 % However, if no such definition exists, we use pagestyle
4803 % \texttt{plain} for title pages.
4804 % \begin{macrocode}
4805 \@ifundefined{ps@titlepage}
4806 {\let\ps@titlepage=\ps@plain}{}
4807 % \end{macrocode}
4808 % \end{imacro}
4809 %
4810 % \begin{imacro}{\MakeShortVerb}
4811 % \changes{v1.7a}{1992/02/27}{Added (from newdoc but now alters
4812 % \cs{dospecials}, \cs{@sanitize}).}
4813 % This arranges an abbreviation for |\verb| such that if you say
4814 % |\MakeShortVerb{\|\meta{c}|}| subsequently using
4815 % \meta{c}\meta{text}\meta{c} is equivalent to
4816 % |\verb|\meta{c}\meta{text}\meta{c}.\footnote{Warning:
4817 % the commentary in the rest of this section was written by Dave
4818 % Love.} In addition, the fact
4819 % that \meta{c} is made active is recorded for the benefit of the
4820 % \env{verbatim} and \env{macrocode} environments.
4821 % Note particularly that the definitions below are global.
4822 % The first thing we do (it needn't be first) is to record
4823 % the---presumably new---special character in |\dospecials| and
4824 % |\@sanitize| using |\add@special|.
4825 %
4826 % \changes{v1.9e.2}{1994/02/07}{-js: Check if \protect\meta{c} is
4827 % already an
4828 % abbreviation for \cs{verb}.}
4829 % Some unwary user might issue |\MakeShortVerb| for a second time, we
4830 % better protect against this. We assume that this happened if a
4831 % control sequence |\cc\|\meta{c} is bound, the probability that this
4832 % name is used by another module is low. We will output a warning
4833 % below, so that a possible error might be noticed by the programmer
4834 % if he reads the |LOG| file. (Should have used module internal names,
4835 % 'though.)
4836 %
4837 % \begin{imacro}{\MakeShortVerb*}
4838 % \changes{v2.1a}{2003/12/09}{(HjG) Added \texttt{*} form}
4839 % This arranges an abbreviation for |\verb*| such that if you say
4840 % |\MakeShortVerb*{\|\meta{c}|}| subsequently using
4841 % \meta{c}\meta{text}\meta{c} is equivalent to
4842 % |\verb*|\meta{c}\meta{text}\meta{c}.
4843 % \begin{macrocode}
4844 %</package>
4845 %<*package|shortvrb>
4846 \def\MakeShortVerb{%
4847 \@ifstar
4848 {\def\@shortvrbdef{\verb*}\@MakeShortVerb}%
4849 {\def\@shortvrbdef{\verb}\@MakeShortVerb}}
4850 % \end{macrocode}
4851 % \end{imacro}
4852 % \end{imacro}
4853 %
4854 % \begin{macro}{\@MakeShortVerb}
4855 % \begin{macrocode}
4856 \def\@MakeShortVerb#1{%
4857 \expandafter\ifx\csname cc\string#1\endcsname\relax
4858 % \end{macrocode}
4859 % \changes{v1.9v}{1995/11/03}{(DPC) Use \cs{@shortvrbinfo}}
4860 % \begin{macrocode}
4861 \@shortvrbinfo{Made }{#1}\@shortvrbdef
4862 \add@special{#1}%
4863 % \end{macrocode}
4864 % Then the character's current catcode is stored in |\cc\|\meta{c}.
4865 % \begin{macrocode}
4866 \expandafter
4867 \xdef\csname cc\string#1\endcsname{\the\catcode`#1}%
4868 % \end{macrocode}
4869 % The character is spliced into the definition using the same trick as
4870 % used in |\verb| (for instance), having activated |~| in a group.
4871 % \begin{macrocode}
4872 \begingroup
4873 \catcode`\~\active \lccode`\~`#1%
4874 \lowercase{%
4875 % \end{macrocode}
4876 % The character's old meaning is recorded in |\ac\|\meta{c} prior to
4877 % assigning it a new one.
4878 % \begin{macrocode}
4879 \global\expandafter\let
4880 \csname ac\string#1\endcsname~%
4881 \expandafter\gdef\expandafter~\expandafter{\@shortvrbdef~}}%
4882 \endgroup
4883 % \end{macrocode}
4884 % Finally the character is made active.
4885 % \begin{macrocode}
4886 \global\catcode`#1\active
4887 % \end{macrocode}
4888 % If we suspect that \meta{c} is already a short reference, we tell
4889 % the user. Now he or she is responsible if anything goes wrong\,\dots
4890 % \begin{macrocode}
4891 \else
4892 % \end{macrocode}
4893 % \changes{v1.9v}{1995/11/03}{(DPC) Use \cs{@shortvrbinfo}}
4894 % \begin{macrocode}
4895 \@shortvrbinfo\@empty{#1 already}%
4896 {\@empty\verb% % to fool emacs highlighting
4897 (*)}%
4898 \fi}
4899 % \end{macrocode}
4900 % \end{macro}
4901 %
4902 %
4903 % \begin{imacro}{\DeleteShortVerb}
4904 % \changes{v1.7a}{1992/02/27}{Added (from newdoc but now alters
4905 % \cs{dospecials}, \cs{@sanitize}).}
4906 % Here's the means of undoing a |\MakeShortVerb|, for instance in a
4907 % region where you need to use the character outside a verbatim
4908 % environment. It arranges for |\dospecials| and |\@sanitize| to be
4909 % altered appropriately, restores the saved catcode and, if necessary,
4910 % the character's meaning (as stored by
4911 % |\MakeShortVerb|). If the catcode wasn't stored in
4912 % |\cc\|\meta{c} (by |\MakeShortVerb|) the command is silently
4913 % ignored.
4914 % \changes{v1.7a}{1992/02/28}{Check for previous matched
4915 % \cs{MakeShortVerb}
4916 % to avoid error.}
4917 % \begin{macrocode}
4918 \def\DeleteShortVerb#1{%
4919 \expandafter\ifx\csname cc\string#1\endcsname\relax
4920 % \end{macrocode}
4921 % \changes{v2.1a}{2003/12/10}{(HjG) Notify user
4922 % if it's not a short verb character}
4923 % \begin{macrocode}
4924 \@shortvrbinfo\@empty{#1 not}%
4925 {\@empty\verb% % to fool emacs highlighting
4926 (*)}%
4927 \else
4928 % \end{macrocode}
4929 % \changes{v1.9v}{1995/11/03}{(DPC) Use \cs{@shortvrbinfo}}
4930 % \begin{macrocode}
4931 \@shortvrbinfo{Deleted }{#1 as}%
4932 {\@empty\verb% % to fool emacs
4933 % highlighting
4934 (*)}%
4935 \rem@special{#1}%
4936 \global\catcode`#1\csname cc\string#1\endcsname
4937 % \end{macrocode}
4938 % \changes{v1.9e.2}{1994/02/07}{-js: Reset `cc`\protect\meta{c} in
4939 % in \cs{DeleteShortVerb}}
4940 % We must not forget to reset |\cc\|\meta{c}, otherwise the check in
4941 % |\MakeShortVerb| for a repeated definition will not work.
4942 % \begin{macrocode}
4943 \global \expandafter\let \csname cc\string#1\endcsname \relax
4944 \ifnum\catcode`#1=\active
4945 \begingroup
4946 \catcode`\~\active \lccode`\~`#1%
4947 \lowercase{%
4948 \global\expandafter\let\expandafter~%
4949 \csname ac\string#1\endcsname}%
4950 \endgroup \fi \fi}
4951 % \end{macrocode}
4952 % \end{imacro}
4953 %
4954 % \begin{macro}{\@shortvrbinfo}
4955 % \changes{v1.9v}{1995/11/03}{(DPC) Macro added}
4956 % \changes{v2.1a}{2003/12/10}{(HjG) Third argument added
4957 % on behalf of \cmd{\MakeShortVerb*}}
4958 % Helper function for info messages.
4959 % \begin{macrocode}
4960 \def\@shortvrbinfo#1#2#3{%
4961 %<shortvrb> \PackageInfo{shortvrb}{%
4962 %<!shortvrb> \PackageInfo{doc}{%
4963 #1\expandafter\@gobble\string#2 a short reference
4964 for \expandafter\string#3}}
4965 % \end{macrocode}
4966 % \end{macro}
4967 %
4968 % \begin{macro}{\add@special}
4969 % \changes{v1.7a}{1992/02/27}{Added for short verb facility.}
4970 % This helper macro adds its argument to the
4971 % |\dospecials| macro which is conventionally used by verbatim macros
4972 % to alter the catcodes of the currently active characters. We need
4973 % to add |\do\|\meta{c} to the expansion of |\dospecials| after
4974 % removing the character if it was already there to avoid multiple
4975 % copies building up should |\MakeShortVerb| not be balanced by
4976 % |\DeleteShortVerb| (in case anything that uses |\dospecials| cares
4977 % about repetitions).
4978 % \begin{macrocode}
4979 \def\add@special#1{%
4980 \rem@special{#1}%
4981 \expandafter\gdef\expandafter\dospecials\expandafter
4982 {\dospecials \do #1}%
4983 % \end{macrocode}
4984 % Similarly we have to add |\@makeother\|\meta{c} to |\@sanitize|
4985 % (which is used in things like |\index| to re-catcode all special
4986 % characters except braces).
4987 % \begin{macrocode}
4988 \expandafter\gdef\expandafter\@sanitize\expandafter
4989 {\@sanitize \@makeother #1}}
4990 % \end{macrocode}
4991 % \end{macro}
4992 %
4993 %
4994 % \begin{macro}{\rem@special}
4995 % \changes{v1.7a}{1992/02/27}{Added for short verb facility.}
4996 % The inverse of |\add@special| is slightly trickier. |\do| is
4997 % re-defined to expand to nothing if its argument is the character of
4998 % interest, otherwise to expand simply to the argument. We can then
4999 % re-define |\dospecials| to be the expansion of itself. The space
5000 % after |=`##1| prevents an expansion to |\relax|!
5001 % \begin{macrocode}
5002 \def\rem@special#1{%
5003 \def\do##1{%
5004 \ifnum`#1=`##1 \else \noexpand\do\noexpand##1\fi}%
5005 \xdef\dospecials{\dospecials}%
5006 % \end{macrocode}
5007 % Fixing |\@sanitize| is the same except that we need to re-define
5008 % |\@makeother| which obviously needs to be done in a group.
5009 % \begin{macrocode}
5010 \begingroup
5011 \def\@makeother##1{%
5012 \ifnum`#1=`##1 \else \noexpand\@makeother\noexpand##1\fi}%
5013 \xdef\@sanitize{\@sanitize}%
5014 \endgroup}
5015 %</package|shortvrb>
5016 %<*package>
5017 % \end{macrocode}
5018 % \end{macro}
5019 %
5020 %
5021 % \subsection[Providing a checksum and character table]
5022 % {Providing a checksum and character table\footnotemark}
5023 % \footnotetext{Warning: the commentary in this section was
5024 % written by Dave Love. }
5025 %
5026 %
5027 % \begin{macro}{\init@checksum}
5028 % The checksum mechanism works by counting backslashes in the
5029 % macrocode. This initializes the count (when called from
5030 % |\MaybeStop|).
5031 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5032 % \begin{macrocode}
5033 \def\init@checksum{\relax
5034 \global\bslash@cnt\z@}
5035 % \end{macrocode}
5036 % \end{macro}
5037 %
5038 %
5039 % \begin{macro}{\check@checksum}
5040 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5041 % This reports the sum compared with the value (|\bslash@cnt|) the
5042 % file advertises. It's called from |\Finale| (if that hasn't been
5043 % re-defined).
5044 % \changes{v2.1f}{2016/02/12}{Suppress \cs{CheckSum} check if no checksum
5045 % is specified in the file}
5046 % \begin{macrocode}
5047 \def\check@checksum{\relax
5048 \ifnum\check@sum>\m@ne
5049 % \end{macrocode}
5050 % We do nothing if the checksum in the file is negative (or not given as
5051 % it is initialized with -1).
5052 % \begin{macrocode}
5053 \ifnum\check@sum=\z@
5054 \typeout{**********************************}%
5055 \typeout{* This macro file has no checksum!}%
5056 \typeout{* The checksum should be \the\bslash@cnt!}%
5057 \typeout{**********************************}%
5058 \else
5059 \ifnum\check@sum=\bslash@cnt
5060 \typeout{*******************}%
5061 \typeout{* Checksum passed *}%
5062 \typeout{*******************}%
5063 \else
5064 \PackageError{doc}{Checksum not passed
5065 (\the\check@sum<>\the\bslash@cnt)}%
5066 {The file currently documented seems to be wrong.^^J%
5067 Try to get a correct version.}%
5068 \fi
5069 \fi
5070 \fi
5071 \global\check@sum\m@ne}
5072 % \end{macrocode}
5073 % \end{macro}
5074 %
5075 %
5076 % \begin{tcounter}{\check@sum}
5077 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5078 % \begin{tcounter}{\bslash@cnt}
5079 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5080 % We need to define counters, |\bslash@cnt| for the number of
5081 % backslashes counted and |\check@sum| for the value advertised by the
5082 % file if any. A negative value means there is no checksum checking which is the default.
5083 % \changes{v2.1f}{2016/02/12}{Suppress \cs{CheckSum} check if no checksum
5084 % is specified in the file}
5085 % \begin{macrocode}
5086 \newcount\check@sum \check@sum = \m@ne
5087 \newcount\bslash@cnt \bslash@cnt = \z@
5088 % \end{macrocode}
5089 % \end{tcounter}
5090 % \end{tcounter}
5091 %
5092 %
5093 % \begin{omacro}{\CheckSum}
5094 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5095 % This is the interface to setting |\check@sum|.
5096 % \begin{macrocode}
5097 \def\CheckSum#1{\@bsphack\global\check@sum#1\relax\@esphack}
5098 % \end{macrocode}
5099 % \end{omacro}
5100 %
5101 %
5102 %
5103 % \begin{macro}{\step@checksum}
5104 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5105 % This advances the count when a backslash is encountered in the
5106 % macrocode.
5107 % \begin{macrocode}
5108 \def\step@checksum{\global\advance\bslash@cnt\@ne}
5109 % \end{macrocode}
5110 % \end{macro}
5111 %
5112 % \begin{omacro}{\CharacterTable}
5113 % The user interface to the character table-checking does some
5114 % |\catcode|ing and then compares the following table with the
5115 % stored version. We need to have |@| of type ``other'' within the
5116 % table since this is the way it is usually returned when reading
5117 % in a normal document. To nevertheless have a private letter we
5118 % use |~| for this purpose. |~| does no harm as a ``letter'' as it
5119 % comes last in the table and therefore will not gobble following
5120 % space.
5121 % \changes{v1.5m}{1989/09/20}{Macro added to check character translation
5122 % problems.}
5123 % \changes{v1.5q}{1989/11/01}{Made character table more readable.}
5124 % \changes{v1.5t}{1989/11/07}{Make \string\~{} letter in chartable
5125 % macros.}
5126 % \changes{v1.5u}{1989/11/14}{Made @ other in default table.}
5127 % \begin{macrocode}
5128 \def\CharacterTable{\begingroup \CharTableChanges \character@table}
5129 % \end{macrocode}
5130 % \end{omacro}
5131 %
5132 % \def\MakePrivateLetters{\catcode`\~=11\makeatletter}
5133 %
5134 % \begin{macro}{\character@table}
5135 % This does the work of comparing the tables and reporting the result.
5136 % Note that the following code is enclosed in a group
5137 % with |~| catcoded to letter.
5138 % \begin{macrocode}
5139 \begingroup
5140 \catcode`\~=11
5141 \gdef\character@table#1{\def\used~table{#1}%
5142 \ifx\used~table\default~table
5143 \typeout{***************************}%
5144 \typeout{* Character table correct *}%
5145 \typeout{***************************}%
5146 \else
5147 \PackageError{doc}{Character table corrupted}
5148 {\the\wrong@table}
5149 \show\default~table
5150 \show\used~table
5151 \fi
5152 \endgroup}
5153 % \end{macrocode}
5154 % \end{macro}
5155 %
5156 % \begin{omacro}{\CharTableChanges}
5157 % When the character table is read in we need to scan it with a
5158 % fixed set of |\catcode|s. The reference table below was defined by
5159 % assuming the normal |\catcode|s of \TeX{}, i.e.\ |@| is of type
5160 % other and the only token of type ``letter'' are the usual letters
5161 % of the alphabet. If, for some reason, other characters are made
5162 % ``letters'' then their |\catcode|s need to be restored before
5163 % checking the table. Otherwise spaces in the table are gobbled and
5164 % we get the information that the tables are different, even if
5165 % they are actually equal. For this reason |\CharTableChanges| can
5166 % be set up to locally restore the |\catcode|s of such ``letters''
5167 % to ``other''.
5168 % \begin{macrocode}
5169 \global\let\CharTableChanges\@empty
5170 % \end{macrocode}
5171 % \end{omacro}
5172 %
5173 % \begin{macro}{\default~table}
5174 % Here's what the table {\em should\/} look like (modulo spaces).
5175 % \begin{macrocode}
5176 \makeatother
5177 \gdef\default~table
5178 {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
5179 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
5180 Digits \0\1\2\3\4\5\6\7\8\9
5181 Exclamation \! Double quote \" Hash (number) \#
5182 Dollar \$ Percent \% Ampersand \&
5183 Acute accent \' Left paren \( Right paren \)
5184 Asterisk \* Plus \+ Comma \,
5185 Minus \- Point \. Solidus \/
5186 Colon \: Semicolon \; Less than \<
5187 Equals \= Greater than \> Question mark \?
5188 Commercial at \@ Left bracket \[ Backslash \\
5189 Right bracket \] Circumflex \^ Underscore \_
5190 Grave accent \` Left brace \{ Vertical bar \|
5191 Right brace \} Tilde \~}
5192 \endgroup
5193 % \end{macrocode}
5194 % \end{macro}
5195 % \let\MakePrivateLetters=\makeatletter
5196 %
5197 % \begin{macro}{\wrong@table}
5198 % \changes{v1.7a}{1992/02/28}{Moved to where the catcodes are right
5199 % so it works.}
5200 % We need a help message in case of problems.
5201 % \begin{macrocode}
5202 \newhelp\wrong@table{Some of the ASCII characters are corrupted.^^J
5203 I now \string\show\space you both tables for comparison.}
5204 % \end{macrocode}
5205 % \end{macro}
5206 %
5207 %
5208 % \subsection[Attaching line numbers to code lines]
5209 % {Attaching line numbers to code lines\footnotemark}
5210 % \footnotetext{Warning: the commentary was written by Dave
5211 % Love.}
5212 %
5213 %
5214 % The code in this section allows index entries to refer to code line
5215 % numbers---the number of the first line of macrocode in the
5216 % \env{macro} environment.
5217 %
5218 %
5219 % \begin{macro}{\codeline@index}
5220 % Indexing by code line is controlled by the |codeline@index| switch.
5221 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
5222 % \changes{v1.7a}{1992/02/24}{Documented code line no. support.}
5223 % \begin{imacro}{\CodelineNumbered}
5224 % \changes{v1.8a}{1993/05/19}{Macro added}
5225 % \begin{macrocode}
5226 \newif\ifcodeline@index \codeline@indexfalse
5227 \let\CodelineNumbered\codeline@indextrue
5228 % \end{macrocode}
5229 % \end{imacro}
5230 % \end{macro}
5231 %
5232 % \begin{macro}{\codeline@wrindex}
5233 % The code index entries are written out by |\special@index|. If
5234 % indexing is by code line this is |\let| to |\codeline@wrindex|;
5235 % if indexing is by page it is just |\index|. However, if
5236 % |\nofiles| is given, we omit writing such an index entry at all.
5237 % \changes{v1.7j}{1992/08/14}{Added \cs{if@filesw}.}
5238 % \begin{macrocode}
5239 \def\codeline@wrindex#1{\if@filesw
5240 \begingroup
5241 \set@display@protect
5242 \immediate\write\@indexfile
5243 {\string\indexentry{#1}%
5244 {\number\c@CodelineNo}}%
5245 \endgroup
5246 \fi}
5247 % \end{macrocode}
5248 % \end{macro}
5249 %
5250 % \begin{macro}{\special@index}
5251 % By default no index entries are written out.
5252 % \begin{macrocode}
5253 \let\special@index = \@gobble
5254 % \end{macrocode}
5255 % \end{macro}
5256 % \begin{macro}{\CodelineIndex}
5257 % \changes{v1.5u}{1989/11/14}{Added \cs{PageIndex} and
5258 % \cs{CodelineIndex} (Undoc)}
5259 % This switches on use of the index file with |\makeindex|, sets the
5260 % switch to indicate code line numbering and defines |\special@index|
5261 % appropriately.
5262 % \begin{macrocode}
5263 \def\CodelineIndex{\makeindex
5264 \codeline@indextrue
5265 \let\special@index\codeline@wrindex}
5266 % \end{macrocode}
5267 % \end{macro}
5268 % \begin{imacro}{\PageIndex}
5269 % |\PageIndex| is similar.
5270 % \begin{macrocode}
5271 \def\PageIndex{\makeindex
5272 \codeline@indexfalse
5273 \let\special@index\index}
5274 % \end{macrocode}
5275 % \end{imacro}
5276 %
5277 %
5278 % \begin{lcounter}{CodelineNo}
5279 % \changes{v1.5l}{1989/09/10}{Counter added to support code line
5280 % numbers}
5281 % \changes{v1.5y}{1990/02/24}{Default changed.}
5282 % \changes{v1.6b}{1990/06/15}{\cs{rm} moved before \cs{scriptsize} to
5283 % avoid unnecessary fontwarning.}
5284 % We need a counter to keep track of the line number.
5285 % \begin{macrocode}
5286 \newcount\c@CodelineNo \c@CodelineNo\z@
5287 % \end{macrocode}
5288 % \end{lcounter}
5289 %
5290 % \begin{macro}{\theCodelineNo}
5291 % \changes{v1.7a}{1992/02/25}{Existing definition not overwritten.}
5292 % \changes{v1.7a}{1992/03/12}{Use \cs{reset@font} for NFSS.}
5293 % This provides a hook to control the format of line numbers which may
5294 % be defined in a class file.
5295 % \begin{macrocode}
5296 \@ifundefined{theCodelineNo}
5297 {\ifx\selectfont\undefined
5298 \def\theCodelineNo{\rmfamily\scriptsize\arabic{CodelineNo}}%
5299 \else
5300 \def\theCodelineNo{\reset@font\scriptsize\arabic{CodelineNo}}%
5301 \fi}
5302 {}
5303 % \end{macrocode}
5304 % \end{macro}
5305 %
5306 %
5307 %
5308 %
5309 % \subsection{Layout Parameters for documenting package files}
5310 %
5311 % \begin{macro}{\tolerance}
5312 % People documenting package files would probably rather have things
5313 % ``sticking out'' in overfull |\hbox|es and poorish spacing,
5314 % because they probably don't want to spend a lot of time on making
5315 % all the line breaks perfect!
5316 % \begin{macrocode}
5317 \tolerance=1000\relax
5318 % \end{macrocode}
5319 % \end{macro}
5320 %
5321 %
5322 % The following |\mathcode| definitions allow the characters
5323 % `|\|'
5324 % and `\texttt{@}' to appear in |\ttfamily| font when invoked in math
5325 % mode;\footnote{You may wonder why the definitions state that both
5326 % characters belong to the {\em variable family\/}
5327 % (i.e.\ the number 7 in front). The reason is this:
5328 % Originally the \texttt{\bslash mathcode} of
5329 % \texttt{\bslash} was defined to be \texttt{"075C},
5330 % i.e.\ ordinary character number 92 (hex 5C) in
5331 % math family number 7 which is the typewriter family in
5332 % standard \LaTeX.
5333 % But this file should not depend on this specific
5334 % setting, so I changed these
5335 % \texttt{\bslash mathcode}$\,$s
5336 % to work with any family assignments. For an example
5337 % see the article about the new font selection scheme.}
5338 % particularly for something like |\@abc=1|.
5339 %
5340 % If an {\em old\/} version of the \pkg{german} package is in
5341 % force, then the `|"|' character is active and would upset the
5342 % definition of the \meta{16-bit number} quantities below, therefore
5343 % we change the |\catcode| of |"| inside a group, and use
5344 % |\global|.
5345 % \begin{macrocode}
5346 { \catcode`\"=12
5347 \global\mathcode`\\="705C \global\mathcode`\@="7040 }
5348 % \end{macrocode}
5349 % \MakeShortVerb{\"}
5350 %
5351 % \begin{macro}{\DocstyleParms}
5352 % This macro can be used, for example, to assign new values to
5353 % |\MacrocodeTopsep| and |\MacroIndent| and some other internal
5354 % registers. If it is already defined, the default definition
5355 % won't be carried out. Note that it is necessary to assign new
5356 % values via this macro if it should be done in a class file (like
5357 % \texttt{ltugboat.cls} for example) since the registers are
5358 % undefined before \texttt{doc.sty} is read in. The default values
5359 % for the internal registers are scattered over this file.
5360 % \changes{v1.5u}{1989/11/14}{\cs{DocStyleParms} now empty}
5361 % \changes{v2.1h}{2018/02/01}{Only use\cs{DocStyleParms} if defined
5362 % (previously the test defined it)}
5363 % \begin{macrocode}
5364 \@ifundefined{DocstyleParms}{}{\DocstyleParms}
5365 % \end{macrocode}
5366 % Clear out |\DocstyleParms| after use (or non-use).
5367 % \begin{macrocode}
5368 \let\DocstyleParms\relax
5369 % \end{macrocode}
5370 % \end{macro}
5371 %
5372 %
5373 %
5374 % \begin{macro}{\AmSTeX}
5375 % \changes{v1.5j}{1989/06/09}{Macro AmsTeX renamed to AmSTeX}
5376 % \begin{macro}{\BibTeX}
5377 % \begin{macro}{\SliTeX}
5378 % Here are a few definitions which can usefully be employed when
5379 % documenting package files: now we can readily refer to \AmSTeX,
5380 % \BibTeX\ and \SliTeX, as well as the usual \TeX\ and \LaTeX.
5381 % \begin{macrocode}
5382 \@ifundefined{AmSTeX}
5383 {\def\AmSTeX{\leavevmode\hbox{$\mathcal A\kern-.2em\lower.376ex%
5384 \hbox{$\mathcal M$}\kern-.2em\mathcal S$-\TeX}}}{}
5385 \@ifundefined{BibTeX}
5386 {\def\BibTeX{{\rmfamily B\kern-.05em%
5387 \textsc{i\kern-.025em b}\kern-.08em%
5388 T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}}{}
5389 \@ifundefined{SliTeX}
5390 {\def\SliTeX{{\rmfamily S\kern-.06emL\kern-.18em\raise.32ex\hbox
5391 {\scshape i}\kern -.03em\TeX}}}{}
5392 % \end{macrocode}
5393 % \end{macro}
5394 % \end{macro}
5395 % \end{macro}
5396 % \begin{macro}{\PlainTeX}
5397 % \changes{v1.5g}{1989/05/07}{space between plain and TeX changed.}
5398 % \begin{macro}{\Web}
5399 % There's even a \PlainTeX{} and a \Web.
5400 % \begin{macrocode}
5401 \@ifundefined{PlainTeX}{\def\PlainTeX{\textsc{Plain}\kern2pt\TeX}}{}
5402 \@ifundefined{Web}{\def\Web{\textsc{Web}}}{}
5403 % \end{macrocode}
5404 % \end{macro}
5405 % \end{macro}
5406 %
5407 %
5408 % \subsection{Changing the \texttt{\protect\bslash catcode} of \%}
5409 %
5410 % \begin{imacro}{\MakePercentIgnore}
5411 % \begin{imacro}{\MakePercentComment}
5412 % And finally the most important bit: we change the |\catcode|
5413 % of `|%|' so that it is ignored (which is how we are able to
5414 % produce this document!). We provide two commands to do the actual
5415 % switching.
5416 %^^A The |\MakePercentIgnore| is then called as the
5417 %^^A last command in this file.
5418 % \begin{macrocode}
5419 \def\MakePercentIgnore{\catcode`\%9\relax}
5420 \def\MakePercentComment{\catcode`\%14\relax}
5421 % \end{macrocode}
5422 % \end{imacro}
5423 % \end{imacro}
5424 %
5425 % \begin{imacro}{\DocInput}
5426 % The two macros above are now used to define the |\DocInput| macro
5427 % which was introduced in version v1.5l (or so) of the \DOC{}
5428 % package. In older versions |\MakePercentIgnore| was placed
5429 % at the very end of \texttt{doc.sty}.
5430 % \begin{macrocode}
5431 \def\DocInput#1{\MakePercentIgnore\input{#1}\MakePercentComment}
5432 % \end{macrocode}
5433 % \end{imacro}
5434 %
5435 % \subsection{GetFileInfo}
5436 %
5437 % \begin{macro}{\GetFileInfo}
5438 % \changes{v1.9o}{1994/05/08}{Macro added}
5439 % \changes{v1.9z}{1997/02/05}{Missing percent latex/2404}
5440 % Define |\filedate| and friends from info in the
5441 % |\ProvidesPackage| etc.\ commands.
5442 % \begin{macrocode}
5443 \def\GetFileInfo#1{%
5444 \def\filename{#1}%
5445 \def\@tempb##1 ##2 ##3\relax##4\relax{%
5446 \def\filedate{##1}%
5447 \def\fileversion{##2}%
5448 \def\fileinfo{##3}}%
5449 \edef\@tempa{\csname ver@#1\endcsname}%
5450 \expandafter\@tempb\@tempa\relax? ? \relax\relax}
5451 % \end{macrocode}
5452 % \end{macro}
5453 %
5454
5455
5456
5457
5458 % \section{Integrating hypdoc}
5459 %
5460 % If the option \texttt{hyperref} is selected (which is the
5461 % default), then we load the \pkg{hypdoc} package. We do that as
5462 % late as possible so that we don't generate option clashes if it
5463 % is also loaded in the preamble. That package currently changes
5464 % more commands than it should (not knowing about their new
5465 % definitions defined below) so we have to save and restore a few.
5466 %
5467 % Midterm all this code in \pkg{hypdoc} should be directly included
5468 % in \DOC. For now, while they are separate we have to do this
5469 % juggling.
5470 % \begin{macrocode}
5471 \AddToHook{begindocument/before}[doc/hyperref]{%
5472 \ifdoc@hyperref
5473 % \end{macrocode}
5474 % Annoying to code around issue \#22
5475 % \begin{macrocode}
5476 \expandafter\let\expandafter\doc@eoph@@k\csname doc.sty-h@@k\endcsname
5477 % \end{macrocode}
5478 % We require the package without any option so if it was already
5479 % loaded there is no option clash.
5480 % \changes{v3.0q}{2024/06/04}{Use hooks to save and restore
5481 % definitions when hypdoc gets loaded (gh/1000)}
5482 % \begin{macrocode}
5483 \RequirePackage{hypdoc}
5484 \expandafter\let\csname doc.sty-h@@k\endcsname\doc@eoph@@k
5485 % \end{macrocode}
5486 % The package adds new definitions for \cs{special@index} into
5487 % \cs{CodelineIndex} and \cs{PageIndex} but since we might be loading it
5488 % very late we are already past them (in the preamble). So we test
5489 % the final state and do it here, if necessary.
5490 % \begin{macrocode}
5491 \ifx\special@index\@gobble % do we write index entries at all?
5492 \else
5493 \ifcodeline@index
5494 \let\special@index\HD@codeline@wrindex
5495 \else
5496 \let\special@index\HD@page@wrindex
5497 \fi
5498 \fi
5499 % \end{macrocode}
5500 % The \pkg{amsmath} documentation uses \cs{env} in headings and
5501 % with \pkg{hyperref} enabled this causes trouble in bookmarks.
5502 % \fmi{fix elsewhere eventually}
5503 % \begin{macrocode}
5504 \AddToHook{class/amsdtx/after}{%
5505 \pdfstringdefDisableCommands{\let\env\@empty }}%
5506 % \end{macrocode}
5507 % That package also adds extra code into |\index| entries but it doesn't
5508 % know about all the stuff that \DOC does (now). So we need to provide
5509 % us with two helpers that handle the |\encapchar| case in some entries.
5510 % \begin{macrocode}
5511 \def\doc@providetarget{\HD@target}%
5512 \def\doc@handleencap#1{\encapchar hdclindex{\the\c@HD@hypercount}{#1}}%
5513 % \end{macrocode}
5514 % If that package is not loaded these helpers do little to nothing.
5515 % \begin{macrocode}
5516 \else
5517 \let\doc@providetarget\@empty
5518 \def\doc@handleencap#1{\encapchar #1}%
5519 % \end{macrocode}
5520 % We define the next commands just in case the user changed the option
5521 % \texttt{hyperref} from \texttt{true} to \texttt{false} without
5522 % removing the auxiliary files.
5523 % \begin{macrocode}
5524 \def\hdclindex#1#2{\ifx\@nil#2\@nil\else\csname #2\expandafter\endcsname\fi}%
5525 \def\hdpindex #1{\ifx\@nil#1\@nil\else\csname #1\expandafter\endcsname\fi}%
5526 \fi
5527 }
5528 % \end{macrocode}
5529 %
5530 %
5531 %
5532 %
5533 %
5534 % \section{Integrating the \DOX package code}
5535 %
5536 % The code in this section is largely taken over from the \DOX package
5537 % by Didier with only minor modifications (so far). This means it is a
5538 % bit back and forth and both the code and the documentation need
5539 % further updates.
5540 %
5541 % \subsection{\DOX environments}
5542
5543 % \begin{macro}{\@doc@env,\@doc@env@}
5544 % \fmi{original doc -- fix}
5545 % \marg{are-we-macrolike}\marg{item}\marg{indextype}\marg{name}\\
5546 % In \texttt{doc.sty}, the \texttt{macro} and \texttt{environment}
5547 % environments go through the \cs{m@cro@} macro which implements specific
5548 % parts by testing a boolean condition as its first argument. This mechanism
5549 % is not extensible, so I have to hack away a more generic version that
5550 % would work for any new \texttt{dox} item, only which looks pretty much
5551 % like the original one (with the addition of options management).
5552 %
5553 % First step is to see if we have a comma-separated list of names
5554 % in |#3| and if so we call the macro doing the work individually
5555 % for each
5556 % \begin{macrocode}
5557 \ExplSyntaxOn
5558 % \end{macrocode}
5559 %
5560 % \begin{macrocode}
5561 \long\def\@doc@env#1#2#3{
5562 % \end{macrocode}
5563 % The |\endgroup| here closes the scanning of names (using special catcodes).
5564 % \begin{macrocode}
5565 \endgroup
5566 \clist_map_inline:nn {#3} { \@doc@env@{#1}{#2}{##1} }
5567 }
5568
5569 \ExplSyntaxOff
5570 % \end{macrocode}
5571 %
5572 % And here is the payload for each name from the given list:
5573 % \begin{macrocode}
5574 \long\def\@doc@env@#1#2#3{%
5575 \topsep\MacroTopsep
5576 \trivlist
5577 \edef\saved@macroname{\string#3}%
5578 % \end{macrocode}
5579 % Since version 2.1g, \texttt{doc} creates a \cs{saved@indexname} command
5580 % which in used by \cs{changes}. We now support that as well. The expansion of
5581 % this command depends on whether the documented item is macrolike or not,
5582 % which we don't know here (it's only known by \cs{NewDocElement}). That's why we
5583 % need one specific command generating \cs{saved@indexname} the right way for
5584 % every single item. These commands are
5585 % named\cs{@Save\meta{item}IndexName};
5586 % they are technically part of the generated API, only not meant for public
5587 % use.
5588 %
5589 % \fmi{above docu is no longer right (but code probably needs further changes
5590 % anyway)}
5591 %
5592 % |#1| is either \texttt{TT} (for true = macrolike) or \texttt{TF}.
5593 % If true then we drop the first char from |\saved@macroname| and
5594 % store the result in |\saved@indexname| and use the latter for
5595 % sorting in the index.
5596 % \begin{macrocode}
5597 \if #1%
5598 \edef\saved@indexname{\expandafter\@gobble\saved@macroname}%
5599 %
5600 % \end{macrocode}
5601 % If the \DOC element described is macrolike but not a normal
5602 % ``macro'' then its type should be recorded and this is the places
5603 % where this happens. For macros (which should make up the bulk of
5604 % these items) we don't do this and for anything else that looks
5605 % from an indexing perspective like a macro we don't do that either
5606 % to keep the list of exceptions small. That would be the case if
5607 % the indexing command |\Code|\meta{doc-element}|Index| is
5608 % equivalent to \cs{CodeMacroIndex}.
5609 % \begin{macrocode}
5610 \expandafter\ifx
5611 \csname Code#2Index\endcsname
5612 \CodeMacroIndex
5613 \else
5614 \record@index@type@save
5615 {\saved@indexname}{#2}%
5616 \fi
5617 \else
5618 \let\saved@indexname\saved@macroname
5619 \fi
5620 %
5621 \def\makelabel##1{\llap{##1}}%
5622 \if@inlabel
5623 \let\@tempa\@empty
5624 \count@\macro@cnt
5625 \loop\ifnum\count@>\z@
5626 \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne
5627 \repeat
5628 \edef\makelabel##1{\llap{\vtop to\baselineskip{\@tempa\hbox{##1}\vss}}}%
5629 \advance\macro@cnt\@ne
5630 \else
5631 \macro@cnt\@ne
5632 \fi
5633 \ifdoc@noprint
5634 \item
5635 \else
5636 \edef\@tempa{%
5637 \noexpand\item[%
5638 % \end{macrocode}
5639 % The second notable modification to the original macro involves dynamically
5640 % constructing the name of the print macro:
5641 % \begin{macrocode}
5642 \noexpand\doc@providetarget
5643 \noexpand\strut
5644 \noexpand\@nameuse{Print#2Name}{\saved@macroname}]}%
5645 \@tempa
5646 \fi
5647 \ifdoc@noindex\else
5648 \global\advance\c@CodelineNo\@ne
5649 % \end{macrocode}
5650 % and the third one involves dynamically constructing the name of the index
5651 % macro:
5652 % \begin{macrocode}
5653 \csname SpecialMain#2Index\expandafter\endcsname
5654 \expandafter{\saved@macroname}\nobreak
5655 \global\advance\c@CodelineNo\m@ne
5656 \fi
5657 % \end{macrocode}
5658 % Suppress further |\index| entries when we are within a
5659 % \texttt{macrolike} environment. There is no point doing that for
5660 % non-\texttt{macrolike} environments are index entries are only
5661 % generated for items starting with a backslash anyway.
5662 % \fmi{fix}
5663 % \begin{macrocode}
5664 \if#1\expandafter\DoNotIndex \expandafter {\saved@macroname}\fi
5665 \ignorespaces}
5666 % \end{macrocode}
5667 % \end{macro}
5668 %
5669 %
5670 %
5671 %
5672 %
5673 %
5674 % \begin{macro}{\doc@env}
5675 % \marg{true-value}\marg{item}\oarg{options}\\
5676 % Handle optional arguments and call \cs{@doc@env}. Because environments can
5677 % be nested, we can't rely on grouping for getting options default values.
5678 % Hence, we need to reset the options at every call.
5679 % \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
5680 % \begin{macrocode}
5681 \def\doc@env#1#2[#3]{%
5682 \@nameuse{doc@noprint\doc@noprintdefault}%
5683 \@nameuse{doc@noindex\doc@noindexdefault}%
5684 \csname keys_set:nn\endcsname{doc}{#3}%
5685 \begingroup
5686 \ifdoc@outer
5687 \catcode`\\12
5688 \fi
5689 \MakePrivateLetters
5690 \@doc@env{#1}{#2}%
5691 }
5692 % \end{macrocode}
5693 % \end{macro}
5694
5695
5696
5697 % \subsection{\DOC descriptions}
5698 %
5699 % \begin{macro}{\@doc@describe}
5700 % \marg{item}\marg{name}\\
5701 % \begin{macrocode}
5702 \def\@doc@describe#1#2{%
5703 \ifdoc@noprint\else
5704 \marginpar{\raggedleft
5705 % \end{macrocode}
5706 % The hyperref target has to be in horizontal mode (which is the
5707 % case if it is after the \cs{strut}).
5708 % \begin{macrocode}
5709 \strut
5710 \doc@providetarget
5711 \@nameuse{PrintDescribe#1}{#2}}%
5712 \fi
5713 \ifdoc@noindex\else
5714 \@nameuse{Special#1Index}{#2}%
5715 \fi
5716 \@esphack
5717 \endgroup
5718 \ignorespaces}
5719 % \end{macrocode}
5720 % \end{macro}
5721 % \begin{macro}{\doc@describe}
5722 % \marg{item}\oarg{options}\\
5723 % Handle optional arguments and call \cs{@doc@describe}.
5724 % \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
5725 % \begin{macrocode}
5726 \def\doc@describe#1[#2]{%
5727 \leavevmode\@bsphack
5728 \csname keys_set:nn\endcsname{doc}{#2}%
5729 \@doc@describe{#1}}
5730 % \end{macrocode}
5731 % \end{macro}
5732 %
5733 %
5734 %
5735 %
5736 % \subsection{API construction}
5737 %
5738 %
5739 % \begin{macro}{\@temptokenb}
5740 % A scratch register (which may have been defined elsewhere)
5741 % \begin{macrocode}
5742 \@ifundefined{temptokenb}{\newtoks\@temptokenb}{}
5743 % \end{macrocode}
5744 % \end{macro}
5745 %
5746 %
5747 % \begin{macro}{\doc@createspecialmainindex}
5748 % \marg{item}\marg{idxtype}\marg{idxcat}
5749 % \begin{macro}{\doc@createspecialmainmacrolikeindex}
5750 % \marg{item}\marg{idxtype}\marg{idxcat}\\
5751 % \fmi{original doc -- fix}
5752 % The ``macrolike'' version does something similar to |doc|'s
5753 % \cs{SpecialIndex@} macro, but simplified. Let's just hope nobody will ever
5754 % define \verb*|\ | or nonletter macros as macrolike \DOC elements\ldots
5755 % \begin{macrocode}
5756 \def\doc@createspecialindexes#1#2#3{%
5757 % \end{macrocode}
5758 %
5759 % \begin{macrocode}
5760 \@temptokena{\space (#2)}%
5761 \@temptokenb{#3:}%
5762 % \end{macrocode}
5763 %
5764 % \begin{macrocode}
5765 \@nameedef{SpecialMain#1Index}##1{%
5766 \noexpand\@bsphack
5767 \ifdoc@toplevel
5768 \noexpand\special@index{##1\noexpand\actualchar
5769 {\string\ttfamily\space##1}%
5770 \ifx\@nil#2\@nil\else \the\@temptokena \fi
5771 \noexpand\encapchar main}%
5772 \fi
5773 \ifx\@nil#3\@nil\else
5774 \noexpand\special@index{\the\@temptokenb\noexpand\levelchar
5775 ##1\noexpand\actualchar{\string\ttfamily\space##1}%
5776 \noexpand\encapchar main}%
5777 \fi
5778 \noexpand\@esphack}%
5779 % \end{macrocode}
5780 %
5781 % \begin{macrocode}
5782 \@nameedef{Special#1Index}##1{%
5783 \noexpand\@bsphack
5784 \ifdoc@toplevel
5785 \noexpand\doc@providetarget
5786 \noexpand\index{##1\noexpand\actualchar{\string\ttfamily\space##1}%
5787 \ifx\@nil#2\@nil\else \the\@temptokena \fi
5788 \noexpand\doc@handleencap{usage}}%
5789 \fi
5790 \ifx\@nil#3\@nil\else
5791 \noexpand\index{\the\@temptokenb\noexpand\levelchar
5792 ##1\noexpand\actualchar{\string\ttfamily\space##1}%
5793 \noexpand\doc@handleencap{usage}}%
5794 \fi
5795 \noexpand\@esphack}}
5796 % \end{macrocode}
5797 %
5798 % \begin{macrocode}
5799 \def\doc@createspecialmacrolikeindexes#1#2#3{%
5800 % \end{macrocode}
5801 %
5802 % \begin{macrocode}
5803 \@temptokena{\space (#2)}%
5804 \@temptokenb{#3:}%
5805 % \end{macrocode}
5806 %
5807 % \begin{macrocode}
5808 \@nameedef{Code#1Index}##1##2{%
5809 \noexpand\@SpecialIndexHelper@##2\noexpand\@nil
5810 \noexpand\@bsphack
5811 \noexpand\ifdoc@noindex\noexpand\else
5812 \ifdoc@toplevel
5813 \noexpand\special@index{\noexpand\@gtempa\noexpand\actualchar
5814 \string\verb% % to fool emacs highlighting
5815 \noexpand\quotechar*\noexpand\verbatimchar
5816 \noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
5817 \ifx\@nil#2\@nil\else \the\@temptokena \fi
5818 \noexpand\encapchar ##1}%
5819 \fi
5820 \ifx\@nil#3\@nil\else
5821 \noexpand\special@index{\the\@temptokenb\noexpand\levelchar
5822 \noexpand\@gtempa\noexpand\actualchar
5823 \string\verb% % to fool emacs highlighting
5824 \noexpand\quotechar*\noexpand\verbatimchar
5825 \noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
5826 \noexpand\encapchar ##1}%
5827 \fi
5828 \noexpand\fi
5829 \noexpand\@esphack}%
5830 % \end{macrocode}
5831 %
5832 % \begin{macrocode}
5833 \@nameedef{SpecialMain#1Index}##1{%
5834 \expandafter\noexpand\csname Code#1Index\endcsname
5835 {main}{##1}}%
5836 % \end{macrocode}
5837 %
5838 % \begin{macrocode}
5839 \@nameedef{Special#1Index}##1{%
5840 \noexpand\@SpecialIndexHelper@##1\noexpand\@nil
5841 \noexpand\@bsphack
5842 \noexpand\ifdoc@noindex\noexpand\else
5843 \ifdoc@toplevel
5844 \noexpand\doc@providetarget
5845 \noexpand\index{\noexpand\@gtempa\noexpand\actualchar
5846 \string\verb% % to fool emacs highlighting
5847 \noexpand\quotechar*\noexpand\verbatimchar
5848 \noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
5849 \ifx\@nil#2\@nil\else \the\@temptokena \fi
5850 \noexpand\doc@handleencap{usage}}%
5851 \fi
5852 \ifx\@nil#3\@nil\else
5853 \noexpand\index{\the\@temptokenb\noexpand\levelchar
5854 \noexpand\@gtempa\noexpand\actualchar
5855 \string\verb% % to fool emacs highlighting
5856 \noexpand\quotechar*\noexpand\verbatimchar
5857 \noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
5858 \noexpand\doc@handleencap{usage}}%
5859 \fi
5860 \noexpand\fi
5861 \noexpand\@esphack}}
5862 % \end{macrocode}
5863 % \end{macro}
5864 % \end{macro}
5865
5866
5867
5868 % \begin{macro}{\doc@createdescribe}
5869 % \marg{item}
5870 % \begin{macrocode}
5871 \def\doc@createdescribe#1{%
5872 \@namedef{Describe#1}{%
5873 % \end{macrocode}
5874 % Because of the optional argument we have to set
5875 % |\MakePrivateLetters| already before parsing that (fingers
5876 % crossed). Otherwise incorrect but quite common usage, such as
5877 % |\DescribeMacro\foo@bar| will break because the scan for the
5878 % optional argument will tokenize the following input (i.e., |\foo|
5879 % in that case) before the |@| sign becomes a letter. As a result
5880 % |DescribeMacro| would receive only |\foo| as its argument.
5881 % \begin{macrocode}
5882 \begingroup
5883 \MakePrivateLetters
5884 \@ifnextchar[%]
5885 {\doc@describe{#1}}{\doc@describe{#1}[]}}}
5886 % \end{macrocode}
5887 % \end{macro}
5888 %
5889 %
5890 % \begin{macro}{\doc@createenv}
5891 % \marg{item}\marg{envname}
5892 % \begin{macrocode}
5893 \def\doc@createenv#1#2#3{%
5894 \@namedef{#3}{%
5895 \@ifnextchar[%]
5896 {\doc@env{#1}{#2}}{\doc@env{#1}{#2}[]}}%
5897 % \end{macrocode}
5898 % Instead of |\let|ting the end of the environment to
5899 % |\endtrivlist| we use one level of expansion. This way any
5900 % possible change in that environment (if that ever happens) is
5901 % properly reflected.
5902 % \begin{macrocode}
5903 \@namedef{end#3}{\endtrivlist}%
5904 % \expandafter\let\csname end#3\endcsname\endtrivlist
5905 }
5906 % \end{macrocode}
5907 % \end{macro}
5908
5909
5910 %
5911 % \begin{macro}{\@nameedef}
5912 %
5913 % \begin{macrocode}
5914 \def\@nameedef#1{\expandafter\edef\csname #1\endcsname}
5915 % \end{macrocode}
5916 % \end{macro}
5917
5918 %
5919 % \subsection{API creation}
5920 %
5921 % The whole user interface is created in one macro call.
5922 %
5923 %\begin{verbatim}
5924 % defaults:
5925 %
5926 % idxtype = #3
5927 % idxgroup = #3s
5928 % printtype =
5929 %\end{verbatim}
5930
5931
5932
5933 % \begin{macro}{\doc@declareerror}
5934 %
5935 % \begin{macrocode}
5936 \def\doc@declareerror#1#2{%
5937 \PackageError{doc}{Doc element '#1/#2' already defined?\@gobble}%
5938 {There is already a definition for
5939 '\string\Print#1Name',\MessageBreak
5940 '\string\PrintDescribe#1'
5941 or the environment '#2'.\MessageBreak
5942 Maybe you are overwriting something by mistake!\MessageBreak
5943 Otherwise use '\string\RenewDocElement' instead.}%
5944 }
5945 % \end{macrocode}
5946 % \end{macro}
5947
5948 % \begin{macro}{\doc@notdeclarederror}
5949 %
5950 % \begin{macrocode}
5951 \def\doc@notdeclarederror#1#2{%
5952 \PackageError{doc}{Doc element '#1/#2' unknown}%
5953 {I expected an existing definition for
5954 '\string\Print#1Name',\MessageBreak
5955 '\string\PrintDescribe#1' and
5956 the environment '#2' but\MessageBreak
5957 not all of them are defined.\MessageBreak
5958 Maybe you wanted to use
5959 '\string\NewDocElement'?}%
5960 }
5961 % \end{macrocode}
5962 % \end{macro}
5963 %
5964 % \begin{macro}{\doc@ignoredinfo}
5965 %
5966 % \begin{macrocode}
5967 \def\doc@ignoredinfo#1#2{%
5968 \PackageInfo{doc}{Doc element '#1/#2' declaration
5969 ignored}%
5970 }
5971 % \end{macrocode}
5972 % \end{macro}
5973 %
5974 %
5975 % \begin{imacro}{\NewDocElement}
5976 % \oarg{options}\marg{name}\marg{envname}
5977 %
5978 % \begin{macrocode}
5979 \newcommand\NewDocElement[3][]{%
5980 % \end{macrocode}
5981 %
5982 % \begin{macrocode}
5983 \@ifundefined{Print#2Name}%
5984 {\@ifundefined{PrintDescribe#2}%
5985 {\@ifundefined{#3}%
5986 {\@ifundefined{end#3}%
5987 {\@NewDocElement{#1}}%
5988 \doc@declareerror
5989 }\doc@declareerror
5990 }\doc@declareerror
5991 }\doc@declareerror
5992 {#2}{#3}%
5993 }
5994 % \end{macrocode}
5995 % \end{imacro}
5996 %
5997 % \begin{imacro}{\ProvideDocElement}
5998 % \oarg{options}\marg{name}\marg{envname}
5999 % This does nothing unless the doc element could be declared with
6000 % \cs{NewDocElement}.
6001 % \begin{macrocode}
6002 \newcommand\ProvideDocElement[3][]{%
6003 % \end{macrocode}
6004 %
6005 % \begin{macrocode}
6006 \@ifundefined{Print#2Name}%
6007 {\@ifundefined{PrintDescribe#2}%
6008 {\@ifundefined{#3}%
6009 {\@ifundefined{end#3}%
6010 {\@NewDocElement{#1}}%
6011 \doc@ignoredinfo
6012 }\doc@ignoredinfo
6013 }\doc@ignoredinfo
6014 }\doc@ignoredinfo
6015 {#2}{#3}%
6016 }
6017 % \end{macrocode}
6018 % \end{imacro}
6019 %
6020 %
6021 % \begin{imacro}{\RenewDocElement}
6022 % \oarg{options}\marg{name}\marg{envname}
6023 %
6024 % \begin{macrocode}
6025 \newcommand\RenewDocElement[3][]{%
6026 % \end{macrocode}
6027 %
6028 % \begin{macrocode}
6029 \@ifundefined{Print#2Name}\doc@notdeclarederror
6030 {\@ifundefined{PrintDescribe#2}\doc@notdeclarederror
6031 {\@ifundefined{#3}\doc@notdeclarederror
6032 {\@ifundefined{end#3}\doc@notdeclarederror
6033 {\@NewDocElement{#1}}%
6034 }%
6035 }%
6036 }%
6037 {#2}{#3}%
6038 }
6039 % \end{macrocode}
6040 % \end{imacro}
6041 %
6042 %
6043 % \begin{macro}{\@NewDocElement}
6044 % \marg{options}\marg{name}\marg{envname}
6045 %
6046 % \begin{macrocode}
6047 \def\@NewDocElement#1#2#3{%
6048 % \end{macrocode}
6049 %
6050 % \begin{macrocode}
6051 \doc@macrolikefalse
6052 \doc@topleveltrue
6053 % \end{macrocode}
6054 %
6055 % \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
6056 % \begin{macrocode}
6057 \def\doc@idxtype{#3}%
6058 \def\doc@idxgroup{#3s}%
6059 \let\doc@printtype\@empty
6060 \csname keys_set:nn\endcsname{doc}{#1}%
6061 % \end{macrocode}
6062 % \begin{imacro}{\Print...Name}
6063 % \marg{name}
6064 % \fmi{extremely messy this with so many \cs{expandafter}s \ldots{}
6065 % should reimplement in expl3}
6066 % \begin{macrocode}
6067 \ifx\doc@printtype\@empty
6068 \@temptokena{}%
6069 \else
6070 \@temptokena\expandafter{\expandafter
6071 \textnormal\expandafter{\expandafter
6072 \space\expandafter
6073 (\doc@printtype)}}%
6074 \fi
6075 \@nameedef{Print#2Name}##1{%
6076 {\noexpand\MacroFont
6077 \ifdoc@macrolike
6078 \noexpand\string
6079 \fi
6080 ##1%
6081 \the\@temptokena
6082 }}%
6083 % \end{macrocode}
6084 % \end{imacro}
6085 %
6086 % \begin{imacro}{\PrintDescribe...}
6087 % \marg{name}
6088 % \begin{macrocode}
6089 \expandafter\let\csname PrintDescribe#2\expandafter\endcsname
6090 \csname Print#2Name\endcsname
6091 % \end{macrocode}
6092 % \end{imacro}
6093 %
6094 % \begin{imacro}{\SpecialMain...Index}
6095 % \marg{name}
6096 % \begin{imacro}{\Special...Index}
6097 % \marg{name}
6098 % \begin{macrocode}
6099 \edef\doc@expr{%
6100 \ifdoc@macrolike
6101 \noexpand\doc@createspecialmacrolikeindexes
6102 \else
6103 \noexpand\doc@createspecialindexes
6104 \fi
6105 {#2}%
6106 }%
6107 \expandafter\expandafter\expandafter
6108 \doc@expr
6109 \expandafter\expandafter\expandafter
6110 {\expandafter\doc@idxtype\expandafter}\expandafter
6111 {\doc@idxgroup}%
6112 % \end{macrocode}
6113 % \end{imacro}
6114 % \end{imacro}
6115 %
6116 % \begin{imacro}{\Describe...}
6117 % \oarg{options}\marg{name}
6118 % \begin{macrocode}
6119 \doc@createdescribe{#2}%
6120 % \end{macrocode}
6121 % \end{imacro}
6122 %
6123 % \begin{environment}{\meta{DocElement}}
6124 % \fmi{can't have formatting in argument -- fix}
6125 % \oarg{options}\marg{name}
6126 % \begin{macrocode}
6127 \ifdoc@macrolike
6128 \doc@createenv{TT}{#2}{#3}%
6129 \else
6130 \doc@createenv{TF}{#2}{#3}%
6131 \fi
6132 }
6133 % \end{macrocode}
6134 % \end{environment}
6135 % \end{macro}
6136
6137
6138
6139
6140
6141 % \subsection{Setting up the default \DOC elements}
6142
6143 % \subsubsection{Macro facilities}
6144 %
6145 % Macros get only a single index entry (no index group, no index
6146 % type) and they do not get any label either when printing in the margin.
6147 % \begin{macrocode}
6148 \NewDocElement[macrolike = true ,
6149 idxtype = ,
6150 idxgroup = ,
6151 printtype =
6152 ]{Macro}{macro}
6153 % \end{macrocode}
6154
6155
6156 % \begin{macro}{\SpecialMainIndex}
6157 %
6158 % In \DOC v2 we had \cs{SpecialMainIndex} and
6159 % \cs{SpecialMainEnvIndex} but now with additional \DOC elements we
6160 % always add the element name after ``\texttt{Main}'' so this would
6161 % be \cs{SpecialMainMacroIndex}. We use |\def| not |\let| so any
6162 % redefinition of |\SpecialMainMacroIndex| will be transparent.
6163 % \begin{macrocode}
6164 \def\SpecialMainIndex{\SpecialMainMacroIndex}
6165 % \end{macrocode}
6166 % \end{macro}
6167
6168 % \begin{macro}{\SpecialUsageIndex}
6169 % \DOC v2 also had \cs{SpecialUsageIndex} which is now called
6170 % \cs{SpecialMacroIndex} generating the ``usage'' index entry for
6171 % a macro. Again we provide that as an alias via |\def|.
6172 %
6173 % In fact the documentation of \DOC v2 claimed that one can use
6174 % this for both macros and environments but that was never true as
6175 % for environments the result was that the first character was
6176 % dropped in sorting of the index. The correct way is to use
6177 % \cs{SpecialEnvIndex} for this.
6178 % \begin{macrocode}
6179 \def\SpecialUsageIndex{\SpecialMacroIndex}
6180 % \end{macrocode}
6181 % \end{macro}
6182 %
6183
6184 % \begin{macro}{\SpecialIndex}
6185 % \begin{macrocode}
6186 \def\SpecialIndex {\CodeMacroIndex{code}}
6187 % \end{macrocode}
6188 % \end{macro}
6189
6190
6191 %
6192 % \subsubsection{Environment facilities}
6193 %
6194 % Providing documentation support for environments. Here we differ
6195 % from \DOC V2 by marking the environments with ``(\textit{env.})''
6196 % when printing the name in the margin.
6197 % \begin{macrocode}
6198 \NewDocElement[macrolike = false ,
6199 idxtype = env. ,
6200 idxgroup = environments ,
6201 printtype = \textit{env.}
6202 ]{Env}{environment}
6203 % \end{macrocode}
6204 %
6205 %
6206 %
6207 % To be able to restore the definition after \pkg{hypdoc} is loaded
6208 % we better save them beforehand. We only load the package at the end of
6209 % the preamble, but the user might do this earlier and then chaos
6210 % is ensured. Thus, to support this generally we save them directly
6211 % before the package is loaded.
6212 % In this way the user can still alter the definition for
6213 % \cs{PrintDescribeMacro} and friends in the preamble.
6214 % \changes{v3.0q}{2024/06/04}{Use hooks to save and restore
6215 % definitions when hypdoc gets loaded (gh/1000)}
6216 % \begin{macrocode}
6217 \AddToHook{package/hypdoc/before}{%
6218 \let\@@PrintDescribeMacro \PrintDescribeMacro
6219 \let\@@PrintDescribeEnv \PrintDescribeEnv
6220 \let\@@PrintMacroName \PrintMacroName
6221 \let\@@PrintEnvName \PrintEnvName
6222 \let\@@SpecialUsageIndex \SpecialUsageIndex
6223 \let\@@SpecialEnvIndex \SpecialEnvIndex
6224 \let\@@SortIndex \SortIndex
6225 \let\@@DescribeMacro \DescribeMacro
6226 \let\@@DescribeEnv \DescribeEnv
6227 }
6228 % \end{macrocode}
6229 % After \pkg{hypdoc} got loaded we need to reset those macros
6230 % again. This is done in the generic hook
6231 % \texttt{package/hypdoc/after}.
6232 % \begin{macrocode}
6233 \AddToHook{package/hypdoc/after}{%
6234 \let\PrintDescribeMacro \@@PrintDescribeMacro
6235 \let\PrintDescribeEnv \@@PrintDescribeEnv
6236 \let\PrintMacroName \@@PrintMacroName
6237 \let\PrintEnvName \@@PrintEnvName
6238 \let\SpecialUsageIndex \@@SpecialUsageIndex
6239 \let\SpecialEnvIndex \@@SpecialEnvIndex
6240 \let\SortIndex \@@SortIndex
6241 \let\DescribeMacro \@@DescribeMacro
6242 \let\DescribeEnv \@@DescribeEnv
6243 }
6244 % \end{macrocode}
6245 %
6246 %
6247 % \section{Misc additions}
6248
6249 % \begin{imacro}{\cs}
6250 % \begin{macrocode}
6251 \DeclareRobustCommand\cs[1]{\texttt{\bslash #1}}
6252 % \end{macrocode}
6253 % \cls{amsdtx} has its own definition for \cs{cs} but that now
6254 % gets overwritten because the class loads \pkg{doc} afterwards. So
6255 % for now we reinstall it here.
6256 % \fmi{fix elsewhere}
6257 % \begin{macrocode}
6258 \AddToHook{class/amsdtx/after}{%
6259 \DeclareRobustCommand\cs[1]{%
6260 \@boxorbreak{%
6261 \ntt
6262 \addbslash#1\@empty
6263 \@xp\@xp\@xp\@indexcs\@xp\@nobslash\string#1\@nil
6264 }%
6265 }%
6266 \def\cn{\cs}%
6267 }
6268 % \end{macrocode}
6269 % \end{imacro}
6270
6271
6272 % We can now finish the \texttt{docstrip} main module.
6273 % \begin{macrocode}
6274 %</package>
6275 % \end{macrocode}
6276 %
6277 %
6278 % \Finale
6279 % \PrintChanges
6280 %
6281 %
6282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6283 \endinput
6284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6285
6286
6287
6288 ^^A Needed for emacs
6289 ^^A
6290 ^^A Local Variables:
6291 ^^A mode: latex
6292 ^^A coding: utf-8-unix
6293 ^^A End: