summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/base/ltxdoc.dtx
blob: 329353d12352c27c56408b0c60aa30e4206aa5cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
% \iffalse meta-comment
%
% Copyright 1993-2018
% The LaTeX3 Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the LaTeX base system.
% -------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%    https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This file has the LPPL maintenance status "maintained".
%
% The list of all files belonging to the LaTeX base distribution is
% given in the file `manifest.txt'. See also `legal.txt' for additional
% information.
%
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
%
% \fi
% \iffalse
%
%<class>\NeedsTeXFormat{LaTeX2e}
%<class>\ProvidesClass{ltxdoc}
%<class>         [2018/03/15 v2.0x Standard LaTeX documentation class]
%
%<*driver>
\documentclass{ltxdoc}
\GetFileInfo{ltxdoc.cls}
\providecommand\dst{\expandafter{\normalfont\scshape docstrip}}
\title{The file \texttt{ltxdoc.dtx} for use with
      \LaTeXe.\thanks{This file has version
           number \fileversion, dated \filedate.}\\[2pt]
      It contains the code for \texttt{ltxdoc.cls}}
\date{\filedate}
\author{David Carlisle}
\begin{document}
 \MaintainedByLaTeXTeam{latex}
 \maketitle
 \DocInput{ltxdoc.dtx}
\end{document}
%</driver>
%
% \fi
%
%
% \changes{v2.0i}{1994/04/29}{Update the documentation.}
% \changes{v2.0s}{1998/08/17}{(RmS) Documentation fixes.}
%
% \section{Documentation of the \LaTeX\ sources}
%
% This class file is designed for documenting the \LaTeX\ source files.
% You may however find it generally useful as a class for typesetting
% the documentation of files  produced in `doc' format.
%
% Each documented file in the standard distribution comes with extension
% |dtx|. The appropriate class package or initex file will be extracted
% from the source by the docstrip system. Each |dtx| file may be
% directly processed with \LaTeXe, for example
%\begin{verbatim}
% latex2e docclass.dtx
%\end{verbatim}
% would produce the documentation of the Class and package interface.
%
% Each file that is used in producing the \LaTeXe\ format (ie not
% including the standard class and packages) will be printed together in
% one document if you \LaTeX\ the file |sources2e.tex|. This has the
% advantage that one can produce a full index of macro usage across all
% the source files.
%
% If you need to customise the typesetting of any of these files, there
% are two options:
% \begin{itemize}
% \item You can use \dst\ with the module `driver' to extract a small
% \LaTeX\ file that you may edit to use whatever class or package
% options you require, before inputting the source file.
% \item You can create a file |ltxdoc.cfg|. This configuration file will
% be read whenever the |ltxdoc| class is used, and so can be used to
% customise the typesetting of all the source files, without having to
% edit lots of small driver files.
%\end{itemize}
%
% The second option is usually more convenient. Various possibilities
% are discussed in the next section.
%
% \section{Customisation}
%
% The simplest form of customisation is to pass more options to the
% |article| class which is loaded by |ltxdoc|. For instance if you wish
% all the documentation to be formatted for A4 paper, add the following
% line to |ltxdoc.cfg|:
%\begin{verbatim}
% \PassOptionsToClass{a4paper}{article}
%\end{verbatim}
%
% All the source files are in two parts, separated by |\StopEventually|.
% The first part (should) contain `user' documentation. The second part
% is a full documented listing of the source code. The |doc| package
% provides the command |\OnlyDescription| which suppresses the code
% listings. This may also be used in the configuration file, but as the
% |doc| package is read later, you must delay the execution of
% |\OnlyDescription| until after the |doc| package has been read. The
% simplest way is to use |\AtBeginDocument|. Thus you could put the
% following in your |ltxdoc.cfg|.
%\begin{verbatim}
% \AtBeginDocument{\OnlyDescription}
%\end{verbatim}
%
%
% If the full source listing |sources2e.tex| is processed, then an index
% and change history are produced by default, however indices are not
% normally produced for individual files.
%
% As an example, consider |ltclass.dtx|, which contains the sources for
% the new class and package interface commands.  With no |cfg|
% file, a 19~page document is produced. With the above configuration
% a slightly more readable document (4~pages) is produced.
%
% Conversely, if you really want to read the source listings in detail,
% you will want to have an index. Again the index commands provided by
% the doc package may be used, but their execution must be delayed.
%\begin{verbatim}
% \AtBeginDocument{\CodelineIndex\EnableCrossrefs}
% \AtEndDocument{\PrintIndex}
%\end{verbatim}
%
% The |doc| package writes index files to be sorted using MakeIndex with
% the |gind| style, so one would then use a command such as
%\begin{verbatim}
% makeindex -s gind.ist ltclass.idx
%\end{verbatim}
% and re-run \LaTeX.
%
% Similarly to print a Change history, you would add
%\begin{verbatim}
% \AtBeginDocument{\RecordChanges}
% \AtEndDocument{\PrintChanges}
%\end{verbatim}
% to |ltxdoc.cfg|, and use  MakeIndex with a command such as
%\begin{verbatim}
% makeindex -s gglo.ist -o ltclass.gls ltclass.glo
%\end{verbatim}
%
% Finally if you do not want to list all the sections of |source2e.tex|,
% you can use  |\includeonly| in the |cfg| file:
%\begin{verbatim}
% \includeonly{ltvers,ltboxes}
%\end{verbatim}
%
% \StopEventually{}
%
%
% \section{Options}
%
%    \begin{macrocode}
%<*class>
\DeclareOption{a5paper}{\@latexerr{Option not supported}%
   {}}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareOption*{%
    \PassOptionsToClass  {\CurrentOption}{article}}
%    \end{macrocode}
%
% \section{Configuration}
% Input a local configuration file, if it exists.
%    \begin{macrocode}
\InputIfFileExists{ltxdoc.cfg}
           {\typeout{*************************************^^J%
                     * Local config file ltxdoc.cfg used^^J%
                     *************************************}}
           {}
%    \end{macrocode}
%
%
% \section{Option Processing}
%
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}
%
% \section{Loading article and doc}
%
%    \begin{macrocode}
\LoadClass{article}
%    \end{macrocode}
%
%    \begin{macrocode}
\RequirePackage{doc}
%    \end{macrocode}
%
% Make \verb+|+ be a `short verb' character, but not in the document
% preamble, where an active character may interfere with packages that
% are loaded.
%    \begin{macrocode}
\AtBeginDocument{\MakeShortVerb{\|}}
%    \end{macrocode}
%
% As `doc' documents tend to have a lot of monospaced material,
% Set up some |tt| substitutions to occur silently.
% \changes{v2.0p}{1995/11/02}{Add font substitutions}
% \changes{v2.0t}{1999/04/17}{Replaced octal number, CAR}
%    \begin{macrocode}
\DeclareFontShape{OT1}{cmtt}{bx}{n}{<-> ssub * cmtt/m/n}{}
\DeclareFontFamily{OMS}{cmtt}{\skewchar\font 48}  % '60
\DeclareFontShape{OMS}{cmtt}{m}{n}{<-> ssub * cmsy/m/n}{}
\DeclareFontShape{OMS}{cmtt}{bx}{n}{<-> ssub * cmsy/b/n}{}
%    \end{macrocode}
% This substitution is in the standard fd file, but not silent.
%    \begin{macrocode}
\DeclareFontShape{OT1}{cmss}{m}{it}{<->ssub*cmss/m/sl}{}
%    \end{macrocode}
%
%    \begin{macrocode}
\CodelineNumbered
\DisableCrossrefs
%    \end{macrocode}
%
% Increase the text width slightly so that with the standard fonts
% 72 columns of code may appear in a |macrocode| environment.
% \changes{v2.0c}{1994/03/15}{Set \cs{textwidth}.}
%    \begin{macrocode}
\setlength{\textwidth}{355pt}
%    \end{macrocode}
%
% Increase the marginpar width slightly, for long command names.
% And increase the left margin by a similar amount
% \changes{v2.0l}
%      {1994/05/25}{Increase \cs{marginparwidth}}
% \changes{v2.0q}{1995/11/28}
%      {Increase \cs{marginparwidth} and page margin.}
%    \begin{macrocode}
\addtolength\marginparwidth{30pt}
\addtolength\oddsidemargin{20pt}
\addtolength\evensidemargin{20pt}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\setcounter{StandardModuleDepth}{1}
%    \end{macrocode}
%
% \section{Useful abbreviations}
%
% |\cmd{\foo}| Prints |\foo| verbatim. It may be used inside moving
% arguments. It can \emph{not} be use to record commands that are defined as
%    ``|\outer|'' nor is it possible to use it on conditionals such as
%    |\iftrue| or  defined by |\newif|.
% |\cs{foo}| also prints |\foo|, for those who prefer that
% syntax. (This second form can be used to record all types of command so the
%    above restrictions do not apply.
% \begin{macro}{\cmd}
% \changes{v2.0k}{1994/05/21}{New definition, so \cmd\{ works.}
% \begin{macro}{\cs}
% \changes{v2.0d}{1994/03/17}{Add \cs{cs}}
%    \begin{macrocode}
\def\cmd#1{\cs{\expandafter\cmd@to@cs\string#1}}
\def\cmd@to@cs#1#2{\char\number`#2\relax}
\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{v2.0r}{1996/01/11}{Removed \cs{star} since useless pr/2039}
%
% \begin{macro}{\marg}
% \changes{v2.0d}{1994/03/17}{Add \cs{marg}}
%    |\marg{text}| prints \marg{text}, `mandatory argument'.
%    \begin{macrocode}
\providecommand\marg[1]{%
  {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\oarg}
%    |\oarg{text}| prints \oarg{text}, `optional argument'.
%    \begin{macrocode}
\providecommand\oarg[1]{%
  {\ttfamily[}\meta{#1}{\ttfamily]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\parg}
%    |\parg{te,xt}| prints \parg{te,xt}, `picture mode argument'.
% \changes{v2.0h}{1994/04/28}{Add \cs{parg}}
% \changes{v2.0o}{1995/08/09}{Use \cs{meta} when showing arguments}
%    \begin{macrocode}
\providecommand\parg[1]{%
  {\ttfamily(}\meta{#1}{\ttfamily)}}
%    \end{macrocode}
% \end{macro}
%
%
% \section{Old Comments}
%
% The \LaTeXe\ sources contain a lot of code inherited from
% \LaTeX2.09. The comments in this code were not designed to be
% typeset, and do not contain the necessary \LaTeX\ markup. The
% \texttt{oldcomments} environment typesets these comments,
% automatically sensing when any control sequence appears, and
% implicitly adding the |\verb|. This procedure does not produce
% particularly beautiful pages, but it allows us to fully document new
% sections, and have some form of typeset comments on all the old
% code.
% \changes{v2.0e}{1994/03/18}{Use a fixed font.}
%
% Scan control names and put them in tt.
% Will actually (incorrectly) scan past |\\| but this does not matter as
% this is almost never followed by a letter in practice.
% (ie |\\foo|) would put |foo| in |\ttfamily|.
%    \begin{macrocode}
\def\oc@scan#1{%
  \ifx\oc@bslash#1%
                      \egroup\let\next\oc@bslash\else
  \ifcat a\noexpand#1%
                      #1\let\next\oc@scan\else
  \ifx\oc@percent#1%
                      \def\next{\char`\%\egroup}%
  \else
                      #1\let\next\egroup
  \fi\fi\fi\next}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\oc@bslash{\bgroup\oc@ttf\char`\\\oc@scan}%
%    \end{macrocode}
%
%    \begin{macrocode}
\def\oc@verb#1{%
  \catcode`#1\active
  \uccode`\~`#1%
  \uppercase{\def~{{\oc@ttf\char`#1}}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\begingroup
  \obeyspaces%
  \catcode`\/=\catcode`\\
  /catcode`/\/active
  /catcode`<=/catcode`{%
  /catcode`>=/catcode`}%
  /catcode`/{/active%
  /catcode`/}/active%
  /gdef/oldc< \end{oldcomments}>%
  /gdef/begmac<    \begin{macrocode}>%
  /gdef/obs</def <</oc@ttf/ >>>%
/endgroup%
%    \end{macrocode}
%
%    \begin{macrocode}
\begingroup
  \catcode`\/=\catcode`\\
  \catcode`\\=13
  /catcode`/|=/catcode`/%
  /catcode`/%=13
  /gdef/oldcomments{|
    /makeatletter
    /let/do/oc@verb/dospecials
    /frenchspacing/@vobeyspaces/obs
    /raggedright
    /oc@verb/>|
    /oc@verb/<|
    /let\/oc@bslash
    /let%/oc@percent
    /obeylines
    /parindent/z@
    /ttfamily/expandafter/let/expandafter/oc@ttf/the/font
    /rmfamily
    /hfuzz/maxdimen
    }
/endgroup
%    \end{macrocode}
%
%    \begin{macrocode}
\begingroup
  \sloppy%
  \obeylines%
  \gdef\oc@percent#1^^M{%
    \ifvmode%
    \def\commentline{#1}%
    \ifx\commentline\oldc%
    \end{oldcomments}%
    \else%
    \ifx\commentline\begmac%
    \begin{macrocode}%
    \else%
    \leavevmode%
    #1^^M%
    \fi\fi%
    \else%
    {\oc@ttf\char`\%}#1^^M%
    \fi}%
\endgroup%
%    \end{macrocode}
%
%
% \section{DocInclude}
%
%    \begin{macrocode}
\@addtoreset{CodelineNo}{part}
%    \end{macrocode}
%
% \begin{macro}{\DocInclude}
% More or less exactly the same as |\include|, but uses |\DocInput|
% on a |dtx| file, not |\input| on a |tex| file.
% \changes{v2.0b}{1994/03/14}{Rename from \cs{docinclude}}
% \changes{v2.0f}{1994/03/25}{Use \cs{part}}
% \changes{v2.0u}{1999/08/08}{Also works for .fdd (M. Schroeder)}
%    \begin{macrocode}
\def\partname{File}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\DocInclude}[1]{%
  \relax
  \clearpage
  \docincludeaux
  \IfFileExists{#1.fdd}%
    {\def\currentfile{#1.fdd}}%
    {\def\currentfile{#1.dtx}}%
  \ifnum\@auxout=\@partaux
    \@latexerr{\string\include\space cannot be nested}\@eha
  \else \@docinclude#1 \fi}
\def\@docinclude#1 {\clearpage
\if@filesw \immediate\write\@mainaux{\string\@input{#1.aux}}\fi
\@tempswatrue\if@partsw \@tempswafalse\edef\@tempb{#1}\@for
\@tempa:=\@partlist\do{\ifx\@tempa\@tempb\@tempswatrue\fi}\fi
\if@tempswa \let\@auxout\@partaux \if@filesw
\immediate\openout\@partaux #1.aux
\immediate\write\@partaux{\relax}\fi
%    \end{macrocode}
% We need to save (and later restore) various index-related
% commands which might be changed by the included file.
%    \begin{macrocode}
\let\@ltxdoc@PrintIndex\PrintIndex
\let\PrintIndex\relax
\let\@ltxdoc@PrintChanges\PrintChanges
\let\PrintChanges\relax
\let\@ltxdoc@theglossary\theglossary
\let\@ltxdoc@endtheglossary\endtheglossary
\part{\currentfile}%
  {\let\ttfamily\relax
  \xdef\filekey{\filekey, \thepart={\ttfamily\currentfile}}}%
\DocInput{\currentfile}%
\let\PrintIndex\@ltxdoc@PrintIndex
\let\PrintChanges\@ltxdoc@PrintChanges
\let\theglossary\@ltxdoc@theglossary
\let\endtheglossary\@ltxdoc@endtheglossary
\clearpage
\@writeckpt{#1}\if@filesw \immediate\closeout\@partaux \fi
\else\@nameuse{cp@#1}\fi\let\@auxout\@mainaux}
%    \end{macrocode}
%
% \changes{v2.0x}{2018/03/15}{Set up \cs{protect} in index entries}
%    \begin{macrocode}
\gdef\codeline@wrindex#1{\if@filesw
%    \end{macrocode}
%   Set \cs{protect} to a suitable value in the index entries (we
%   can't use |\set@display@protect| as that would result in different
%   numer of spaces after a command depending on the number of
%   expansion happening prior to writing the index).
%    \begin{macrocode}
      \begingroup
        \let\protect\noexpand
        \immediate\write\@indexfile
            {\string\indexentry{#1}%
            {\filesep\number\c@CodelineNo}}%
      \endgroup\fi}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\let\filesep\@empty
%    \end{macrocode}
%
%
%  \begin{macro}{\aalph}
% Special  form of |\alph| as currently |source2e.tex|
% includes more than 26 files
% \changes{v2.0n}{1994/05/27}{Use uppercase letters, for makeindex}.
%    \begin{macrocode}
\def\aalph#1{\@aalph{\csname c@#1\endcsname}}
\def\@aalph#1{%
  \ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or
         j\or k\or l\or m\or n\or o\or p\or q\or r\or s\or
         t\or u\or v\or w\or x\or y\or z\or A\or B\or C\or
         D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or
         N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or
         X\or Y\or Z\else\@ctrerr\fi}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\docincludeaux}
% \changes{v2.06}{1994/03/31}{Use \cs{footnotesize} in file key.}
% \changes{v2.0k}{1994/05/21}{Use \cs{aalph}}
% \changes{v2.0v}{2017/03/13}{Use \cs{parbox}[t] in file
%         key to maintain space between the text block and the page foot.}
%    \begin{macrocode}
\def\docincludeaux{%
  \def\thepart{\aalph{part}}\def\filesep{\thepart-}%
  \let\filekey\@gobble
  \g@addto@macro\index@prologue{%
    \gdef\@oddfoot{\parbox[t]{\textwidth}{\strut\footnotesize
       \raggedright{\bfseries File Key:} \filekey}}%
    \let\@evenfoot\@oddfoot}%
  \global\let\docincludeaux\relax
 \gdef\@oddfoot{%
   \expandafter\ifx\csname ver@\currentfile\endcsname\relax
    File \thepart: {\ttfamily\currentfile} %
   \else
    \GetFileInfo{\currentfile}%
    File \thepart: {\ttfamily\filename} %
    Date: \filedate\ %
    Version \fileversion
    \fi
    \hfill\thepage}%
 \let\@evenfoot\@oddfoot}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MaintainedByLaTeXTeam}
% \changes{v2.0v}{2015/03/25}{macro added}
% \changes{v2.0w}{2015/03/25}{use display block not footnote text}
% Generate boilerplate reference to bug database.
%    \begin{macrocode}
\def\MaintainedBy#1{\gdef\@maintainedby{#1}}
%    \end{macrocode}
%
%    \begin{macrocode}
\let\@maintainedby\@empty
%    \end{macrocode}
%
%    \begin{macrocode}
\def\MaintainedByLaTeXTeam#1{%
{\gdef\@maintainedby{%
This file is maintained by the \LaTeX{} Project team.\\%
Bug reports can be opened (category \texttt{#1}) at\\%
\url{https://latex-project.org/bugs.html}.}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@maketitle{%
  \newpage
  \null
  \vskip 2em%
  \begin{center}%
  \let \footnote \thanks
    {\LARGE \@title \par}%
    \vskip 1.5em%
    {\large
      \lineskip .5em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
    \vskip 1em%
    {\large \@date}%
    \ifx\@maintainedby\@empty
    \else
    \vskip 1em%
    \fbox{\fbox{\begin{tabular}{@{}l@{}}\@maintainedby\end{tabular}}}%
    \fi
  \end{center}%
  \par
  \vskip 1.5em}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\url}
%    \begin{macrocode}
\providecommand\url{\texttt}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\def\task#1#2{}
%</class>
%    \end{macrocode}
% \Finale
%