Debian Codegraph @

texmf-dist/source/latex/l3kernel/l3doc.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: l3doc.dtx
4 %
5 % Copyright (C) 1990-2026 The LaTeX Project
6 %
7 % It may be distributed and/or modified under the conditions of the
8 % LaTeX Project Public License (LPPL), either version 1.3c of this
9 % license or (at your option) any later version. The latest version
10 % of this license is in the file
11 %
12 % https://www.latex-project.org/lppl.txt
13 %
14 % This file is part of the "l3kernel bundle" (The Work in LPPL)
15 % and all files in that bundle must be distributed together.
16 %
17 % -----------------------------------------------------------------------
18 %
19 % The development version of the bundle can be found at
20 %
21 % https://github.com/latex3/latex3
22 %
23 % for those people who are interested.
24 %
25 %<*driver>
26 \def\nameofplainTeX{plain}
27 \ifx\fmtname\nameofplainTeX\else
28 \expandafter\begingroup
29 \fi
30 \input docstrip %
31 \askforoverwritefalse
32 \preamble
33
34 Copyright (C) 1990-2026 The LaTeX Project
35
36 It may be distributed and/or modified under the conditions of
37 the LaTeX Project Public License (LPPL), either version 1.3c of
38 this license or (at your option) any later version. The latest
39 version of this license is in the file:
40
41 https://www.latex-project.org/lppl.txt
42
43 This file is part of the "l3kernel bundle" (The Work in LPPL)
44 and all files in that bundle must be distributed together.
45
46 \endpreamble
47 % stop docstrip adding \endinput
48 \postamble
49 \endpostamble
50 \generate{\file{l3doc.cls}{\from{l3doc.dtx}{class,cfg}}}
51 %\generate{\file{l3doc.ist}{\from{l3doc.dtx}{docist}}}
52 \ifx\fmtname\nameofplainTeX
53 \expandafter\endbatchfile
54 \else
55 \expandafter\endgroup
56 \fi
57 %</driver>
58 %
59 %<*driver|class>
60 \RequirePackage{calc}
61 %</driver|class>
62 %
63 %<*driver>
64 \documentclass{l3doc}
65 \usepackage{framed}
66 \begin{document}
67 \DocInput{l3doc.dtx}
68 \end{document}
69 %</driver>
70 %
71 % This isn't included in the typeset documentation because it's a bit
72 % ugly:
73 %<*class>
74 \ProvidesExplClass{l3doc}{2026-05-15}{}
75 {L3 Experimental documentation class}
76 %</class>
77 % \fi
78 %
79 % \title{The \cls{l3doc} class -- experimental\thanks{%
80 % On popular request we now distribute the document for this
81 % experimental class. However, please note that it is by no means
82 % in final state and is \emph{likely} to undergo modifications,
83 % even \emph{incompatible ones}! Thus, using it might therefore
84 % require you to do updates, if the class changes.}}
85 %
86 % \author{\Team}
87 % \date{Released 2026-05-15}
88 % \maketitle
89 % \tableofcontents
90 %
91 % \begin{documentation}
92 %
93 %
94 % \section{Introduction}
95 %
96 % Code and documentation for this class have been written prior to the
97 % change of \pkg{doc} from version 2 to version 3, which already shows
98 % how far behind this class currently is. So take the following
99 % warning seriously please:
100 %
101 % \begin{quote}
102 % \textbf{It is much less stable than the main \pkg{expl3} packages.\\
103 % Use at own risk!}
104 % \end{quote}
105 %
106 % This is an ad-hoc class for documenting the \pkg{expl3} bundle, a
107 % collection of modules or packages that make up \LaTeX3's programming
108 % environment. Eventually it will replace the \cls{ltxdoc} class for
109 % \LaTeX3, but not before the good ideas in \pkg{hypdoc}, \cls{xdoc2},
110 % \pkg{docmfp}, and \cls{gmdoc} are incorporated.
111 %
112 % It is written as a \enquote{self-contained} docstrip file: executing
113 % |latex l3doc.dtx| generates the \file{l3doc.cls} file and typesets
114 % this documentation; execute |tex l3doc.dtx| to only generate
115 % \file{l3doc.cls}.
116 %
117 % \section{Features of other packages}
118 %
119 % This class builds on the \pkg{ltxdoc} class and the \pkg{doc} package,
120 % but in the time since they were originally written some improvements
121 % and replacements have appeared that we would like to use as
122 % inspiration.
123 %
124 % These packages or classes are \pkg{hypdoc}, \pkg{docmfp}, \pkg{gmdoc},
125 % and \pkg{xdoc}. I have summarized them below in order to work out
126 % what sort of features we should aim at a minimum for \pkg{l3doc}.
127 %
128 % \subsection{The \pkg{hypdoc} package}
129 %
130 % This package provides hyperlink support for the \pkg{doc} package. I
131 % have included it in this list to remind me that cross-referencing
132 % between documentation and implementation of methods is not very
133 % good. (\emph{E.g.}, it would be nice to be able to automatically
134 % hyperlink the documentation for a function from its implementation and
135 % vice-versa.)
136 %
137 % \subsection{The \pkg{docmfp} package}
138 %
139 % \begin{itemize}
140 % \item Provides \cs{DescribeRoutine} and the \env{routine}
141 % environment (etc.) for MetaFont and MetaPost code.
142 % \item Provides \cs{DescribeVariable} and the \env{variable}
143 % environment (etc.) for more general code.
144 % \item Provides \cs{Describe} and the \env{Code} environment
145 % (etc.) as a generalization of the above two
146 % instantiations.
147 % \item Small tweaks to the DocStrip system to aid non-\LaTeX{} use.
148 % \end{itemize}
149 %
150 % \subsection{The \pkg{xdoc2} package}
151 %
152 % \begin{itemize}
153 % \item Two-sided printing.
154 % \item \cs{NewMacroEnvironment}, \cs{NewDescribeEnvironment}; similar
155 % idea to \pkg{docmfp} but more comprehensive.
156 % \item Tons of small improvements.
157 % \end{itemize}
158 %
159 % \subsection{The \pkg{gmdoc} package}
160 %
161 % Radical re-implementation of \pkg{doc} as a package or class.
162 % \begin{itemize}
163 % \item Requires no |\begin{macrocode}| blocks!
164 % \item Automatically inserts |\begin{macro}| blocks!
165 % \item And a whole bunch of other little things.
166 % \end{itemize}
167 %
168 % \section{Problems \& Todo}
169 %
170 % Problems at the moment:
171 % (1)~not flexible in the types of things that can be documented;
172 % (2)~no obvious link between the |\begin{function}| environment for
173 % documenting things to the |\begin{macro}| function that's used
174 % analogously in the implementation.
175 %
176 % The \env{macro} should probably be renamed to \env{function} when it
177 % is used within an implementation section. But they should have the
178 % same syntax before that happens!
179 %
180 % Furthermore, we need another \enquote{layer} of documentation commands
181 % to account for \enquote{user-macro} as opposed to
182 % \enquote{code-functions}; the \pkg{expl3} functions should be
183 % documented differently, probably, to the \pkg{ltcmd} user macros (at
184 % least in terms of indexing).
185 %
186 % In no particular order, a list of things to do:
187 % \begin{itemize}
188 % \item Rename \env{function}/\env{macro} environments to better
189 % describe their use.
190 % \item Generalize \env{function}/\env{macro} for documenting
191 % \enquote{other things}, such as environment names, package
192 % options, even keyval options.
193 % \item New function like \tn{part} but for files (remove awkward
194 % \enquote{File} as \tn{partname}).
195 % \item Something better to replace \cs{StopEventually}; I'm thinking
196 % two environments \env{documentation} and \env{implementation} that
197 % can conditionally typeset/ignore their material. (This has been
198 % implemented but needs further consideration.)
199 % \item Hyperlink documentation and implementation of macros (see the
200 % \textsc{dtx} file of \pkg{svn-multi} v2 as an example). This is
201 % partially done, now, but should be improved.
202 % \end{itemize}
203 %
204 % \section{Documentation}
205 %
206 % \subsection{Configuration}
207 %
208 % Before class options are processed, \pkg{l3doc} loads a configuration
209 % file \file{l3doc.cfg} if it exists, allowing you to customize the
210 % behavior of the class without having to change the documentation
211 % source files.
212 %
213 % For example, to produce documentation on letter-sized paper instead of
214 % the default A4 size, create \file{l3doc.cfg} and include the line
215 % \begin{verbatim}
216 % \PassOptionsToClass{letterpaper}{l3doc}
217 % \end{verbatim}
218 %
219 % By default, \pkg{l3doc} selects the |T1| font encoding and loads the
220 % Latin Modern fonts. To prevent this, use the class option
221 % |cm-default|.
222 %
223 % \subsection{Class options}
224 %
225 % The class recognizes a number of options, some of which are generally
226 % useful and some of which are aimed squarely at use by the kernel team only.
227 %
228 % \DescribeOption{full}
229 % \DescribeOption{onlydoc}
230 % When the \texttt{full} option is set (the standard setting), both the
231 % documentation and implementation parts of the source are typeset. If on the
232 % other hand the \texttt{onlydoc} option is set, only the documentation part
233 % is typeset.
234 %
235 % \DescribeOption{lm-default}
236 % Selects whether the standard font set up is Latin Modern in the \texttt{T1}
237 % encoding (the standard setting) or leaves the font setup unchanged.
238 %
239 % \DescribeOption{kernel}
240 % Determines whether \pkg{l3doc} treats internal functions and variables
241 % belonging to |kernel| module as allowable in code, for instance
242 % \cs{__kernel_tl_to_str:w}, \cs{c__kernel_expl_date_tl}, and
243 % \cs{l__kernel_expl_bool}. In general,
244 % \emph{no} internal material from outside the current module is allowed.
245 % However, for bootstrapping the \pkg{expl3} kernel, a small number of
246 % cross-module functions are needed. To suppress the error message that
247 % would otherwise arise, the class option \texttt{kernel} may be given.
248 %
249 % \DescribeOption{check}
250 % When the \texttt{check} option is given, the class will record all commands
251 % defined and documented in a \texttt{\meta{name}.cmds} file. This will show
252 % which are both documented and defined, which are only documented and which
253 % are only defined. (Here, \enquote{defined} means listed using a
254 % \texttt{macro} or \texttt{variable} environment in the implementation part of
255 % the source file).
256 %
257 % \DescribeOption{checktest}
258 % When \texttt{checktest} is given as an option, the class will check that each
259 % function entry in the implementation part of the source is marked using
260 % \cs{UnitTest}.
261 %
262 % \DescribeOption{show-notes}
263 % \DescribeOption{hide-notes}
264 % These complementary options determine if the information given using the
265 % \cs{NB} and \cs{NOTE} commands is printed.
266 %
267 % \DescribeOption{cs-break}
268 % \DescribeOption{cs-break-nohyphen}
269 % The commands \cs{cmd} and \cs{cs} allow hyphenation of control sequences
270 % after (most) underscores. By default, a hyphen is used to mark the
271 % hyphenation, but this can be changed with the \texttt{cs-break-nohyphen}
272 % class option. To disable hyphenation of control sequences entirely, use
273 % \texttt{cs-break = false}.
274 %
275 % By default, class options
276 % \begin{verbatim}
277 % full , check = false , checktest = false , lm-default
278 % \end{verbatim}
279 % are set.
280 %
281 % \subsection{Partitioning documentation and implementation}
282 %
283 % \pkg{doc} uses the \cs{OnlyDocumentation}/\cs{AlsoImplementation}
284 % macros to guide the use of \cs{StopEventually}|{}|, which is intended
285 % to be placed to partition the documentation and implementation within
286 % a single \file{.dtx} file.
287 %
288 % This isn't very flexible, since it assumes that we \emph{always} want
289 % to print the documentation. For the \pkg{expl3} sources, I wanted to
290 % be able to input \file{.dtx} files in two modes: only displaying
291 % the documentation, and only displaying the implementation. For
292 % example:
293 % \begin{verbatim}
294 % \DisableImplementation
295 % \DocInput{l3basics,l3prg,...}
296 % \EnableImplementation
297 % \DisableDocumentation
298 % \DocInputAgain
299 % \end{verbatim}
300 %
301 % The idea being that the entire \pkg{expl3} bundle can be documented,
302 % with the implementation included at the back. Now, this isn't
303 % perfect, but it's a start.
304 %
305 % Use |\begin{documentation}...\end{documentation}| around the
306 % documentation, and |\begin{implementation}...\end{implementation}|
307 % around the implementation. The
308 % \cs{EnableDocumentation}/\cs{EnableImplementation} causes them to
309 % be typeset when the \file{.dtx} file is \cs{DocInput}; use
310 % \cs{DisableDocumentation}/\cs{DisableImplementation} to omit the
311 % contents of those environments.
312 %
313 % Note that \cs{DocInput} now takes comma-separated arguments, and
314 % \cs{DocInputAgain} can be used to re-input all \file{.dtx} files
315 % previously input in this way.
316 %
317 % \subsection{General text markup}
318 %
319 % Many of the commands in this section come from \pkg{ltxdoc} with some
320 % improvements.
321 %
322 % \begin{function}{\cmd, \cs}
323 % \begin{syntax}
324 % \cmd{\cmd} \oarg{options} \meta{control sequence}\\
325 % \cs{cs} \oarg{options} \marg{csname}
326 % \end{syntax}
327 % These commands are provided to typeset control sequences.
328 % |\cmd\foo| produces \enquote{\cmd\foo} and |\cs{foo}| produces the
329 % same. In general, \cs{cs} is more robust since
330 % it doesn't rely on catcodes being \enquote{correct} and is therefore
331 % recommended.
332 %
333 % These commands are aware of the |@@| \pkg{DocStrip} syntax and
334 % replace such instances correctly in the typeset documentation.
335 % This only happens after a |%<@@=|\meta{module}|>| declaration.
336 %
337 % Additionally, commands can be used in the argument of \cs{cs}. For
338 % instance, |\cs{\meta{name}:\meta{signature}}| produces
339 % \cs[no-index]{\meta{name}:\meta{signature}}.
340 %
341 % The \meta{options} are a key--value list which can contain the
342 % following keys:
343 % \begin{itemize}
344 % \item |index=|\meta{name}: the \meta{csname} is indexed as if
345 % one had written \cs{cs}\Arg{name}.
346 % \item |no-index|: the \meta{csname} is not indexed.
347 % \item |module=|\meta{module}: the \meta{csname} is indexed in
348 % the list of commands from the \meta{module}; the \meta{module}
349 % can in particular be |TeX| for \enquote{\TeX{} and \LaTeXe{}}
350 % commands, or empty for commands which should be placed in the
351 % main index. By default, the \meta{module} is deduced
352 % automatically from the command name.
353 % \item |replace| is a boolean key (\texttt{true} by default) which
354 % indicates whether to replace |@@| as \pkg{DocStrip} does.
355 % \end{itemize}
356 % These commands allow hyphenation of control sequences after (most) underscores.
357 % By default, a hyphen is used to mark the hyphenation, but this can be changed with
358 % the \texttt{cs-break-nohyphen} class option.
359 % To disable hyphenation of control sequences entirely, use
360 % \texttt{cs-break = false}.
361 % \end{function}
362 %
363 %
364 % \begin{function}{\tn}
365 % \begin{syntax}
366 % \cs{tn} \oarg{options} \marg{csname}
367 % \end{syntax}
368 % Analogous to \cs{cs} but intended for \enquote{traditional} \TeX{}
369 % or \LaTeXe{} commands; they are indexed accordingly. This is in
370 % fact equivalent to \cs{cs} |[module=TeX, replace=false,|
371 % \meta{options}|]| \Arg{csname}.
372 % \end{function}
373 %
374 % \begin{function}{\meta}
375 % \begin{syntax}
376 % \cs{meta} \Arg{name}
377 % \end{syntax}
378 % \cs{meta} typesets the \meta{name} italicized in \meta{angle
379 % brackets}. Within a \env{function} environment or similar, angle
380 % brackets |<...>| are set up to be a shorthand for |\meta{...}|.
381 %
382 % This function has additional functionality over its \pkg{ltxdoc}
383 % versions; underscores can be used to subscript material as in math
384 % mode. For example, |\meta{arg_{xy}}| produces
385 % \enquote{\meta{arg_{xy}}}.
386 % \end{function}
387 %
388 % \begin{function}{\Arg, \marg, \oarg, \parg}
389 % \begin{syntax}
390 % |\Arg| \Arg{name}
391 % \end{syntax}
392 % Typesets the \meta{name} as for \cs{meta} and wraps it in braces.
393 %
394 % The \cs{marg}/\cs{oarg}/\cs{parg} versions follow from \pkg{ltxdoc}
395 % in being used for \enquote{mandatory} or \enquote{optional} or
396 % \enquote{picture} brackets as per \LaTeXe{} syntax.
397 % \end{function}
398 %
399 % \begin{function}{\file, \env, \pkg, \cls}
400 % \begin{syntax}
401 % \cs{pkg} \Arg{name}
402 % \end{syntax}
403 % These all take one argument and are intended to be used as semantic
404 % commands for representing files, environments, package names, and
405 % class names, respectively.
406 % \end{function}
407 %
408 % \begin{function}{\NB, \NOTE}
409 % \begin{syntax}
410 % \cs{NB} \marg{tag} \marg{comments}
411 % \verb|\begin{NOTE}| \marg{tag}
412 % \qquad\meta{comments}
413 % \verb|\end{NOTE}|
414 % \end{syntax}
415 % Make notes in the source that are not typeset by default. When the \verb|show-notes|
416 % class option is active, the comments are typeset in a detokenized and verbatim mode, respectively.
417 % \end{function}
418 %
419 % \subsection{Describing functions in the documentation}
420 %
421 % \DescribeEnv{function}
422 % \DescribeEnv{variable}
423 % Two heavily-used environments are defined to describe \pkg{expl3} functions
424 % and variables. If describing a variable, use the latter environment; it
425 % behaves identically to the \env{function} environment.
426 % \DescribeEnv{syntax}
427 % Both of the above environments are typically combined with the \env{syntax}
428 % environment, to describe their syntax.
429 % \begin{framed}
430 % \vspace{-\baselineskip}
431 % \begin{verbatim}
432 % \begin{function}{\package_function_one:N, \package_function_two:n}
433 % \begin{syntax}
434 % \cs{package_function_one:N} \meta{cs}
435 % \cs{package_function_two:n} \marg{Argument}
436 % \end{syntax}
437 % Descriptive text here ...
438 % \end{function}
439 % \end{verbatim}
440 % \hrulefill
441 % \par
442 % \hspace*{0.25\textwidth}
443 % \begin{minipage}{0.5\textwidth}
444 % \begin{function}{\package_function_one:N, \package_function_two:n}
445 % \begin{syntax}
446 % \cs[no-index]{package_function_one:N} \meta{cs}
447 % \cs[no-index]{package_function_two:n} \marg{Argument}
448 % \end{syntax}
449 % \emph{Descriptive text here …}
450 % \end{function}
451 % \end{minipage}
452 % \end{framed}
453 %
454 % Function environments take an optional argument to indicate whether
455 % the function(s) it describes are expandable (use |EXP|) or
456 % restricted-expandable (use |rEXP|) or defined in conditional forms
457 % (use |TF|, |pTF|, or |noTF|). Note that |pTF| implies |EXP| since
458 % predicates must always be expandable, and that |noTF| means that the
459 % function without |TF| should be documented in addition to |TF|. For
460 % the conditional forms |TF| and |pTF|, the argument of the
461 % \env{function} environment is \emph{not} in fact a command that
462 % exists: in the example below, \cs[no-index]{tl_if_empty:N} does not
463 % exist, but its conditional forms \cs{tl_if_empty:NT},
464 % \cs{tl_if_empty:NF}, \cs{tl_if_empty:NTF} and predicate form
465 % \cs{tl_if_empty_p:N} exist:
466 % \begin{framed}
467 % \vspace{-\baselineskip}
468 % \begin{verbatim}
469 % \begin{function}[pTF]{\tl_if_empty:N, \tl_if_empty:c}
470 % \begin{syntax}
471 % \cs{tl_if_empty_p:N} \meta{tl~var}
472 % \cs{tl_if_empty:NTF} \meta{tl~var} \Arg{true code} \Arg{false code}
473 % \end{syntax}
474 % Tests if the \meta{tl~var} is entirely empty
475 % (i.e., contains no tokens at all).
476 % \end{function}
477 % \end{verbatim}
478 % \hrulefill
479 % \par
480 % \hspace*{0.25\textwidth}
481 % \begin{minipage}{0.5\textwidth}
482 % \begin{function}[pTF]{\tl_if_empty:N, \tl_if_empty:c}
483 % \begin{syntax}
484 % \cs{tl_if_empty_p:N} \meta{tl~var}
485 % \cs{tl_if_empty:NTF} \meta{tl~var} \Arg{true code} \Arg{false code}
486 % \end{syntax}
487 % Tests if the \meta{tl~var} is entirely empty
488 % (i.e., contains no tokens at all).
489 % \end{function}
490 % \end{minipage}
491 % \end{framed}
492 %
493 % \DescribeEnv{texnote}
494 % This environment is used to call out sections within \env{function}
495 % and similar environments that are only of interest to seasoned
496 % \TeX{} developers.
497 %
498 % \subsection{Describing functions in the implementation}
499 %
500 % \DescribeEnv{macro}
501 % The well-used environment from \LaTeXe{} for marking up the
502 % implementation of macros/functions remains the \env{macro}
503 % environment. Some changes in \pkg{l3doc}: it now accepts
504 % comma-separated lists of functions, to avoid a very large number of
505 % consecutive |\end{macro}| statements.
506 % Spaces and new lines are ignored (the option |[verb]| prevents this).
507 % \begin{verbatim}
508 % % \begin{macro}{\foo:N, \foo:c}
509 % % \begin{macrocode}
510 % ... code for \foo:N and \foo:c ...
511 % % \end{macrocode}
512 % % \end{macro}
513 % \end{verbatim}
514 % If you are documenting an auxiliary macro, it's generally not
515 % necessary to highlight it as much and you also don't need to check it
516 % for, say, having a test function and having a documentation chunk
517 % earlier in a \env{function} environment. \pkg{l3doc} will pick up these
518 % cases from the presence of |__| in the name, or you may force marking
519 % as internal by using |\begin{macro}[int]| to mark it as such. The margin
520 % call-out is then printed in grey for such cases.
521 %
522 % For documenting \pkg{expl3}-type conditionals, you may also pass this
523 % environment a |TF| option (and omit it from the function name) to
524 % denote that the function is provided with |T|, |F|, and |TF| suffixes.
525 % A similar |pTF| option prints both |TF| and |_p| predicate forms.
526 % An option |noTF| prints both the |TF| forms and a form with neither
527 % |T| nor |F|, to document functions such as \cs[no-index]{prop_get:NN}
528 % which also have conditional forms (\cs[no-index]{prop_get:NNTF}).
529 %
530 % In a very small number of cases, there is no user documentation for
531 % a \enquote{public} function. In these rare cases, the option
532 % |no-user-doc| may be added to suppress the undefined reference that
533 % would otherwise then arises.
534 %
535 % \DescribeMacro{\TestFiles}
536 % \cs{TestFiles}\marg{list of files} is used to indicate which test
537 % files are used for the current code; they are printed in the
538 % documentation.
539 %
540 % \DescribeMacro{\UnitTested}
541 % Within a \env{macro} environment, it is a good idea to mark whether a
542 % unit test has been created for the commands it defines. This is
543 % indicated by writing \cs{UnitTested} anywhere within |\begin{macro}|
544 % \dots |\end{macro}|.
545 %
546 % If the class option |checktest| is enabled, then it is an \emph{error}
547 % to have a \env{macro} environment without a call to
548 % \file{Testfiles}. This is intended for large packages such as
549 % \pkg{expl3} that should have absolutely comprehensive tests suites and
550 % whose authors may not always be as sharp at adding new tests with new
551 % code as they should be.
552 %
553 % \DescribeMacro{\TestMissing}
554 % If a function is missing a test, this may be flagged by writing (as
555 % many times as needed) \cs{TestMissing} \marg{explanation of test
556 % required}. These missing tests are summarized in the listing
557 % printed at the end of the compilation run.
558 %
559 % \DescribeEnv{variable}
560 % When documenting variable definitions, use the \env{variable}
561 % environment instead. Here it behaves identically to the
562 % \env{macro} environment, except that if the class option |checktest|
563 % is enabled, variables are not required to have a test file.
564 %
565 % \DescribeEnv{arguments}
566 % Within a \env{macro} environment, you may use the \env{arguments}
567 % environment to describe the arguments taken by the function(s). It
568 % behaves like a modified enumerate environment.
569 % \begin{verbatim}
570 % % \begin{macro}{\foo:nn, \foo:VV}
571 % % \begin{arguments}
572 % % \item Name of froozle to be frazzled
573 % % \item Name of muble to be jubled
574 % % \end{arguments}
575 % % \begin{macrocode}
576 % ... code for \foo:nn and \foo:VV ...
577 % % \end{macrocode}
578 % % \end{macro}
579 % \end{verbatim}
580 %
581 %
582 % \subsection{Keeping things consistent}
583 %
584 % Whenever a function is either documented or defined with
585 % \env{function} and \env{macro} respectively, its name is stored in a
586 % sequence for later processing.
587 %
588 % At the end of the document (i.e., after the \file{.dtx} file
589 % has finished processing), the list of names is analyzed to check
590 % whether all defined functions have been documented and vice versa. The
591 % results are printed in the console output.
592 %
593 % If you need to do more serious work with these lists of names, take a
594 % look at the implementation for the data structures and methods used to
595 % store and access them directly.
596 %
597 % \subsection{Documenting templates}
598 %
599 % The following macros are provided for documenting templates; might end
600 % up being something completely different but who knows.
601 % \begin{quote}\parskip=0pt\obeylines
602 % |\begin{TemplateInterfaceDescription}| \Arg{template type name}
603 % | \TemplateArgument{none}{---}|
604 % \textsc{or one or more of these:}
605 % | \TemplateArgument| \Arg{arg no} \Arg{meaning}
606 % \textsc{and}
607 % |\TemplateSemantics|
608 % | | \meta{text describing the template type semantics}
609 % |\end{TemplateInterfaceDescription}|
610 % \end{quote}
611 %
612 % \begin{quote}\parskip=0pt\obeylines
613 % |\begin{TemplateDescription}| \Arg{template type name} \Arg{name}
614 % \textsc{one or more of these:}
615 % | \TemplateKey| \marg{key name} \marg{type of key}
616 % | |\marg{textual description of meaning}
617 % | |\marg{default value if any}
618 % \textsc{and}
619 % |\TemplateSemantics|
620 % | | \meta{text describing special additional semantics of the template}
621 % |\end{TemplateDescription}|
622 % \end{quote}
623 %
624 % \begin{quote}\parskip=0pt\obeylines
625 % |\begin{InstanceDescription}| \oarg{text to specify key column width (optional)}
626 % \hfill\marg{template type name}\marg{instance name}\marg{template name}
627 % \textsc{one or more of these:}
628 % | \InstanceKey| \marg{key name} \marg{value}
629 % \textsc{and}
630 % |\InstanceSemantics|
631 % | | \meta{text describing the result of this instance}
632 % |\end{InstanceDescription}|
633 % \end{quote}
634 %
635 % \end{documentation}
636 %
637 % \begin{implementation}
638 %
639 % \section{\pkg{l3doc} implementation}
640 %
641 % \begin{macrocode}
642 %<*class>
643 % \end{macrocode}
644 %
645 % \begin{macrocode}
646 %<@@=codedoc>
647 % \end{macrocode}
648 %
649 % \subsection{Variables}
650 %
651 % \begin{variable}{\g_docinput_clist}
652 % The list of files which have been input through \cs{DocInput}.
653 % \begin{macrocode}
654 \clist_new:N \g_docinput_clist
655 % \end{macrocode}
656 % \end{variable}
657 %
658 % \begin{variable}{\g_doc_functions_seq, \g_doc_macros_seq}
659 % All functions documented through \env{function}, and all macros
660 % introduced through \env{macro}. They can be compared to see what
661 % documentation or code is missing.
662 % \begin{macrocode}
663 \seq_new:N \g_doc_functions_seq
664 \seq_new:N \g_doc_macros_seq
665 % \end{macrocode}
666 % \end{variable}
667 %
668 % \begin{variable}{\l_@@_detect_internals_bool, \l_@@_detect_internals_tl}
669 % If \texttt{true}, \pkg{l3doc} will check for use of internal
670 % commands \cs[no-index]{__\meta{pkg}_\ldots{}} from other packages in
671 % the argument of the \texttt{macro} environment, and in the code typeset in
672 % \texttt{macrocode} environments, but not in~\cs{cs}. Also a token list
673 % to store temporary data for this purpose.
674 % \begin{macrocode}
675 \bool_new:N \l_@@_detect_internals_bool
676 \bool_set_true:N \l_@@_detect_internals_bool
677 \tl_new:N \l_@@_detect_internals_tl
678 \tl_new:N \l_@@_detect_internals_cs_tl
679 % \end{macrocode}
680 % \end{variable}
681 %
682 % \begin{variable}{\l_@@_output_coffin}
683 % The \env{function} environment is typeset by combining coffins
684 % containing various pieces (function names, description, etc.)
685 % into this coffin.
686 % \begin{macrocode}
687 \coffin_new:N \l_@@_output_coffin
688 % \end{macrocode}
689 % \end{variable}
690 %
691 % \begin{variable}
692 % {\l_@@_functions_coffin, \l_@@_descr_coffin, \l_@@_syntax_coffin}
693 % These coffins contain respectively the list of function names
694 % (argument of the \env{function} environment), the text between
695 % |\begin{function}| and |\end{function}|, and the syntax given in the
696 % \env{syntax} environment.
697 % \begin{macrocode}
698 \coffin_new:N \l_@@_functions_coffin
699 \coffin_new:N \l_@@_descr_coffin
700 \coffin_new:N \l_@@_syntax_coffin
701 % \end{macrocode}
702 % \end{variable}
703 %
704 % \begin{variable}{\g_@@_syntax_box}
705 % The contents of the \env{syntax} environment are typeset in this box
706 % before being transferred to \cs{l_@@_syntax_coffin}.
707 % \begin{macrocode}
708 \box_new:N \g_@@_syntax_box
709 % \end{macrocode}
710 % \end{variable}
711 %
712 % \begin{variable}{\l_@@_in_function_bool}
713 % True when inside a \texttt{function} or \texttt{variable}
714 % environment. Used by the \texttt{syntax} environment to determine
715 % its behavior.
716 % \begin{macrocode}
717 \bool_new:N \l_@@_in_function_bool
718 % \end{macrocode}
719 % \end{variable}
720 %
721 % \begin{variable}{\l_@@_long_name_bool, \l_@@_trial_width_dim}
722 % The boolean \cs{l_@@_long_name_bool} is \texttt{true} if the width
723 % \cs{l_@@_trial_width_dim} of the coffin \cs{l_@@_functions_coffin}
724 % (containing the current function names) is bigger than the space
725 % available in the margin.
726 % \begin{macrocode}
727 \bool_new:N \l_@@_long_name_bool
728 \dim_new:N \l_@@_trial_width_dim
729 % \end{macrocode}
730 % \end{variable}
731 %
732 % \begin{variable}{\l_@@_nested_macro_int}
733 % The nesting of \env{macro} environments (this is now~$0$ outside a
734 % \env{macro} environment).
735 % \begin{macrocode}
736 \int_new:N \l_@@_nested_macro_int
737 % \end{macrocode}
738 % \end{variable}
739 %
740 % \begin{variable}
741 % {
742 % \l_@@_macro_tested_bool,
743 % \g_@@_missing_tests_prop,
744 % \g_@@_not_tested_seq,
745 % \g_@@_testfiles_seq,
746 % }
747 % A boolean describing whether the current macro has tests, and some
748 % global structures which contain information about test files and
749 % which tests are missing.
750 % \begin{macrocode}
751 \bool_new:N \l_@@_macro_tested_bool
752 \prop_new:N \g_@@_missing_tests_prop
753 \seq_new:N \g_@@_not_tested_seq
754 \seq_new:N \g_@@_testfiles_seq
755 % \end{macrocode}
756 % \end{variable}
757 %
758 % \begin{variable}
759 % {
760 % \l_@@_macro_deprecated_bool ,
761 % \l_@@_macro_internal_bool,
762 % \l_@@_macro_nodoc_bool ,
763 % \l_@@_macro_TF_bool,
764 % \l_@@_macro_pTF_bool,
765 % \l_@@_macro_noTF_bool,
766 % \l_@@_macro_EXP_bool,
767 % \l_@@_macro_rEXP_bool,
768 % \l_@@_macro_var_bool,
769 % \l_@@_override_module_tl,
770 % \l_@@_macro_documented_tl,
771 % }
772 % Contain information about some options of function/macro
773 % environments. We initialize \cs{l_@@_override_module_tl} to avoid
774 % overriding module names by an empty name (meaning no module).
775 % \begin{macrocode}
776 \bool_new:N \l_@@_macro_deprecated_bool
777 \bool_new:N \l_@@_macro_internal_bool
778 \bool_new:N \l_@@_macro_nodoc_bool
779 \bool_new:N \l_@@_macro_TF_bool
780 \bool_new:N \l_@@_macro_pTF_bool
781 \bool_new:N \l_@@_macro_noTF_bool
782 \bool_new:N \l_@@_macro_EXP_bool
783 \bool_new:N \l_@@_macro_rEXP_bool
784 \bool_new:N \l_@@_macro_var_bool
785 \tl_new:N \l_@@_override_module_tl
786 \tl_set:Nn \l_@@_override_module_tl { \q_no_value }
787 \tl_new:N \l_@@_macro_documented_tl
788 % \end{macrocode}
789 % \end{variable}
790 %
791 % \begin{variable}
792 % {
793 % \g_@@_lmodern_bool,
794 % \g_@@_checkfunc_bool,
795 % \g_@@_checktest_bool,
796 % \g_@@_cs_break_bool,
797 % \g_@@_show_notes_bool,
798 % \g_@@_kernel_bool
799 % }
800 % Information about package options.
801 % \begin{macrocode}
802 \bool_new:N \g_@@_lmodern_bool
803 \bool_new:N \g_@@_checkfunc_bool
804 \bool_new:N \g_@@_checktest_bool
805 \bool_new:N \g_@@_kernel_bool
806 \bool_new:N \g_@@_cs_break_bool
807 \bool_new:N \g_@@_show_notes_bool
808 \bool_gset_true:N \g_@@_cs_break_bool
809 % \end{macrocode}
810 % \end{variable}
811 %
812 % \begin{variable}{\l_@@_tmpa_tl, \l_@@_tmpb_tl, \l_@@_tmpa_int, \l_@@_tmpa_seq}
813 % Some temporary variables.
814 % \begin{macrocode}
815 \tl_new:N \l_@@_tmpa_tl
816 \tl_new:N \l_@@_tmpb_tl
817 \int_new:N \l_@@_tmpa_int
818 \int_new:N \l_@@_tmpa_seq
819 % \end{macrocode}
820 % \end{variable}
821 %
822 % \begin{variable}{\l_@@_names_block_tl}
823 % List of local sequence variables (produced through
824 % \cs{@@_lseq_name:n}), one for each set of variants in a
825 % \env{function} or \env{macro} environment. More precisely these
826 % sequences are named after the base forms, such as \cs{clist_count:n}
827 % or \cs{clist_count:N} (which are not variants). Each of these
828 % sequences have the base name (without any signature) as their first
829 % item, followed by the list of variant's signatures, or
830 % \cs{scan_stop:} to denote the absence of signature (no colon).
831 % \begin{macrocode}
832 \tl_new:N \l_@@_names_block_tl
833 % \end{macrocode}
834 % \end{variable}
835 %
836 % \begin{variable}{\g_@@_variants_seq}
837 % Stores rather temporarily the list of variants (signatures only) of
838 % a function/macro that is being documented. It is global because we
839 % need it to keep its value throughout cells of an alignment.
840 % \begin{macrocode}
841 \seq_new:N \g_@@_variants_seq
842 % \end{macrocode}
843 % \end{variable}
844 %
845 % \begin{variable}{\l_@@_names_verb_bool}
846 % Set to |true| if the main argument of a macro/function environment
847 % should be used as is, without removing any comma or space.
848 % \begin{macrocode}
849 \bool_new:N \l_@@_names_verb_bool
850 % \end{macrocode}
851 % \end{variable}
852 %
853 % \begin{variable}{\l_@@_names_seq}
854 % List of functions/environments/\ldots{} appearing as arguments of a
855 % given \env{function} or \env{macro} environment. These are the
856 % names after conversion of |_@@| and |@@| to |__|\meta{module name}
857 % and other sanitizing.
858 % \begin{macrocode}
859 \seq_new:N \l_@@_names_seq
860 % \end{macrocode}
861 % \end{variable}
862 %
863 % \begin{variable}{\g_@@_nested_names_seq}
864 % Collects all macros in nested \env{macro} environments, to use them
865 % in the \enquote{End definition} text.
866 % \begin{macrocode}
867 \seq_new:N \g_@@_nested_names_seq
868 % \end{macrocode}
869 % \end{variable}
870 %
871 % \begin{variable}
872 % {
873 % \l_@@_index_macro_tl, \l_@@_index_key_tl,
874 % \l_@@_index_module_tl, \l_@@_index_internal_bool,
875 % \l_@@_macro_do_not_index_tl
876 % }
877 % When analyzing a control sequence found within a \env{macrocode}
878 % environment, \cs{l_@@_index_macro_tl} holds the control sequence
879 % (partially a string), \cs{l_@@_index_key_tl} holds the future
880 % sort key in the index, and \cs{l_@@_index_module_tl} is the
881 % subindex in which the control sequence should be listed.
882 % \cs{l_@@_index_internal_bool} indicates when the control sequence is
883 % internal and should be indexed in a slightly different subindex.
884 % Finally, \cs{l_@@_macro_do_not_index_tl} indicates control sequences
885 % which should not be indexed in a specifiv \env{macro} envronment.
886 % \begin{macrocode}
887 \tl_new:N \l_@@_index_macro_tl
888 \tl_new:N \l_@@_index_key_tl
889 \tl_new:N \l_@@_index_module_tl
890 \tl_new:N \l_@@_macro_do_not_index_tl
891 \bool_new:N \l_@@_index_internal_bool
892 % \end{macrocode}
893 % \end{variable}
894 %
895 % \begin{variable}{\g_@@_module_name_tl}
896 % The module name, set when reading a line |<@@=|\meta{module}|>|.
897 % \begin{macrocode}
898 \tl_new:N \g_@@_module_name_tl
899 % \end{macrocode}
900 % \end{variable}
901 %
902 % \begin{variable}
903 % {\l_@@_macro_box, \l_@@_macro_index_box, \l_@@_macro_int}
904 % A vertical box in which the names given to the macro environment are
905 % typeset, a horizontal box in which we store the targets created by
906 % indexing commands, and the number of macros so far (including those
907 % from surrounding \env{macro} environments).
908 % \begin{macrocode}
909 \box_new:N \l_@@_macro_box
910 \box_new:N \l_@@_macro_index_box
911 \int_new:N \l_@@_macro_int
912 % \end{macrocode}
913 % \end{variable}
914 %
915 % \begin{variable}
916 % {
917 % \l_@@_cmd_tl,
918 % \l_@@_cmd_index_tl,
919 % \l_@@_cmd_module_tl,
920 % \l_@@_cmd_noindex_bool,
921 % \l_@@_cmd_replace_bool,
922 % }
923 % Variables used to control the behavior of \cs{cmd}, \cs{cs} and
924 % \cs{tn}.
925 % \begin{macrocode}
926 \tl_new:N \l_@@_cmd_tl
927 \tl_new:N \l_@@_cmd_index_tl
928 \tl_new:N \l_@@_cmd_module_tl
929 \bool_new:N \l_@@_cmd_noindex_bool
930 \bool_new:N \l_@@_cmd_replace_bool
931 % \end{macrocode}
932 % \end{variable}
933 %
934 % \begin{variable}{\l_@@_in_implementation_bool}
935 % This boolean is \texttt{true} within the \env{implementation}
936 % environment, and \texttt{false} anywhere else.
937 % \begin{macrocode}
938 \bool_new:N \l_@@_in_implementation_bool
939 % \end{macrocode}
940 % \end{variable}
941 %
942 % \begin{variable}
943 % {
944 % \g_@@_typeset_documentation_bool,
945 % \g_@@_typeset_implementation_bool
946 % }
947 % These booleans control whether the documentation/implementation
948 % should be typeset. By default both should be.
949 % \begin{macrocode}
950 \bool_new:N \g_@@_typeset_documentation_bool
951 \bool_new:N \g_@@_typeset_implementation_bool
952 \bool_gset_true:N \g_@@_typeset_documentation_bool
953 \bool_gset_true:N \g_@@_typeset_implementation_bool
954 % \end{macrocode}
955 % \end{variable}
956 %
957 % \begin{variable}{\g_@@_base_name_tl}
958 % The name of the macro which is being documented (without its
959 % signature).
960 % \begin{macrocode}
961 \tl_new:N \g_@@_base_name_tl
962 % \end{macrocode}
963 % \end{variable}
964 %
965 % \begin{variable}{\l_@@_function_label_clist, \l_@@_no_label_bool}
966 % Option of a \env{function} environment which replaces the label that
967 % would normally be inserted by labels for the given list of control
968 % sequences. This is only useful to avoid duplicate labels when a
969 % function's documentation appears multiple times.
970 % \begin{macrocode}
971 \clist_new:N \l_@@_function_label_clist
972 \bool_new:N \l_@@_no_label_bool
973 % \end{macrocode}
974 % \end{variable}
975 %
976 % \begin{variable}{\l_@@_date_added_tl, \l_@@_date_updated_tl}
977 % Values of some options of the \env{function} environment.
978 % \begin{macrocode}
979 \tl_new:N \l_@@_date_added_tl
980 \tl_new:N \l_@@_date_updated_tl
981 % \end{macrocode}
982 % \end{variable}
983 %
984 % \begin{variable}{\l_@@_macro_argument_tl}
985 % Save the argument of a \env{macro} or \env{function} environment for
986 % use in error messages.
987 % \begin{macrocode}
988 \tl_new:N \l_@@_macro_argument_tl
989 % \end{macrocode}
990 % \end{variable}
991 %
992 % ^^A Bruno: what does the next line do?
993 % \begin{macrocode}
994 % \int_new:N \c@CodelineNo
995 % \end{macrocode}
996 %
997 % \subsection{Variants and helpers}
998 %
999 % \begin{macro}{\@@_tmpa:w, \@@_tmpb:w}
1000 % Auxiliary macros for temporary use.
1001 % \begin{macrocode}
1002 \cs_new_eq:NN \@@_tmpa:w ?
1003 \cs_new_eq:NN \@@_tmpb:w ?
1004 % \end{macrocode}
1005 % \end{macro}
1006 %
1007 % \begin{macro}
1008 % {
1009 % \seq_set_split:NoV,
1010 % \tl_to_str:f
1011 % }
1012 % A few missing variants.
1013 % \begin{macrocode}
1014 \cs_generate_variant:Nn \seq_set_split:Nnn { NoV }
1015 \cs_generate_variant:Nn \tl_to_str:n { f }
1016 % \end{macrocode}
1017 % \end{macro}
1018 %
1019 % \begin{macro}[TF]{\@@_if_almost_str:n}
1020 % Used to test if the argument of |\cmd| or other macros to be indexed
1021 % is almost a string or not: for instance this is \texttt{false} if |#1|
1022 % contains |\meta{...}|. The surprising |f|-expansion is there to
1023 % cope with the case of |#1| starting with \cs{c_backslash_str}
1024 % which should be expanded and considered to be \enquote{normal}.
1025 % \begin{macrocode}
1026 \prg_new_protected_conditional:Npnn \@@_if_almost_str:n #1 { TF , T , F }
1027 {
1028 \int_compare:nNnTF
1029 { \tl_count:n {#1} }
1030 < { \tl_count:e { \tl_to_str:f {#1} } }
1031 { \prg_return_false: }
1032 { \prg_return_true: }
1033 }
1034 \prg_generate_conditional_variant:Nnn \@@_if_almost_str:n { V } { T }
1035 % \end{macrocode}
1036 % \end{macro}
1037 %
1038 % \begin{macro}{\@@_trim_right:Nn, \@@_trim_right:No}
1039 % Removes all material after |#2| in the token list variable~|#1|.
1040 % Perhaps combine with \cs{@@_key_trim_module:n}?
1041 % \begin{macrocode}
1042 \cs_new_protected:Npn \@@_trim_right:Nn #1#2
1043 {
1044 \cs_set:Npn \@@_tmp:w ##1 #2 ##2 \q_stop { \exp_not:n {##1} }
1045 \__kernel_tl_set:Nx #1 { \exp_after:wN \@@_tmp:w #1 #2 \q_stop }
1046 }
1047 \cs_generate_variant:Nn \@@_trim_right:Nn { No }
1048 % \end{macrocode}
1049 % \end{macro}
1050 %
1051 % \begin{macro}[TF]{\@@_str_if_begin:nn, \@@_str_if_begin:oo}
1052 % True if the first string starts with the second.
1053 % \begin{macrocode}
1054 \prg_new_protected_conditional:Npnn \@@_str_if_begin:nn #1#2 { TF , T , F }
1055 {
1056 \tl_if_in:ooTF
1057 { \exp_after:wN \scan_stop: \tl_to_str:n {#1} }
1058 { \exp_after:wN \scan_stop: \tl_to_str:n {#2} }
1059 { \prg_return_true: }
1060 { \prg_return_false: }
1061 }
1062 \prg_generate_conditional_variant:Nnn \@@_str_if_begin:nn
1063 { oo } { TF , T , F }
1064 % \end{macrocode}
1065 % \end{macro}
1066 %
1067 % \begin{macro}{\@@_replace_at_at:N}
1068 % \begin{macro}{\@@_replace_at_at_aux:Nn}
1069 % The goal is to replace |@@| by the current module name. We take
1070 % advantage of this function to also detect internal macros. If there is
1071 % no \meta{module~name}, do nothing. Otherwise, sanitize the catcodes
1072 % of |@| and~|_|, temporarily change |@@@@| to |aa| with different catcodes and later to |@@|, and replace |__@@| and |_@@| and |@@| by
1073 % |__|\meta{module~name}. The result contains |_| with category
1074 % code letter because this is what the |macrocode| environment
1075 % expects. Other use cases can apply \cs{tl_to_str:n} if needed.
1076 % Note that we include spaces between the
1077 % |@| in the code below, since it is also processed through the same
1078 % replacement rules.
1079 % \begin{macrocode}
1080 \cs_new_protected:Npn \@@_replace_at_at:N #1
1081 {
1082 \tl_if_empty:NF \g_@@_module_name_tl
1083 {
1084 \exp_args:NNo \@@_replace_at_at_aux:Nn
1085 #1 \g_@@_module_name_tl
1086 }
1087 }
1088 \cs_new_protected:Npe \@@_replace_at_at_aux:Nn #1#2
1089 {
1090 \tl_replace_all:Nnn #1 { \token_to_str:N @ } { @ }
1091 \tl_replace_all:Nnn #1 { \token_to_str:N _ } { _ }
1092 \tl_replace_all:Nnn #1 { @ @ @ @ } { \token_to_str:N a a }
1093 \tl_replace_all:Nnn #1 { _ _ @ @ } { _ _ #2 }
1094 \tl_replace_all:Nnn #1 { _ @ @ } { _ _ #2 }
1095 \tl_replace_all:Nnn #1 { @ @ } { _ _ #2 }
1096 \tl_replace_all:Nnn #1 { \token_to_str:N a a } { @ @ }
1097 }
1098 % \end{macrocode}
1099 % \end{macro}
1100 % \end{macro}
1101 %
1102 % \begin{macro}
1103 % {
1104 % \@@_detect_internals:N,
1105 % \@@_detect_internals_aux:N,
1106 % \@@_if_detect_internals_ok:NF
1107 % }
1108 % After splitting at each |__| and removing the leading item from the
1109 % sequence (since it does not follow |__|), remove everything after
1110 % any space or end-of-line to get a good approximation of the control
1111 % sequence (for the warning message). Then check if that starts with
1112 % something allowed: |@@| module name and |:| or |_|, or if the
1113 % relevant boolean is set |kernel_| (it seems safe to assume we will
1114 % not define a |\__kernel:...| command). For the message itself
1115 % remove anything after any |_| or |:| (with either catcode) to get a
1116 % guess of the module name.
1117 % \begin{macrocode}
1118 \cs_new_protected:Npn \@@_detect_internals:N #1
1119 {
1120 \bool_if:NT \l_@@_detect_internals_bool
1121 { \@@_detect_internals_aux:N #1 }
1122 }
1123 \group_begin:
1124 \char_set_catcode_active:N \^^M
1125 \cs_new_protected:Npn \@@_detect_internals_aux:N #1
1126 {
1127 \tl_set_eq:NN \l_@@_detect_internals_tl #1
1128 \tl_replace_all:NVn \l_@@_detect_internals_tl \c_underscore_str { _ }
1129 \seq_set_split:NnV \l_@@_tmpa_seq { _ _ } \l_@@_detect_internals_tl
1130 \seq_pop_left:NN \l_@@_tmpa_seq \l_@@_detect_internals_tl
1131 \seq_map_variable:NNn \l_@@_tmpa_seq \l_@@_detect_internals_tl
1132 {
1133 \@@_trim_right:No \l_@@_detect_internals_tl
1134 \c_catcode_active_space_tl
1135 \@@_trim_right:Nn \l_@@_detect_internals_tl ^^M
1136 \@@_if_detect_internals_ok:NF \l_@@_detect_internals_tl
1137 {
1138 \tl_set_eq:NN \l_@@_detect_internals_cs_tl \l_@@_detect_internals_tl
1139 \@@_trim_right:Nn \l_@@_detect_internals_tl _
1140 \@@_trim_right:Nn \l_@@_detect_internals_tl :
1141 \@@_trim_right:No \l_@@_detect_internals_tl { \token_to_str:N : }
1142 \msg_warning:nneee { l3doc } { foreign-internal }
1143 { \tl_to_str:N \l_@@_detect_internals_cs_tl }
1144 { \tl_to_str:N \l_@@_detect_internals_tl }
1145 { \tl_to_str:N \g_@@_module_name_tl }
1146 }
1147 }
1148 }
1149 \group_end:
1150 \prg_new_protected_conditional:Npnn \@@_if_detect_internals_ok:N #1 { F }
1151 {
1152 \@@_str_if_begin:ooTF {#1} { \g_@@_module_name_tl _ }
1153 { \prg_return_true: }
1154 {
1155 \@@_str_if_begin:ooTF {#1} { \g_@@_module_name_tl : }
1156 { \prg_return_true: }
1157 {
1158 \bool_if:NTF \g_@@_kernel_bool
1159 {
1160 \@@_str_if_begin:ooTF {#1} { kernel _ }
1161 { \prg_return_true: }
1162 { \prg_return_false: }
1163 }
1164 { \prg_return_false: }
1165 }
1166 }
1167 }
1168 % \end{macrocode}
1169 % \end{macro}
1170 %
1171 % \begin{macro}[rEXP]{\@@_signature_base_form:n}
1172 % \begin{macro}
1173 % {\@@_signature_base_form_aux:n, \@@_signature_base_form_aux:w}
1174 % Expands to the \enquote{base form} of the signature. For instance,
1175 % given |noxcfvV| it would obtain |nnnNnnn|, or given |ow| it would
1176 % obtain |nw|. The loop stops at the first token that is not
1177 % recognized; the rest is enclosed in \cs{exp_not:n}.
1178 % \begin{macrocode}
1179 \cs_new:Npn \@@_signature_base_form:n #1
1180 { \@@_signature_base_form_aux:n #1 \q_stop }
1181 \cs_new:Npn \@@_signature_base_form_aux:n #1
1182 {
1183 \str_case:nnTF {#1}
1184 {
1185 { N } { N }
1186 { c } { N }
1187 { n } { n }
1188 { o } { n }
1189 { f } { n }
1190 { e } { n }
1191 { x } { n }
1192 { V } { n }
1193 { v } { n }
1194 }
1195 { \@@_signature_base_form_aux:n }
1196 { \@@_signature_base_form_aux:w #1 }
1197 }
1198 \cs_new:Npn \@@_signature_base_form_aux:w #1 \q_stop
1199 { \exp_not:n {#1} }
1200 % \end{macrocode}
1201 % \end{macro}
1202 % \end{macro}
1203 %
1204 % \begin{macro}{\@@_predicate_from_base:n}
1205 % Get predicate from a function's base name. The code is not broken
1206 % by functions with no signature. The |n|-type version can be used
1207 % for keys and other non-control sequences. The output after
1208 % |e|-expansion is a string.
1209 % \begin{macrocode}
1210 \cs_new:Npn \@@_predicate_from_base:n #1
1211 {
1212 \@@_get_function_name:n {#1}
1213 \tl_to_str:n { _p: }
1214 \@@_get_function_signature:n {#1}
1215 }
1216 % \end{macrocode}
1217 % \end{macro}
1218 %
1219 % \begin{macro}{\@@_split_function_do:nn, \@@_split_function_do:on}
1220 % \begin{macro}{\@@_get_function_name:n, \@@_get_function_signature:n}
1221 % \begin{macro}{\@@_split_function_auxi:w, \@@_split_function_auxii:w}
1222 % Similar to internal functions defined in \pkg{l3basics}, but here we
1223 % operate on strings directly rather than control sequences.
1224 % \begin{macrocode}
1225 \cs_new:Npn \@@_get_function_name:n #1
1226 { \@@_split_function_do:nn {#1} { \use_i:nnn } }
1227 \cs_new:Npn \@@_get_function_signature:n #1
1228 { \@@_split_function_do:nn {#1} { \use_ii:nnn } }
1229 \cs_set_protected:Npn \@@_tmpa:w #1
1230 {
1231 \cs_new:Npn \@@_split_function_do:nn ##1
1232 {
1233 \exp_after:wN \@@_split_function_auxi:w
1234 \tl_to_str:n {##1} \q_mark \c_true_bool
1235 #1 \q_mark \c_false_bool
1236 \q_stop
1237 }
1238 \cs_new:Npn \@@_split_function_auxi:w
1239 ##1 #1 ##2 \q_mark ##3##4 \q_stop ##5
1240 { \@@_split_function_auxii:w {##5} ##1 \q_mark \q_stop {##2} ##3 }
1241 \cs_new:Npn \@@_split_function_auxii:w
1242 ##1##2 \q_mark ##3 \q_stop
1243 { ##1 {##2} }
1244 }
1245 \exp_args:No \@@_tmpa:w { \token_to_str:N : }
1246 \cs_generate_variant:Nn \@@_split_function_do:nn { o }
1247 % \end{macrocode}
1248 % \end{macro}
1249 % \end{macro}
1250 % \end{macro}
1251 %
1252 % \begin{macro}[rEXP]{\@@_key_get_base:nN}
1253 % Get the base form of a function and store it. As part of getting
1254 % the base form, change trailing |T| or |F| to |TF|, skipping that
1255 % change if the function contains no colon to avoid changing for
1256 % instance some names ending in \texttt{PDF} or similar. The various
1257 % letters |z| serve as end-delimiters different from any outcome of
1258 % \cs{tl_to_str:n}.
1259 % \begin{macrocode}
1260 \cs_new_protected:Npn \@@_key_get_base:nN #1#2
1261 {
1262 \@@_if_almost_str:nTF {#1}
1263 {
1264 \@@_key_get_base_TF:nN {#1} \l_@@_tmpa_tl
1265 \__kernel_tl_set:Nx #2
1266 { \@@_split_function_do:on \l_@@_tmpa_tl { \@@_base_form_aux:nnN } }
1267 }
1268 { \tl_set:Nn #2 {#1} }
1269 }
1270 \cs_new:Npe \@@_key_get_base_TF:nN #1#2
1271 {
1272 \__kernel_tl_set:Nx #2 { \exp_not:N \tl_to_str:n {#1} }
1273 \tl_if_in:NoF #2 { \tl_to_str:n {:} }
1274 { \exp_not:N \prg_break: }
1275 \tl_if_in:onT { #2 z } { \tl_to_str:n {TF} z }
1276 { \exp_not:N \prg_break: }
1277 \tl_if_in:onT { #2 z } { \tl_to_str:n {T} z }
1278 {
1279 \tl_put_right:Nn #2 { \tl_to_str:n {F} }
1280 \exp_not:N \prg_break:
1281 }
1282 \tl_if_in:onT { #2 z } { \tl_to_str:n {F} z }
1283 {
1284 \tl_put_right:Nn #2 { z }
1285 \tl_replace_once:Nnn #2 { \tl_to_str:n {F} z } { \tl_to_str:n {TF} }
1286 \exp_not:N \prg_break:
1287 }
1288 \exp_not:N \prg_break_point:
1289 }
1290 \cs_new:Npn \@@_base_form_aux:nnN #1#2#3
1291 {
1292 \exp_not:n {#1}
1293 \bool_if:NT #3
1294 {
1295 \token_to_str:N :
1296 \bool_lazy_or:nnTF
1297 { \str_if_eq_p:nn { #1 ~ } { \exp_args } }
1298 { \str_if_eq_p:nn { #1 ~ } { \exp_last_unbraced } }
1299 { \exp_not:n {#2} }
1300 { \@@_signature_base_form:n {#2} }
1301 }
1302 }
1303 % \end{macrocode}
1304 % \end{macro}
1305 %
1306 % \begin{macro}{\@@_base_form_signature_do:nnn}
1307 % Do |#2{#1}| if there is no signature, or if |#1| contains two colons
1308 % in a row (this covers the weird function |\::N| and so on).
1309 % Otherwise apply |#3| with the following two arguments: the base form
1310 % of |#1|, and the original signature with an extra pair of braces.
1311 % \begin{macrocode}
1312 \cs_new_protected:Npn \@@_base_form_signature_do:nnn #1#2#3
1313 {
1314 \@@_split_function_do:nn {#1}
1315 { \@@_base_form_aux:nnnnnN {#1} {#2} {#3} }
1316 }
1317 \cs_new_protected:Npn \@@_base_form_aux:nnnnnN #1#2#3#4#5#6
1318 {
1319 \bool_if:NTF #6
1320 {
1321 \tl_if_head_eq_charcode:nNTF {#4} :
1322 { #2 {#1} }
1323 {
1324 \use:e
1325 {
1326 \exp_not:n {#3}
1327 { \@@_base_form_aux:nnN {#4} {#5} #6 }
1328 }
1329 {#4} {#5}
1330 }
1331 }
1332 { #2 {#1} }
1333 }
1334 % \end{macrocode}
1335 % \end{macro}
1336 %
1337 % \begin{macro}[pTF]{\@@_date_compare:nNn}
1338 % \begin{macro}{\@@_date_compare_aux:nnnNnnn, \@@_date_compare_aux:w}
1339 % Expects |#1| and |#3| to be dates in the format YYYY-MM-DD (but
1340 % accepts YYYY or YYYY-MM too). Compares them using |#2| (one of |<|,
1341 % |=|, |>|), filling in zeros for missing data.
1342 % \begin{macrocode}
1343 \prg_new_conditional:Npnn \@@_date_compare:nNn #1#2#3 { TF , T , F , p }
1344 { \@@_date_compare_aux:w #1--- \q_mark #2 #3--- \q_stop }
1345 \cs_new:Npn \@@_date_compare_aux:w
1346 #1 - #2 - #3 - #4 \q_mark #5 #6 - #7 - #8 - #9 \q_stop
1347 {
1348 \@@_date_compare_aux:nnnNnnn
1349 { \tl_if_empty:nTF {#1} { 0 } {#1} }
1350 { \tl_if_empty:nTF {#2} { 0 } {#2} }
1351 { \tl_if_empty:nTF {#3} { 0 } {#3} }
1352 #5
1353 { \tl_if_empty:nTF {#6} { 0 } {#6} }
1354 { \tl_if_empty:nTF {#7} { 0 } {#7} }
1355 { \tl_if_empty:nTF {#8} { 0 } {#8} }
1356 }
1357 \cs_new:Npn \@@_date_compare_aux:nnnNnnn #1#2#3#4#5#6#7
1358 {
1359 \int_compare:nNnTF {#1} = {#5}
1360 {
1361 \int_compare:nNnTF {#2} = {#6}
1362 {
1363 \int_compare:nNnTF {#3} #4 {#7}
1364 { \prg_return_true: } { \prg_return_false: }
1365 }
1366 {
1367 \int_compare:nNnTF {#2} #4 {#6}
1368 { \prg_return_true: } { \prg_return_false: }
1369 }
1370 }
1371 {
1372 \int_compare:nNnTF {#1} #4 {#5}
1373 { \prg_return_true: } { \prg_return_false: }
1374 }
1375 \use_none:n
1376 \q_stop
1377 }
1378 % \end{macrocode}
1379 % \end{macro}
1380 % \end{macro}
1381 %
1382 % \begin{macro}{\@@_gprop_name:n, \@@_lseq_name:n}
1383 % We need to keep track of some information about control sequences
1384 % (and other strings) that are being (or have been) documented. Some
1385 % is stored into global props and some into local seqs, whose name
1386 % does not follow conventions: it is \cs[no-index]{g_@@} or
1387 % \cs[no-index]{l_@@} followed by a space and by the string, which can
1388 % be arbitrary. We cannot reasonably use a single big |prop| for
1389 % speed reasons.
1390 % \begin{macrocode}
1391 \cs_new:Npn \@@_gprop_name:n #1 { g_@@ ~ \tl_to_str:n {#1} }
1392 \cs_new:Npn \@@_lseq_name:n #1 { l_@@ ~ \tl_to_str:n {#1} }
1393 % \end{macrocode}
1394 % \end{macro}
1395 %
1396 % \subsection{Messages}
1397 %
1398 % \begin{macrocode}
1399 \msg_new:nnnn { l3doc } { no-signature-TF }
1400 { Function/macro~'#1'~cannot~be~turned~into~a~conditional. }
1401 {
1402 A~function~or~macro~environment~with~option~pTF,~TF~or~noTF~
1403 received~the~argument~'#1'.~This~function's~name~has~no~
1404 ':'~hence~it~is~not~clear~where~to~add~'_p'~or~'TF'.~
1405 Please~follow~expl3~naming~conventions.
1406 }
1407 \msg_new:nnn { l3doc } { date-format }
1408 { The~date~'#1'~should~be~given~in~YYYY-MM-DD~format. }
1409 \msg_new:nnn { l3doc } { future-date }
1410 { The~added/updated~date~'#2'~of~'#1'~is~in~the~future. }
1411 \msg_new:nnn { l3doc } { syntax-nested-function }
1412 {
1413 The~'syntax'~environment~should~be~used~in~the~
1414 innermost~'function'~environment.
1415 }
1416 \msg_new:nnn { l3doc } { multiple-syntax }
1417 {
1418 The~'syntax'~environment~should~only~be~used~once~in~
1419 a~'function'~environment.
1420 }
1421 \msg_new:nnn { l3doc } { deprecated-option }
1422 { The~option~'#1'~has~been~deprecated~for~'#2'. }
1423 \msg_new:nnn { l3doc } { foreign-internal }
1424 {
1425 A~control~sequence~of~the~form~'...__#1'~was~used.~
1426 It~should~only~be~used~in~the~module~'#2'
1427 \tl_if_empty:nF {#3} { ,~not~in~'#3' } .
1428 }
1429 % \end{macrocode}
1430 %
1431 % \subsection{Options and configuration}
1432 %
1433 % \begin{macrocode}
1434 \DeclareKeys [ l3doc / options ]
1435 {
1436 a5paper .code:n = \@latexerr { Option~not~supported } { } ,
1437 full .code:n =
1438 {
1439 \bool_gset_true:N \g_@@_typeset_documentation_bool
1440 \bool_gset_true:N \g_@@_typeset_implementation_bool
1441 } ,
1442 onlydoc .code:n =
1443 {
1444 \bool_gset_true:N \g_@@_typeset_documentation_bool
1445 \bool_gset_false:N \g_@@_typeset_implementation_bool
1446 } ,
1447 check .bool_gset:N = \g_@@_checkfunc_bool ,
1448 checktest .bool_gset:N = \g_@@_checktest_bool ,
1449 kernel .bool_gset:N = \g_@@_kernel_bool ,
1450 stdmodule .bool_gset_inverse:N = \g_@@_kernel_bool ,
1451 lm-default .bool_gset:N = \g_@@_lmodern_bool ,
1452 cs-break .bool_gset_inverse:N = \g_@@_cs_break_bool ,
1453 cs-break-nohyphen .code:n = \PassOptionsToPackage{nohyphen}{underscore} ,
1454 show-notes .bool_gset:N = \g_@@_show_notes_bool,
1455 hide-notes .bool_gset_inverse:N = \g_@@_show_notes_bool ,
1456 base-date .tl_set:N = \l_@@_base_date_tl ,
1457 }
1458 % \end{macrocode}
1459 %
1460 % \begin{macrocode}
1461 \DeclareUnknownKeyHandler [ l3doc / options ]
1462 { \PassOptionsToClass { \CurrentOption } { article } }
1463 \SetKeys [ l3doc / options ]
1464 { full , check = false , checktest = false , lm-default , base-date = 2020-02-02 }
1465 \PassOptionsToClass { a4paper } { article }
1466 % \end{macrocode}
1467 %
1468 % Input a local configuration file, if it exists, with a message to the
1469 % console that this has happened. Since we distribute a \file{.cfg} file
1470 % with the class, this should usually always be true. Therefore, check
1471 % for \cs{ExplMakeTitle} (defined in \enquote{our} \file{.cfg} file) and
1472 % only output the informational message if it's not found.
1473 %
1474 % \begin{macrocode}
1475 \msg_new:nnn { l3doc } { input-cfg }
1476 { Local~config~file~l3doc.cfg~loaded. }
1477 \file_if_exist:nT { l3doc.cfg }
1478 {
1479 \file_input:n { l3doc.cfg }
1480 \cs_if_exist:cF { ExplMakeTitle }
1481 { \msg_info:nn { l3doc } { input-cfg } }
1482 }
1483 % \end{macrocode}
1484 %
1485 % \begin{macrocode}
1486 \ProcessKeyOptions [ l3doc / options ]
1487 % \end{macrocode}
1488 %
1489 %
1490 % \subsection{Class and package loading}
1491 %
1492 % \begin{macrocode}
1493 \LoadClass{article}
1494 \RequirePackage{doc}
1495 \RequirePackage
1496 {
1497 array,
1498 alphalph,
1499 amsmath,
1500 amssymb,
1501 booktabs,
1502 color,
1503 colortbl,
1504 hologo,
1505 enumitem,
1506 pifont,
1507 textcomp,
1508 trace,
1509 csquotes,
1510 fancyvrb,
1511 underscore,
1512 verbatim
1513 }
1514 \raggedbottom
1515 % \end{macrocode}
1516 %
1517 % Depending on the option, load the package \pkg{lmodern} to set the
1518 % font. Then replace the italic typewriter font with the oblique shape
1519 % instead; the former makes my skin crawl. (Will, Aug 2011)
1520 % \begin{macrocode}
1521 \bool_if:NT \g_@@_lmodern_bool
1522 {
1523 \sys_if_engine_opentype:TF
1524 {
1525 \group_begin:
1526 \ttfamily
1527 \DeclareFontShape{TU}{lmtt}{m}{it}
1528 {<-> \UnicodeFontFile{lmmonoslant10-regular}{}}{}
1529 \group_end:
1530 }
1531 {
1532 \RequirePackage[T1]{fontenc}
1533 \RequirePackage{lmodern}
1534 \group_begin:
1535 \ttfamily
1536 \DeclareFontShape{T1}{lmtt}{m}{it}{<->ec-lmtto10}{}
1537 \group_end:
1538 }
1539 }
1540 % \end{macrocode}
1541 %
1542 % Must be last, as usual.
1543 % \begin{macrocode}
1544 \RequirePackage{hypdoc}
1545 % \end{macrocode}
1546 %
1547 % \subsection{Configuration and tweaks}
1548 %
1549 % \begin{macro}{\MakePrivateLetters}
1550 % A few more letters are \enquote{private} in a \LaTeX3 programming
1551 % environment.
1552 % \begin{macrocode}
1553 \cs_gset:Npn \MakePrivateLetters
1554 {
1555 \char_set_catcode_letter:N \@
1556 \char_set_catcode_letter:N \_
1557 \char_set_catcode_letter:N \:
1558 }
1559 % \end{macrocode}
1560 % \end{macro}
1561 %
1562 % \begin{macro}{CodelineNo}
1563 % Some configurations which have to do with line numbering.
1564 % \begin{macrocode}
1565 \setcounter{StandardModuleDepth}{1}
1566 \@addtoreset{CodelineNo}{part}
1567 \tl_replace_once:Nnn \theCodelineNo
1568 { \HDorg@theCodelineNo }
1569 { \textcolor[gray]{0.5} { \sffamily\tiny\arabic{CodelineNo} } }
1570 % \end{macrocode}
1571 % \end{macro}
1572 %
1573 % \begin{macro}{\verbatim, \endverbatim}
1574 % In \file{.dtx} documents, the \env{verbatim} environment adds extra
1575 % space because it only removes the first \enquote{\%} sign, and not
1576 % the indentation (typically a space). Fix it with \pkg{fancyvrb}:
1577 % \begin{macrocode}
1578 \fvset{gobble=2}
1579 \cs_gset_eq:NN \verbatim \Verbatim
1580 \cs_gset_eq:NN \endverbatim \endVerbatim
1581 % \end{macrocode}
1582 % \end{macro}
1583 %
1584 % \begin{macro}{\ifnot@excluded}
1585 % This function tests whether a macro name stored in
1586 % \tn{macro@namepart} was excluded from indexing by \tn{DoNotIndex}.
1587 % Rather than trying to fix catcodes that come into here, turn
1588 % everything to string catcodes. This is slightly inefficient as we
1589 % could have ensured that \tn{index@excludelist} has string catcodes
1590 % in the first place.
1591 % \begin{macrocode}
1592 \cs_set_protected:Npn \ifnot@excluded
1593 {
1594 \exp_args:Nee \expanded@notin
1595 { \c_backslash_str \tl_to_str:N \macro@namepart , }
1596 { \exp_args:NV \tl_to_str:n \index@excludelist }
1597 }
1598 % \end{macrocode}
1599 % \end{macro}
1600 %
1601 % \begin{macro}{\pdfstringnewline}
1602 % \begin{macro}{\@@_pdfstring_newline:w}
1603 % We avoid some hyperref warnings by making |\\| (almost) trivial in
1604 % bookmarks: more precisely it might be used with a star and an
1605 % optional argument, which we thus remove using an \pkg{ltcmd}
1606 % expandable command. Since there cannot be trailing optional
1607 % arguments, pick up an extra mandatory one and put it back.
1608 % \begin{macrocode}
1609 \cs_new:Npn \pdfstringnewline { : ~ }
1610 \DeclareExpandableDocumentCommand
1611 { \@@_pdfstring_newline:w } { s o m } { \pdfstringnewline #3 }
1612 \pdfstringdefDisableCommands
1613 { \cs_set_eq:NN \\ \@@_pdfstring_newline:w }
1614 % \end{macrocode}
1615 % \end{macro}
1616 % \end{macro}
1617 %
1618 % \subsection{Design}
1619 %
1620 % Increase the text width slightly so that with the standard fonts
1621 % 72~columns of code may appear in a \env{macrocode} environment.
1622 % Increase the marginpar width slightly, for long command names. And
1623 % increase the left margin by a similar amount.
1624 % \begin{macrocode}
1625 \setlength \textwidth { 385pt }
1626 \addtolength \marginparwidth { 30pt }
1627 \addtolength \oddsidemargin { 20pt }
1628 \addtolength \evensidemargin { 20pt }
1629 % \end{macrocode}
1630 % (These were introduced when \cls{article} was the documentclass, but
1631 % I've left them here for now to remind me to do something about them
1632 % later.)
1633 %
1634 % \begin{macro}{\list}
1635 % \begin{macro}{\@@_oldlist:nn}
1636 % Customize lists.
1637 % \begin{macrocode}
1638 \cs_new_eq:NN \@@_oldlist:nn \list
1639 \cs_gset:Npn \list #1 #2
1640 { \@@_oldlist:nn {#1} { #2 \dim_zero:N \listparindent } }
1641 \setlength \parindent { 2em }
1642 \setlength \itemindent { 0pt }
1643 \setlength \parskip { 0pt plus 3pt minus 0pt }
1644 % \end{macrocode}
1645 % \end{macro}
1646 % \end{macro}
1647 %
1648 % \begin{macro}{\partname}
1649 % Use \enquote{File} as a name in Part titles.
1650 % \begin{macrocode}
1651 \tl_gset:Nn \partname {File}
1652 % \end{macrocode}
1653 % \end{macro}
1654 %
1655 % \begin{macro}{\l@section, \l@subsection}
1656 % Customize the table of contents (as we have so many sections).
1657 % Different design and/or structure is called for.
1658 % \begin{macrocode}
1659 \@addtoreset{section}{part}
1660 \cs_gset:Npn \l@section #1#2
1661 {
1662 \ifnum \c@tocdepth >\z@
1663 \addpenalty\@secpenalty
1664 \addvspace{1.0em \@plus\p@}
1665 \setlength\@tempdima{2.5em} % was 1.5em
1666 \begingroup
1667 \parindent \z@ \rightskip \@pnumwidth
1668 \parfillskip -\@pnumwidth
1669 \leavevmode \bfseries
1670 \advance\leftskip\@tempdima
1671 \hskip -\leftskip
1672 #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
1673 \endgroup
1674 \fi
1675 }
1676 \cs_gset:Npn \l@subsection
1677 { \@dottedtocline{2}{2.5em}{2.3em} } % #2 = 1.5em
1678 % \end{macrocode}
1679 % \end{macro}
1680 %
1681 % \subsection{Text markup}
1682 %
1683 % Make "|" and |"| be \enquote{short verb} characters, but not in the
1684 % document preamble, where an active character may interfere with
1685 % packages that are loaded. Remove these short-hands at the end of the
1686 % document before reading the \file{.aux} file, as they may appear in
1687 % labels (for instance, \pkg{l3fp} documents an operation "||").
1688 % \begin{macrocode}
1689 \AtBeginDocument
1690 {
1691 \MakeShortVerb \"
1692 \MakeShortVerb \|
1693 }
1694 \AtEndDocument
1695 {
1696 \DeleteShortVerb \"
1697 \DeleteShortVerb \|
1698 }
1699 % \end{macrocode}
1700 %
1701 % \begin{macro}{\eTeX, \IniTeX, \Lua, \LuaTeX, \pdfTeX, \XeTeX,
1702 % \pTeX, \upTeX, \epTeX, \eupTeX}
1703 % Some commands for logos.
1704 % \begin{macrocode}
1705 \providecommand*\eTeX{\hologo{eTeX}}
1706 \providecommand*\IniTeX{\hologo{iniTeX}}
1707 \providecommand*\Lua{Lua}
1708 \providecommand*\LuaTeX{\hologo{LuaTeX}}
1709 \providecommand*\pdfTeX{\hologo{pdfTeX}}
1710 \providecommand*\XeTeX{\hologo{XeTeX}}
1711 \providecommand*\pTeX{p\kern-.2em\hologo{TeX}}
1712 \providecommand*\upTeX{up\kern-.2em\hologo{TeX}}
1713 \providecommand*\epTeX{$\varepsilon$-\pTeX}
1714 \providecommand*\eupTeX{$\varepsilon$-\upTeX}
1715 \providecommand*\ConTeXt{\hologo{ConTeXt}}
1716 % \end{macrocode}
1717 % \end{macro}
1718 %
1719 % \begin{macro}{\cmd, \cs, \tn}
1720 % They rely on a common auxiliary \cs{@@_cmd:nn} which receives as
1721 % arguments the options and some tokens whose string representation
1722 % starts with a backslash (to support cases such as |\cs{pkg_\ldots}|,
1723 % we do not turn the whole argument into a string).
1724 % \begin{macrocode}
1725 \DeclareDocumentCommand \cmd { O{} m }
1726 { \@@_cmd:no {#1} { \token_to_str:N #2 } }
1727 \DeclareDocumentCommand \cs { O{} m }
1728 { \@@_cmd:no {#1} { \c_backslash_str #2 } }
1729 \DeclareDocumentCommand \tn { O{} m }
1730 {
1731 \@@_cmd:no
1732 { module = TeX , replace = false , #1 }
1733 { \c_backslash_str #2 }
1734 }
1735 % \end{macrocode}
1736 % \end{macro}
1737 %
1738 % \begin{macro}{\meta}
1739 % A document-level command.
1740 % \begin{macrocode}
1741 \DeclareDocumentCommand \meta { m }
1742 { \texttt{ \@@_meta:n {#1} } }
1743 % \end{macrocode}
1744 % \end{macro}
1745 %
1746 % \begin{macro}
1747 % {
1748 % \@@_pdfstring_cmd:w,
1749 % \@@_pdfstring_cs:w,
1750 % \@@_pdfstring_meta:w
1751 % }
1752 % To work within a bookmark, these commands must be expandable.
1753 % \begin{macrocode}
1754 \DeclareExpandableDocumentCommand
1755 { \@@_pdfstring_cmd:w } { o m } { \token_to_str:N #2 }
1756 \DeclareExpandableDocumentCommand
1757 { \@@_pdfstring_cs:w } { o m } { \textbackslash \tl_to_str:n {#2} }
1758 \cs_new:Npn \@@_pdfstring_meta:w #1
1759 { < \tl_to_str:n {#1} > }
1760 \pdfstringdefDisableCommands
1761 {
1762 \cs_set_eq:NN \cmd \@@_pdfstring_cmd:w
1763 \cs_set_eq:NN \cs \@@_pdfstring_cs:w
1764 \cs_set_eq:NN \tn \@@_pdfstring_cs:w
1765 \cs_set_eq:NN \meta \@@_pdfstring_meta:w
1766 \cs_set_eq:NN \@@_meta:n \@@_pdfstring_meta:w
1767 }
1768 % \end{macrocode}
1769 % \end{macro}
1770 %
1771 % \begin{macro}{\Arg, \marg, \oarg, \parg}
1772 % |\marg{text}| prints \marg{text}, \enquote{mandatory argument}.\\
1773 % |\oarg{text}| prints \oarg{text}, \enquote{optional argument}.\\
1774 % |\parg{te,xt}| prints \parg{te,xt}, \enquote{picture mode argument}.
1775 % Finally, \cs{Arg} is the same as \cs{marg}.
1776 % \begin{macrocode}
1777 \newcommand\Arg[1]
1778 { \texttt{\char`\{} \@@_meta:n {#1} \texttt{\char`\}} }
1779 \providecommand\marg[1]{ \Arg{#1} }
1780 \providecommand\oarg[1]{ \texttt[ \@@_meta:n {#1} \texttt] }
1781 \providecommand\parg[1]{ \texttt( \@@_meta:n {#1} \texttt) }
1782 % \end{macrocode}
1783 % \end{macro}
1784 %
1785 % \begin{macro}{\file, \env, \pkg, \cls}
1786 % This list may change\dots this is just my preference for markup.
1787 % \begin{macrocode}
1788 \DeclareRobustCommand \file {\nolinkurl}
1789 \DeclareRobustCommand \env {\texttt}
1790 \DeclareRobustCommand \pkg {\textsf}
1791 \DeclareRobustCommand \cls {\textsf}
1792 % \end{macrocode}
1793 % \end{macro}
1794 %
1795 % \begin{macro}{\EnableDocumentation, \EnableImplementation}
1796 % \begin{macro}{\DisableDocumentation, \DisableImplementation}
1797 % Control whether to typeset the documentation/implementation or not.
1798 % These simply set two switches.
1799 % \begin{macrocode}
1800 \NewDocumentCommand \EnableDocumentation { }
1801 { \bool_gset_true:N \g_@@_typeset_documentation_bool }
1802 \NewDocumentCommand \EnableImplementation { }
1803 { \bool_gset_true:N \g_@@_typeset_implementation_bool }
1804 \NewDocumentCommand \DisableDocumentation { }
1805 { \bool_gset_false:N \g_@@_typeset_documentation_bool }
1806 \NewDocumentCommand \DisableImplementation { }
1807 { \bool_gset_false:N \g_@@_typeset_implementation_bool }
1808 % \end{macrocode}
1809 % \end{macro}
1810 % \end{macro}
1811 %
1812 % \begin{environment}{documentation}
1813 % \begin{environment}{implementation}
1814 % If the documentation/implementation should be typeset, then simply
1815 % set the boolean \cs{l_@@_in_implementation_bool} which indicates
1816 % whether we are within the implementation section. Otherwise use
1817 % \cs{comment} (and a paired \cs{endcomment}).
1818 % \begin{macrocode}
1819 \NewDocumentEnvironment { documentation } { }
1820 {
1821 \bool_if:NTF \g_@@_typeset_documentation_bool
1822 { \bool_set_false:N \l_@@_in_implementation_bool }
1823 { \comment }
1824 }
1825 { \bool_if:NF \g_@@_typeset_documentation_bool { \endcomment } }
1826 \NewDocumentEnvironment { implementation } { }
1827 {
1828 \bool_if:NTF \g_@@_typeset_implementation_bool
1829 { \bool_set_true:N \l_@@_in_implementation_bool }
1830 { \comment }
1831 }
1832 { \bool_if:NF \g_@@_typeset_implementation_bool { \endcomment } }
1833 % \end{macrocode}
1834 % \end{environment}
1835 % \end{environment}
1836 %
1837 % \begin{environment}{variable}
1838 % The \env{variable} environment behaves as a \env{function} or
1839 % \env{macro} environment depending on the part of the document.
1840 % \begin{macrocode}
1841 \DeclareDocumentEnvironment { variable } { O{} +v }
1842 {
1843 \bool_if:NTF \l_@@_in_implementation_bool
1844 { \@@_macro:nnw { var , #1 } {#2} }
1845 { \@@_function:nnw {#1} {#2} }
1846 }
1847 {
1848 \bool_if:NTF \l_@@_in_implementation_bool
1849 { \@@_macro_end: }
1850 { \@@_function_end: }
1851 }
1852 % \end{macrocode}
1853 % \end{environment}
1854 %
1855 % \begin{environment}{function}
1856 % \begin{environment}{macro}
1857 % Environment for documenting function(s), and environment for
1858 % documenting the implementation of a macro.
1859 % \begin{macrocode}
1860 \DeclareDocumentEnvironment { function } { O{} +v }
1861 { \@@_function:nnw {#1} {#2} }
1862 { \@@_function_end: }
1863 \DeclareDocumentEnvironment { macro } { O{} +v }
1864 { \@@_macro:nnw {#1} {#2} }
1865 { \@@_macro_end: }
1866 % \end{macrocode}
1867 % \end{environment}
1868 % \end{environment}
1869 %
1870 % \begin{environment}{syntax}
1871 % Syntax block placed next to the list of functions to illustrate
1872 % their use. TODO: test that the \env{syntax} environment is only
1873 % used inside the \env{function} environment, and that it only appears
1874 % once.
1875 % \begin{macrocode}
1876 \NewDocumentEnvironment { syntax } { }
1877 { \@@_syntax:w }
1878 {
1879 \@@_syntax_end:
1880 \ignorespacesafterend
1881 }
1882 % \end{macrocode}
1883 % \end{environment}
1884 %
1885 % \begin{environment}{texnote}
1886 % Used to describe information destined to \TeX{} experts only.
1887 % \begin{macrocode}
1888 \NewDocumentEnvironment { texnote } { }
1889 {
1890 \endgraf
1891 \vspace{3mm}
1892 \small\textbf{\TeX~hackers~note:}
1893 }
1894 {
1895 \vspace{3mm}
1896 }
1897 % \end{macrocode}
1898 % \end{environment}
1899 %
1900 % \begin{environment}{arguments}
1901 % This environment is designed to be used within a \env{macro}
1902 % environment to describe the arguments of the macro/function.
1903 % \begin{macrocode}
1904 \NewDocumentEnvironment { arguments } { }
1905 {
1906 \enumerate [
1907 nolistsep ,
1908 label = \texttt{\#\arabic*} ~ : ,
1909 labelsep = * ,
1910 ]
1911 }
1912 {
1913 \endenumerate
1914 }
1915 % \end{macrocode}
1916 % \end{environment}
1917 %
1918 % \begin{macro}{\CodedocExplain, \CodedocExplainEXP, \CodedocExplainREXP, \CodedocExplainTF}
1919 % Explanation of stars and |TF| notations, for use in third-party
1920 % packages.
1921 % \begin{macrocode}
1922 \NewDocumentCommand { \CodedocExplain } { }
1923 { \CodedocExplainEXP \ \CodedocExplainREXP \ \CodedocExplainTF }
1924 \NewDocumentCommand { \CodedocExplainEXP } { }
1925 {
1926 \raisebox{\baselineskip}[0pt][0pt]{\hypertarget{expstar}{}}%
1927 \write \@auxout { \def \string \Codedoc@expstar { } }
1928 \@@_typeset_exp:\ indicates~fully~expandable~functions,~which~
1929 can~be~used~within~an~\texttt{e}-type~argument~(inside~an~\tn{expanded}),~
1930 \texttt{x}-type~argument~(in~plain~\TeX{}~terms,~inside~an~\tn{edef}),~
1931 as~well~as~within~an~\texttt{f}-type~argument.
1932 }
1933 \NewDocumentCommand { \CodedocExplainREXP } { }
1934 {
1935 \raisebox{\baselineskip}[0pt][0pt]{\hypertarget{rexpstar}{}}%
1936 \write \@auxout { \def \string \Codedoc@rexpstar { } }
1937 \@@_typeset_rexp:\ indicates~
1938 restricted~expandable~functions,~which~can~be~used~within~an~
1939 \texttt{x}-type~argument~or~an~\texttt{e}-type~argument,~
1940 but~cannot~be~fully~expanded~within~an~\texttt{f}-type~argument.
1941 }
1942 \NewDocumentCommand { \CodedocExplainTF } { }
1943 {
1944 \raisebox{\baselineskip}[0pt][0pt]{\hypertarget{explTF}{}}%
1945 \write \@auxout { \def \string \Codedoc@explTF { } }
1946 \@@_typeset_TF:\ indicates~conditional~(\texttt{if})~functions~
1947 whose~variants~with~\texttt{T},~\texttt{F}~and~\texttt{TF}~
1948 argument~specifiers~expect~different~
1949 \enquote{true}/\enquote{false}~branches.
1950 }
1951 % \end{macrocode}
1952 % \end{macro}
1953 %
1954 % \subsection{Implementing text markup}
1955 %
1956 % Keys for \cs{cmd}, \cs{cs} and \cs{tn}.
1957 % \begin{macrocode}
1958 \keys_define:nn { l3doc/cmd }
1959 {
1960 index .tl_set:N = \l_@@_cmd_index_tl ,
1961 module .tl_set:N = \l_@@_cmd_module_tl ,
1962 no-index .bool_set:N = \l_@@_cmd_noindex_bool ,
1963 replace .bool_set:N = \l_@@_cmd_replace_bool ,
1964 }
1965 % \end{macrocode}
1966 %
1967 % \begin{macro}[do-not-index={\\,\_,\1,\c,\2}]{\@@_cmd:nn, \@@_cmd:no}
1968 % Apply the key--value \meta{options}~|#1| after setting some
1969 % default values. Then (unless |replace=false|) replace |@@| in~|#2|,
1970 % which is a bit tricky: the |_| must be given the catcode expected by
1971 % \cs{@@_replace_at_at:N}, but should be reverted to their original
1972 % catcode (normally active, needed for line-breaking) without
1973 % rescanning the whole argument. Then typeset the command in
1974 % \tn{verbatim@font}, after turning it to harmless characters if
1975 % needed (and keeping the underscore breakable); in any case, spaces
1976 % must be turned into \tn{@xobeysp} and we must use \tn{@} to avoid
1977 % longer spaces after a control sequence that ends for instance with a
1978 % colon (empty signature). Finally, produce an index entry.
1979 % Indexing is suppressed when \cs{l_@@_cmd_noindex_bool} is true.
1980 % \begin{macrocode}
1981 \cs_new_protected:Npn \@@_cmd:nn #1#2
1982 {
1983 \bool_set_false:N \l_@@_cmd_noindex_bool
1984 \bool_set_true:N \l_@@_cmd_replace_bool
1985 \tl_set:Nn \l_@@_cmd_index_tl { \q_no_value }
1986 \tl_set:Nn \l_@@_cmd_module_tl { \q_no_value }
1987 \keys_set:nn { l3doc/cmd } {#1}
1988 \tl_set:Nn \l_@@_cmd_tl {#2}
1989 \bool_if:NT \l_@@_cmd_replace_bool
1990 {
1991 \tl_set_rescan:Nnn \l_@@_tmpb_tl { } { _ }
1992 \tl_replace_all:NVn \l_@@_cmd_tl \l_@@_tmpb_tl { _ }
1993 \@@_replace_at_at:N \l_@@_cmd_tl
1994 \tl_replace_all:NnV \l_@@_cmd_tl { _ } \l_@@_tmpb_tl
1995 }
1996 % \end{macrocode}
1997 % Typesetting.
1998 % Note the replacement for the underscore is to permit linebreaks.
1999 % The \texttt{underscore} package adds the linebreak,
2000 % and the regex results in applying the breakable underscore only to the \emph{last}
2001 % of a run of underscores, and not if the underscore follows a backslash.
2002 % \begin{macrocode}
2003 \mode_if_math:T { \mbox }
2004 {
2005 \bool_if:NT \l_@@_allow_indexing_bool { \@@_target: }
2006 \verbatim@font
2007 \@@_if_almost_str:VT \l_@@_cmd_tl
2008 {
2009 \__kernel_tl_set:Nx \l_@@_cmd_tl { \tl_to_str:N \l_@@_cmd_tl }
2010 \bool_if:NT \g_@@_cs_break_bool
2011 {
2012 \regex_replace_all:nnN
2013 { ([^\\\_]\_*) \_ ([^\_]) }
2014 { \1 \c{BreakableUnderscore} \2 }
2015 \l_@@_cmd_tl
2016 }
2017 }
2018 \tl_replace_all:Nnn \l_@@_cmd_tl { ~ } { \@xobeysp }
2019 \l_@@_cmd_tl
2020 \@
2021 }
2022 % \end{macrocode}
2023 % Indexing.
2024 % \begin{macrocode}
2025 \bool_if:NT \l_@@_allow_indexing_bool
2026 {
2027 \bool_if:NF \l_@@_cmd_noindex_bool
2028 {
2029 \quark_if_no_value:NF \l_@@_cmd_index_tl
2030 {
2031 \__kernel_tl_set:Nx \l_@@_cmd_tl
2032 { \c_backslash_str \exp_not:o { \l_@@_cmd_index_tl } }
2033 }
2034 \exp_args:No \@@_key_get:n { \l_@@_cmd_tl }
2035 \quark_if_no_value:NF \l_@@_cmd_module_tl
2036 {
2037 \__kernel_tl_set:Nx \l_@@_index_module_tl
2038 { \tl_to_str:N \l_@@_cmd_module_tl }
2039 }
2040 \@@_special_index_module:ooonN
2041 { \l_@@_index_key_tl }
2042 { \l_@@_index_macro_tl }
2043 { \l_@@_index_module_tl }
2044 { usage }
2045 \l_@@_index_internal_bool
2046 }
2047 }
2048 }
2049 \cs_generate_variant:Nn \@@_cmd:nn { no }
2050 % \end{macrocode}
2051 % \end{macro}
2052 %
2053 % \begin{macro}
2054 % {
2055 % \@@_meta:n,
2056 % \@@_ensuremath_sb:n,
2057 % \@@_meta_original:n
2058 % }
2059 % Store |#1| in \cs{l_@@_tmpa_tl} and replaces every underscore,
2060 % regardless of its category (\enquote{math toggle},
2061 % \enquote{alignment}, \enquote{superscript}, \enquote{subscript},
2062 % \enquote{letter}, \enquote{other}, or \enquote{active}) by
2063 % \cs{@@_ensuremath_sb:n} (which creates math subscripts), then runs
2064 % the code used for \tn{meta} in \pkg{doc.sty}.
2065 % \begin{macrocode}
2066 \cs_new_protected:Npn \@@_meta:n #1
2067 {
2068 \tl_set:Nn \l_@@_tmpa_tl {#1}
2069 \tl_map_inline:nn
2070 { { 3 } { 4 } { 7 } { 8 } { 11 } { 12 } { 13 } }
2071 {
2072 \tl_set_rescan:Nnn \l_@@_tmpb_tl
2073 { \char_set_catcode:nn { `_ } {##1} } { _ }
2074 \tl_replace_all:NVn \l_@@_tmpa_tl \l_@@_tmpb_tl
2075 { \@@_ensuremath_sb:n }
2076 }
2077 \exp_args:NV \@@_meta_original:n \l_@@_tmpa_tl
2078 }
2079 \cs_new_protected:Npn \@@_ensuremath_sb:n #1
2080 { \ensuremath { \sb {#1} } }
2081 \cs_new_protected:Npn \@@_meta_original:n #1
2082 {
2083 \ensuremath \langle
2084 \mode_if_math:T { \nfss@text }
2085 {
2086 \meta@font@select
2087 \edef \meta@hyphen@restore
2088 { \hyphenchar \the \font \the \hyphenchar \font }
2089 \hyphenchar \font \m@ne
2090 \language \l@nohyphenation
2091 #1 \/
2092 \meta@hyphen@restore
2093 }
2094 \ensuremath \rangle
2095 }
2096 % \end{macrocode}
2097 % \end{macro}
2098 %
2099 % \subsubsection{Common between \env{macro} and \env{function}}
2100 %
2101 % \begin{macro}
2102 % {
2103 % \@@_typeset_exp:, \@@_typeset_rexp:,
2104 % \@@_typeset_TF:, \@@_typeset_aux:n
2105 % }
2106 % Used by \cs{@@_macro_single:nNN} and in the \env{function} environment
2107 % to typeset conditionals and auxiliary functions.
2108 % \begin{macrocode}
2109 \cs_new_protected:Npn \@@_typeset_exp:
2110 {
2111 \cs_if_exist:NTF \Codedoc@expstar
2112 { \hyperlink { expstar } }
2113 { \mbox }
2114 {$\star$}
2115 }
2116 \cs_new_protected:Npn \@@_typeset_rexp:
2117 {
2118 \cs_if_exist:NTF \Codedoc@rexpstar
2119 { \hyperlink { rexpstar } }
2120 { \mbox }
2121 { \ding { 73 } } % hollow star
2122 }
2123 \cs_new_protected:Npn \@@_typeset_TF:
2124 {
2125 \cs_if_exist:NTF \Codedoc@explTF
2126 { \hyperlink { explTF } }
2127 { \mbox }
2128 {
2129 \itshape TF
2130 \makebox[0pt][r]
2131 {
2132 \underline { \phantom{\itshape TF} \kern-0.1em }
2133 }
2134 }
2135 }
2136 \cs_new_protected:Npn \@@_typeset_aux:n #1
2137 {
2138 { \color[gray]{0.5} #1 }
2139 }
2140 % \end{macrocode}
2141 % \end{macro}
2142 %
2143 % \begin{macro}
2144 % {\@@_get_hyper_target:nN, \@@_get_hyper_target:oN, \@@_get_hyper_target:eN}
2145 % Create a \pkg{hyperref} anchor from a macro name~|#1| and stores it
2146 % in the token list variable~|#2|. For instance, |\prg_replicate:nn|
2147 % gives |doc/function//prg/replicate:nn|.
2148 % \begin{macrocode}
2149 \cs_new_protected:Npn \@@_get_hyper_target:nN #1#2
2150 {
2151 \__kernel_tl_set:Nx #2 { \tl_to_str:n {#1} }
2152 \tl_replace_all:NVn #2 \c_underscore_str { / }
2153 \tl_remove_all:NV #2 \c_backslash_str
2154 \tl_put_left:Nn #2 { doc/function// }
2155 }
2156 \cs_generate_variant:Nn \@@_get_hyper_target:nN { o , e }
2157 % \end{macrocode}
2158 % \end{macro}
2159 %
2160 % \begin{macro}{\@@_names_get_seq:nN}
2161 % The argument~|#1| (argument of a |function| or |macro| environment)
2162 % has catcodes $10$ (space), $12$ (other) and $13$ (active), and
2163 % since \LaTeX{} 2024-06-01 also macro \cs{obeyedline} in replacement
2164 % of active |^^M| tokens (due to the revised behavior of |+v|
2165 % argument type in |ltcmd|).
2166 % If the |verb| option was used, sanitize catcodes and output
2167 % a one-item sequence.
2168 % Otherwise, remove any \enquote{\%} character at the beginning of
2169 % a line using new end-of-line marker \cs{obeyedline}. Remove any
2170 % remaining \cs{obeyedline}. Then sanitize catcodes so we keep those
2171 % verbatim \cs{obeyedline} typed in by user. Remove remaining
2172 % \enquote{\%} character at the beginning of a line using traditional
2173 % |^^M| marker. Remove tabs and newlines. Finally, convert
2174 % |_@@| and |@@| to |__|\meta{module name} (if it is non-empty). At
2175 % this point, \cs{l_@@_tmpa_tl} contains a comma-delimited list of
2176 % names, where |@| and~|_| have category code letter. Turn it to a
2177 % string, parse it as a comma-delimited list (in particular this
2178 % removes spaces), and output a sequence of function/macro names.
2179 % \begin{macrocode}
2180 \cs_new_protected:Npn \@@_names_get_seq:nN #1#2
2181 {
2182 \bool_if:NTF \l_@@_names_verb_bool
2183 {
2184 \seq_clear:N #2
2185 \seq_put_right:No #2 { \tl_to_str:n {#1} }
2186 }
2187 {
2188 \tl_set:Nn \l_@@_tmpa_tl {#1}
2189 \tl_remove_all:Ne \l_@@_tmpa_tl
2190 { \exp_not:N \obeyedline \c_percent_str }
2191 \tl_remove_all:Ne \l_@@_tmpa_tl
2192 { \exp_not:N \obeyedline }
2193 \__kernel_tl_set:Nx \l_@@_tmpa_tl { \tl_to_str:N \l_@@_tmpa_tl }
2194 \tl_remove_all:Ne \l_@@_tmpa_tl
2195 { \iow_char:N \^^M \c_percent_str }
2196 \tl_remove_all:Ne \l_@@_tmpa_tl { \tl_to_str:n { ^ ^ A } }
2197 \tl_remove_all:Ne \l_@@_tmpa_tl { \iow_char:N \^^I }
2198 \tl_remove_all:Ne \l_@@_tmpa_tl { \iow_char:N \^^M }
2199 \@@_detect_internals:N \l_@@_tmpa_tl
2200 \@@_replace_at_at:N \l_@@_tmpa_tl
2201 \exp_args:NNe \seq_set_from_clist:Nn #2
2202 { \tl_to_str:N \l_@@_tmpa_tl }
2203 }
2204 }
2205 % \end{macrocode}
2206 % \end{macro}
2207 %
2208 % \begin{macro}{\@@_names_parse:, \@@_names_parse_one:n}
2209 % The goal is to group variants together. We populate
2210 % \cs{l_@@_names_block_tl} with local sequence variable named with
2211 % \cs{@@_lseq_name:n} after the base forms. When encountering a new
2212 % base form, set the corresponding local sequence to hold the
2213 % \meta{base name} (stripped of the signature) and add the local
2214 % sequence to the list \cs{l_@@_names_block_tl}. In all cases append
2215 % the signature to the local sequence, which thus takes the form
2216 % \meta{base name}, \meta{signature_1}, \meta{signature_2} and so on.
2217 % If the original function had no signature (no colon) then use
2218 % \cs{scan_stop:} as the signature (there can be no variant). We
2219 % special case commands |#1| starting with |\::|, namely weird
2220 % functions named |\::N| and the like.
2221 % \begin{macrocode}
2222 \cs_new_protected:Npn \@@_names_parse:
2223 {
2224 \tl_clear:N \l_@@_names_block_tl
2225 \seq_map_function:NN
2226 \l_@@_names_seq
2227 \@@_names_parse_one:n
2228 }
2229 \cs_new_protected:Npn \@@_names_parse_one:n #1
2230 {
2231 \@@_split_function_do:nn {#1}
2232 { \@@_names_parse_one_aux:nnNn }
2233 {#1}
2234 }
2235 \cs_new_protected:Npn \@@_names_parse_one_aux:nnNn #1#2#3#4
2236 {
2237 \bool_if:NTF #3
2238 {
2239 \tl_if_head_eq_charcode:nNTF {#2} :
2240 { \@@_names_parse_aux:nnn {#4} {#4} { \scan_stop: } }
2241 {
2242 \exp_args:Ne \@@_names_parse_aux:nnn
2243 { \@@_base_form_aux:nnN {#1} {#2} #3 }
2244 {#1} {#2}
2245 }
2246 }
2247 {
2248 \bool_if:NT \l_@@_macro_TF_bool
2249 { \msg_error:nne { l3doc } { no-signature-TF } {#4} }
2250 \@@_names_parse_aux:nnn {#4} {#4} { \scan_stop: }
2251 }
2252 }
2253 \cs_new_protected:Npn \@@_names_parse_aux:nnn #1
2254 { \exp_args:Nc \@@_names_parse_aux:Nnn { \@@_lseq_name:n {#1} } }
2255 \cs_new_protected:Npn \@@_names_parse_aux:Nnn #1#2#3
2256 {
2257 \tl_if_in:NnF \l_@@_names_block_tl {#1}
2258 {
2259 \tl_put_right:Nn \l_@@_names_block_tl {#1}
2260 \seq_clear_new:N #1
2261 \seq_put_right:Nn #1 {#2}
2262 }
2263 \seq_put_right:Nn #1 {#3}
2264 }
2265 % \end{macrocode}
2266 % \end{macro}
2267 %
2268 % \begin{macro}{\@@_names_typeset:}
2269 % \begin{macro}{\@@_names_typeset_auxi:n}
2270 % This code is in particular used when typesetting function names in a
2271 % \env{function} environment. The mapping over \cs{l_@@_names_block_tl}
2272 % cannot use \cs{tl_map_inline:Nn} because the code following |\\|
2273 % would not be expandable, thus breaking \tn{bottomrule}.
2274 %
2275 % Call \cs{@@_names_typeset_auxi:n} on each local sequence (which
2276 % holds a set of variants). The first step is to pop the base form
2277 % and change spaces to category other so
2278 % that they get displayed eventually. Then store the variants in
2279 % \cs{g_@@_variants_seq}, remove the first, which will be displayed
2280 % more prominently, and reconstruct the actual name, passing it to
2281 % \cs{@@_names_typeset_auxii:n}.
2282 % \begin{macrocode}
2283 \cs_new_protected:Npn \@@_names_typeset:
2284 {
2285 \tl_map_function:NN \l_@@_names_block_tl
2286 \@@_names_typeset_auxi:n
2287 }
2288 \cs_new_protected:Npn \@@_names_typeset_auxi:n #1
2289 {
2290 \seq_pop:NN #1 \l_@@_tmpa_tl
2291 \tl_gset_eq:NN \g_@@_base_name_tl \l_@@_tmpa_tl
2292 \tl_greplace_all:NnV \g_@@_base_name_tl
2293 { ~ } \c_catcode_other_space_tl
2294 \seq_get:NN #1 \l_@@_tmpa_tl
2295 \str_if_eq:VnTF \l_@@_tmpa_tl { \scan_stop: }
2296 {
2297 \seq_gclear:N \g_@@_variants_seq
2298 \@@_names_typeset_auxii:e { \g_@@_base_name_tl }
2299 }
2300 {
2301 \seq_gset_eq:NN \g_@@_variants_seq #1
2302 \seq_gpop:NN \g_@@_variants_seq \l_@@_tmpb_tl
2303 \@@_names_typeset_auxii:e
2304 { \g_@@_base_name_tl : \l_@@_tmpb_tl }
2305 }
2306 }
2307 % \end{macrocode}
2308 % \end{macro}
2309 % \end{macro}
2310 %
2311 % \begin{macro}
2312 % {\@@_names_typeset_auxii:n, \@@_names_typeset_auxii:e}
2313 % In case the option |pTF| was given, typeset predicates before the
2314 % |TF| functions. In case the option |noTF| was given, typeset the
2315 % non-|TF| function as well. Pass the relevant boolean in both cases
2316 % to control whether to append |TF|.
2317 % \begin{macrocode}
2318 \cs_new_protected:Npn \@@_names_typeset_auxii:n #1
2319 {
2320 \bool_if:NT \l_@@_macro_pTF_bool
2321 {
2322 \@@_names_typeset_block:eN
2323 { \@@_predicate_from_base:n {#1} }
2324 \c_false_bool
2325 }
2326 \bool_if:NT \l_@@_macro_noTF_bool
2327 { \@@_names_typeset_block:nN {#1} \c_false_bool }
2328 \@@_names_typeset_block:nN {#1} \l_@@_macro_TF_bool
2329 }
2330 \cs_generate_variant:Nn \@@_names_typeset_auxii:n { e }
2331 % \end{macrocode}
2332 % \end{macro}
2333 %
2334 % \begin{macro}{\@@_names_typeset_block:nN, \@@_names_typeset_block:eN}
2335 % Names in \env{function} and \env{macro} environments are typeset
2336 % differently. To distinguish the two note that
2337 % \cs{l_@@_nested_macro_int} is at least one when in an \env{macro}
2338 % environment (we assume \env{function} is not nested inside it). A
2339 % block is a function with all its variants.
2340 % \begin{macrocode}
2341 \cs_new_protected:Npn \@@_names_typeset_block:nN
2342 {
2343 \int_compare:nNnTF \l_@@_nested_macro_int = 0
2344 { \@@_typeset_function_block:nN }
2345 { \@@_macro_typeset_block:nN }
2346 }
2347 \cs_generate_variant:Nn \@@_names_typeset_block:nN { e }
2348 % \end{macrocode}
2349 % \end{macro}
2350 %
2351 % \begin{macro}[pTF]{\@@_if_macro_internal:n}
2352 % \begin{macro}[EXP]{\@@_if_macro_internal_aux:w}
2353 % Determines whether the given macro should be considered internal or
2354 % public. If an option such as |int| was given then the answer is
2355 % \cs{l_@@_macro_internal_bool}, otherwise check for whether the macro
2356 % name contains~|__|.
2357 % \begin{macrocode}
2358 \prg_new_conditional:Npnn \@@_if_macro_internal:n #1 { p , T , F , TF }
2359 {
2360 \bool_if:NTF \l_@@_macro_internal_bool
2361 { \prg_return_true: }
2362 {
2363 \tl_if_empty:eTF
2364 {
2365 \exp_after:wN \@@_if_macro_internal_aux:w
2366 \tl_to_str:n { #1 ~ __ }
2367 }
2368 { \prg_return_false: } { \prg_return_true: }
2369 }
2370 }
2371 \exp_last_unbraced:NNNNo
2372 \cs_new:Npn \@@_if_macro_internal_aux:w #1 { \tl_to_str:n { __ } } { }
2373 % \end{macrocode}
2374 % \end{macro}
2375 % \end{macro}
2376 %
2377 % \begin{macro}{\@@_names_block_base_map:N}
2378 % The \cs{l_@@_names_block_tl} contains sequence variables
2379 % corresponding to different base functions and their variants. For
2380 % each such sequence, put the first and second items in
2381 % \cs{l_@@_tmpa_tl} and \cs{l_@@_tmpb_tl} and build the base
2382 % function's name.
2383 % \begin{macrocode}
2384 \cs_new_protected:Npn \@@_names_block_base_map:N #1
2385 {
2386 \tl_map_inline:Nn \l_@@_names_block_tl
2387 {
2388 \group_begin:
2389 \seq_set_eq:NN \l_@@_tmpa_seq ##1
2390 \seq_pop:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
2391 \seq_get:NN \l_@@_tmpa_seq \l_@@_tmpb_tl
2392 \exp_args:NNe
2393 \group_end:
2394 #1
2395 {
2396 \l_@@_tmpa_tl
2397 \str_if_eq:VnF \l_@@_tmpb_tl { \scan_stop: }
2398 { : \l_@@_tmpb_tl }
2399 \bool_if:NT \l_@@_macro_TF_bool { TF }
2400 }
2401 }
2402 }
2403 % \end{macrocode}
2404 % \end{macro}
2405 %
2406 % \subsubsection{The \env{function} environment}
2407 %
2408 % \begin{macrocode}
2409 \keys_define:nn { l3doc/function }
2410 {
2411 TF .value_forbidden:n = true ,
2412 TF .code:n =
2413 {
2414 \bool_set_true:N \l_@@_macro_TF_bool
2415 } ,
2416 EXP .value_forbidden:n = true ,
2417 EXP .code:n =
2418 {
2419 \bool_set_true:N \l_@@_macro_EXP_bool
2420 \bool_set_false:N \l_@@_macro_rEXP_bool
2421 } ,
2422 rEXP .value_forbidden:n = true ,
2423 rEXP .code:n =
2424 {
2425 \bool_set_false:N \l_@@_macro_EXP_bool
2426 \bool_set_true:N \l_@@_macro_rEXP_bool
2427 } ,
2428 pTF .value_forbidden:n = true ,
2429 pTF .code:n =
2430 {
2431 \bool_set_true:N \l_@@_macro_pTF_bool
2432 \bool_set_true:N \l_@@_macro_TF_bool
2433 \bool_set_true:N \l_@@_macro_EXP_bool
2434 \bool_set_false:N \l_@@_macro_rEXP_bool
2435 } ,
2436 noTF .value_forbidden:n = true ,
2437 noTF .code:n =
2438 {
2439 \bool_set_true:N \l_@@_macro_noTF_bool
2440 \bool_set_true:N \l_@@_macro_TF_bool
2441 } ,
2442 added .code:n = { \@@_date_set_past:Nn \l_@@_date_added_tl {#1} },
2443 updated .code:n = { \@@_date_set_past:Nn \l_@@_date_updated_tl {#1} } ,
2444 deprecated .bool_set:N = \l_@@_macro_deprecated_bool ,
2445 no-user-doc .bool_set:N = \l_@@_macro_nodoc_bool ,
2446 tested .code:n = { } ,
2447 label .code:n =
2448 {
2449 \clist_set:Nn \l_@@_function_label_clist {#1}
2450 \bool_set_true:N \l_@@_no_label_bool
2451 } ,
2452 verb .value_forbidden:n = true ,
2453 verb .bool_set:N = \l_@@_names_verb_bool ,
2454 module .tl_set:N = \l_@@_override_module_tl ,
2455 }
2456 % \end{macrocode}
2457 %
2458 % \begin{macro}[do-not-index={\A,\Z,\d,\1,\2,\3}]
2459 % {\@@_date_set:Nn,\@@_date_set_past:Nn}
2460 % Normalize the date into the format \texttt{YYYY-MM-DD}; more
2461 % precisely month and day are allowed to be single digits. The
2462 % \cs{@@_date_set_past:Nn} function only allows dates in the past (or
2463 % same day).
2464 % \begin{macrocode}
2465 \cs_new_protected:Npn \@@_date_set:Nn #1#2
2466 {
2467 \tl_set:Nn #1 {#2}
2468 \regex_replace_once:nnNF
2469 { \A(\d\d\d\d)[-/](\d\d?)[-/](\d\d?)\Z } { \1-\2-\3 } #1
2470 {
2471 \msg_error:nnn { l3doc } { date-format } {#2}
2472 \tl_set:Nn #1 { 1970-01-01 }
2473 }
2474 }
2475 \cs_new_protected:Npn \@@_date_set_past:Nn #1#2
2476 {
2477 \@@_date_set:Nn #1 {#2}
2478 \exp_args:No \@@_date_compare:nNnT
2479 {#1} > { \c_sys_year_int - \c_sys_month_int - \c_sys_day_int }
2480 {
2481 \msg_error:nnee { l3doc } { future-date }
2482 { \tl_to_str:N \l_@@_macro_argument_tl }
2483 {#1}
2484 }
2485 }
2486 % \end{macrocode}
2487 % \end{macro}
2488 %
2489 % \begin{macro}{\@@_function:nnw}
2490 % \begin{arguments}
2491 % \item Key--value list.
2492 % \item Comma-separated list of functions; input has already been
2493 % sanitized by catcode changes before reading the argument.
2494 % \end{arguments}
2495 % \begin{macro}{\@@_function_end:}
2496 % Make sure any paragraph is finished, and similar safe practices at
2497 % the beginning of an environment which will typeset material.
2498 % Initialize some variables. Parse the key--value list. Clean up the
2499 % list of functions, then go through them to extract some data. After
2500 % this, typeset the function names in the coffin
2501 % \cs{l_@@_functions_coffin} and measure it to know if it fits in the
2502 % margin. Finally, start a vertical coffin for the main part of the
2503 % environment. This coffin stops when the environment ends, then all
2504 % the pieces are assembled into a single coffin, which is typeset.
2505 % \begin{macrocode}
2506 \cs_new_protected:Npn \@@_function:nnw #1#2
2507 {
2508 \@@_function_typeset_start:
2509 \@@_function_init:
2510 \tl_set:Nn \l_@@_macro_argument_tl {#2}
2511 \keys_set:nn { l3doc/function } {#1}
2512 \@@_names_get_seq:nN {#2} \l_@@_names_seq
2513 \@@_names_parse:
2514 \@@_function_typeset:
2515 \@@_function_reset:
2516 \@@_function_descr_start:w
2517 }
2518 \cs_new_protected:Npn \@@_function_end:
2519 {
2520 \@@_function_descr_stop:
2521 \@@_function_assemble:
2522 \@@_function_typeset_stop:
2523 }
2524 % \end{macrocode}
2525 % \end{macro}
2526 % \end{macro}
2527 %
2528 % \begin{macro}
2529 % {\@@_function_typeset_start:, \@@_function_typeset_stop:}
2530 % At the start of the \env{function} environment, before performing
2531 % any assignment, close the last paragraph, and set up the typesetting
2532 % scene. Further code typesets a coffin, so we end the paragraph and
2533 % allow a page break.
2534 % \begin{macrocode}
2535 \cs_new_protected:Npn \@@_function_typeset_start:
2536 {
2537 \par \bigskip \noindent
2538 }
2539 \cs_new_protected:Npn \@@_function_typeset_stop:
2540 {
2541 \par
2542 \dim_set:Nn \prevdepth { \coffin_dp:N \l_@@_descr_coffin }
2543 \allowbreak
2544 }
2545 % \end{macrocode}
2546 % \end{macro}
2547 %
2548 % \begin{macro}{\@@_function_init:}
2549 % Complain if \texttt{function} environments are nested. Clear
2550 % various variables.
2551 % \begin{macrocode}
2552 \cs_new_protected:Npn \@@_function_init:
2553 {
2554 \box_if_empty:NF \g_@@_syntax_box
2555 { \msg_error:nn { l3doc } { syntax-nested-function } }
2556 \coffin_clear:N \l_@@_descr_coffin
2557 \box_gclear:N \g_@@_syntax_box
2558 \coffin_clear:N \l_@@_syntax_coffin
2559 \coffin_clear:N \l_@@_functions_coffin
2560 \bool_set_false:N \l_@@_macro_TF_bool
2561 \bool_set_false:N \l_@@_macro_pTF_bool
2562 \bool_set_false:N \l_@@_macro_noTF_bool
2563 \bool_set_false:N \l_@@_macro_EXP_bool
2564 \bool_set_false:N \l_@@_macro_rEXP_bool
2565 \bool_set_false:N \l_@@_no_label_bool
2566 \bool_set_false:N \l_@@_names_verb_bool
2567 \bool_set_true:N \l_@@_in_function_bool
2568 \clist_clear:N \l_@@_function_label_clist
2569 \tl_set:Nn \l_@@_override_module_tl { \q_no_value }
2570 \char_set_active_eq:NN \< \@@_shorthand_meta:
2571 \char_set_catcode_active:N \<
2572 }
2573 % \end{macrocode}
2574 % \end{macro}
2575 %
2576 % \begin{macro}{\@@_shorthand_meta:, \@@_shorthand_meta:w}
2577 % Allow |<...>| to be used as markup for |\meta{...}|.
2578 % \begin{macrocode}
2579 \cs_new_protected:Npn \@@_shorthand_meta:
2580 { \mode_if_math:TF { < } { \@@_shorthand_meta:w } }
2581 \cs_new_protected_nopar:Npn \@@_shorthand_meta:w #1 > { \meta {#1} }
2582 % \end{macrocode}
2583 % \end{macro}
2584 %
2585 % \begin{macro}{\@@_function_reset:}
2586 % Clear some variables.
2587 % \begin{macrocode}
2588 \cs_new_protected:Npn \@@_function_reset:
2589 {
2590 \tl_set:Nn \l_@@_override_module_tl { \q_no_value }
2591 }
2592 % \end{macrocode}
2593 % \end{macro}
2594 %
2595 % \begin{macro}{\@@_function_typeset:}
2596 % Typeset in the coffin \cs{l_@@_functions_coffin} the functions listed in
2597 % \cs{l_@@_names_block_tl} and the relevant dates, then set
2598 % \cs{l_@@_long_name_bool} to be \texttt{true} if this coffin is
2599 % larger than the available width in the margin. The function
2600 % \cs{@@_typeset_functions:} is quite involved hence given later.
2601 % \begin{macrocode}
2602 \cs_new_protected:Npn \@@_function_typeset:
2603 {
2604 \dim_zero:N \l_@@_trial_width_dim
2605 \hcoffin_set:Nn \l_@@_functions_coffin { \@@_typeset_functions: }
2606 \dim_set:Nn \l_@@_trial_width_dim
2607 { \coffin_wd:N \l_@@_functions_coffin }
2608 \bool_set:Nn \l_@@_long_name_bool
2609 { \dim_compare_p:nNn \l_@@_trial_width_dim > \marginparwidth }
2610 }
2611 % \end{macrocode}
2612 % \end{macro}
2613 %
2614 % \begin{macro}
2615 % {\@@_function_descr_start:w, \@@_function_descr_stop:}
2616 % The last step in \cs{@@_function:nnw} (the beginning of a
2617 % \env{function} environment) is to open a coffin which will capture
2618 % the description of the function, namely the body of the
2619 % \env{function} environment. This is closed by \cs{@@_function_end:}
2620 % (the end of a \env{function} environment).
2621 % \begin{macrocode}
2622 \cs_new_protected:Npn \@@_function_descr_start:w
2623 {
2624 \vcoffin_set:Nnw \l_@@_descr_coffin { \textwidth }
2625 \noindent \ignorespaces
2626 }
2627 \cs_new_protected:Npn \@@_function_descr_stop:
2628 { \vcoffin_set_end: }
2629 % \end{macrocode}
2630 % \end{macro}
2631 %
2632 % \begin{macro}{\@@_function_assemble:}
2633 % The box \cs{g_@@_syntax_box} contains the contents of the syntax
2634 % environment if it was used. Now that we have all the pieces, join
2635 % together the syntax coffin, the names coffin, and the description
2636 % coffin. The relative positions depend on whether the names coffin
2637 % fits in the margin. Then typeset the combination.
2638 % \begin{macrocode}
2639 \cs_new_protected:Npn \@@_function_assemble:
2640 {
2641 \hcoffin_set:Nn \l_@@_syntax_coffin
2642 { \box_use_drop:N \g_@@_syntax_box }
2643 \bool_if:NTF \l_@@_long_name_bool
2644 {
2645 \coffin_join:NnnNnnnn
2646 \l_@@_output_coffin {hc} {vc}
2647 \l_@@_syntax_coffin {l} {T}
2648 {0pt} {0pt}
2649 \coffin_join:NnnNnnnn
2650 \l_@@_output_coffin {l} {t}
2651 \l_@@_functions_coffin {r} {t}
2652 {-\marginparsep} {0pt}
2653 \coffin_join:NnnNnnnn
2654 \l_@@_output_coffin {l} {b}
2655 \l_@@_descr_coffin {l} {t}
2656 {\marginparwidth + \marginparsep} {-\medskipamount}
2657 \coffin_typeset:Nnnnn \l_@@_output_coffin
2658 {\l_@@_descr_coffin-l} {\l_@@_descr_coffin-t}
2659 {0pt} {0pt}
2660 }
2661 {
2662 \coffin_join:NnnNnnnn
2663 \l_@@_output_coffin {hc} {vc}
2664 \l_@@_syntax_coffin {l} {t}
2665 {0pt} {0pt}
2666 \coffin_join:NnnNnnnn
2667 \l_@@_output_coffin {l} {b}
2668 \l_@@_descr_coffin {l} {t}
2669 {0pt} {-\medskipamount}
2670 \coffin_join:NnnNnnnn
2671 \l_@@_output_coffin {l} {t}
2672 \l_@@_functions_coffin {r} {t}
2673 {-\marginparsep} {0pt}
2674 \coffin_typeset:Nnnnn \l_@@_output_coffin
2675 {\l_@@_syntax_coffin-l} {\l_@@_syntax_coffin-T}
2676 {0pt} {0pt}
2677 }
2678 }
2679 % \end{macrocode}
2680 % \end{macro}
2681 %
2682 % \begin{macro}{\@@_typeset_functions:}
2683 % This function builds the \cs{l_@@_functions_coffin} by typesetting the
2684 % function names (with variants) and the relevant dates in a
2685 % \env{tabular} environment. The use of rules \tn{toprule},
2686 % \tn{midrule} and \tn{bottomrule} requires whatever lies between the
2687 % last |\\| and the rule to be expandable, making our lives a bit
2688 % complicated. Dates are checked here so this is before the tabular.
2689 % \begin{macrocode}
2690 \cs_new_protected:Npn \@@_typeset_functions:
2691 {
2692 \small\ttfamily
2693 \@@_target:
2694 \Hy@MakeCurrentHref { HD. \int_use:N \c@HD@hypercount }
2695 \@@_date_compare:VNVF \l_@@_date_added_tl > \l_@@_base_date_tl
2696 { \tl_clear:N \l_@@_date_added_tl }
2697 \@@_date_compare:VNVF \l_@@_date_updated_tl > \l_@@_base_date_tl
2698 { \tl_clear:N \l_@@_date_updated_tl }
2699 \begin{tabular} [t] { @{} l @{} >{\hspace{\tabcolsep}} r @{} }
2700 \toprule
2701 \@@_function_extra_labels:
2702 \@@_names_typeset:
2703 \@@_typeset_dates:
2704 \bottomrule
2705 \end{tabular}
2706 \normalfont\normalsize
2707 }
2708 \cs_generate_variant:Nn \@@_date_compare:nNnF { VNV }
2709 % \end{macrocode}
2710 % \end{macro}
2711 %
2712 % ^^A TODO: collect all index targets from a given function environment in a box and stick it at the top.
2713 % \begin{macro}{\@@_typeset_function_block:nN}
2714 % \begin{macro}{\@@_function_index:n, \@@_function_index:e}
2715 % |#1| is a csname, |#2| a boolean indicating whether to add |TF| or not.
2716 % \begin{macrocode}
2717 \cs_new_protected:Npn \@@_typeset_function_block:nN #1#2
2718 {
2719 \@@_function_index:e
2720 { #1 \bool_if:NT #2 { \tl_to_str:n {TF} } }
2721 \@@_function_label:eN {#1} #2
2722 #1
2723 \bool_if:NT #2 { \@@_typeset_TF: }
2724 \@@_typeset_expandability:
2725 \seq_if_empty:NF \g_@@_variants_seq
2726 { \@@_typeset_variant_list:nN {#1} #2 }
2727 \\
2728 }
2729 \cs_new_protected:Npn \@@_function_index:n #1
2730 {
2731 \seq_gput_right:Nn \g_doc_functions_seq {#1}
2732 \@@_special_index:nn {#1} { usage }
2733 }
2734 \cs_generate_variant:Nn \@@_function_index:n { e }
2735 % \end{macrocode}
2736 %
2737 % \begin{macrocode}
2738 \cs_new_protected:Npn \@@_typeset_expandability:
2739 {
2740 &
2741 \bool_if:NT \l_@@_macro_EXP_bool { \@@_typeset_exp: }
2742 \bool_if:NT \l_@@_macro_rEXP_bool { \@@_typeset_rexp: }
2743 }
2744 % \end{macrocode}
2745 %
2746 % |#1| is the function, |#2| whether to add |TF|.
2747 % \begin{macrocode}
2748 \cs_new_protected:Npn \@@_typeset_variant_list:nN #1#2
2749 {
2750 \\
2751 \@@_typeset_aux:n { \@@_get_function_name:n {#1} }
2752 :
2753 \int_compare:nTF { \seq_count:N \g_@@_variants_seq == 1 }
2754 {
2755 \seq_use:Nn \g_@@_variants_seq { }
2756 \bool_if:NT #2 { \@@_typeset_TF: }
2757 }
2758 {
2759 \hbox_set:Nn \l_tmpa_box
2760 { \seq_use:Nn \g_@@_variants_seq { \textrm| \nolinebreak[2] } }
2761 \textrm(
2762 % \end{macrocode}
2763 %
2764 % Set long variant lists in a parbox, short lists set natural length.
2765 % \begin{macrocode}
2766 \dim_compare:nNnTF { \box_wd:N \l_tmpa_box } > { .4\columnwidth }
2767 {
2768 \parbox[t]{.4\columnwidth}
2769 {
2770 \raggedright
2771 \hbox_unpack_drop:N \l_tmpa_box
2772 \textrm)
2773 \bool_if:NT #2 { \@@_typeset_TF: }
2774 }
2775 }
2776 {
2777 \hbox_unpack_drop:N \l_tmpa_box
2778 \textrm)
2779 \bool_if:NT #2 { \@@_typeset_TF: }
2780 }
2781 }
2782 \@@_typeset_expandability:
2783 }
2784 % \end{macrocode}
2785 %
2786 % |#1| is the function name, |#2| whether to add |TF|.
2787 % \begin{macrocode}
2788 \cs_new_protected:Npn \@@_function_extra_labels:
2789 {
2790 \bool_if:NT \l_@@_no_label_bool
2791 {
2792 \clist_map_inline:Nn \l_@@_function_label_clist
2793 {
2794 \@@_get_hyper_target:oN { \token_to_str:N ##1 }
2795 \l_@@_tmpa_tl
2796 \exp_args:No \label { \l_@@_tmpa_tl }
2797 }
2798 }
2799 }
2800 \cs_new_protected:Npn \@@_function_label:nN #1#2
2801 {
2802 \bool_if:NF \l_@@_no_label_bool
2803 {
2804 \@@_get_hyper_target:eN
2805 {
2806 \exp_not:n {#1}
2807 \bool_if:NT #2 { \tl_to_str:n {TF} }
2808 }
2809 \l_@@_tmpa_tl
2810 \exp_args:No \label { \l_@@_tmpa_tl }
2811 }
2812 }
2813 \cs_generate_variant:Nn \@@_function_label:nN { e }
2814 % \end{macrocode}
2815 % \end{macro}
2816 % \end{macro}
2817 %
2818 % \begin{macro}{\@@_typeset_dates:}
2819 % To display metadata for when functions are added/modified.
2820 % This function must be expandable since it produces rules for use in
2821 % alignments.
2822 % \begin{macrocode}
2823 \cs_new:Npn \@@_typeset_dates:
2824 {
2825 \bool_lazy_and:nnF
2826 { \tl_if_empty_p:N \l_@@_date_added_tl }
2827 { \tl_if_empty_p:N \l_@@_date_updated_tl }
2828 { \midrule }
2829 \tl_if_empty:NF \l_@@_date_added_tl
2830 {
2831 \multicolumn { 2 } { @{} r @{} }
2832 { \scriptsize New: \, \l_@@_date_added_tl } \\
2833 }
2834 \tl_if_empty:NF \l_@@_date_updated_tl
2835 {
2836 \multicolumn { 2 } { @{} r @{} }
2837 { \scriptsize Updated: \, \l_@@_date_updated_tl } \\
2838 }
2839 }
2840 % \end{macrocode}
2841 % \end{macro}
2842 %
2843 % \begin{macro}{\@@_syntax:w, \@@_syntax_end:}
2844 % Implement the \env{syntax} environment.
2845 % \begin{macrocode}
2846 \dim_new:N \l_@@_syntax_dim
2847 \cs_new_protected:Npn \@@_syntax:w
2848 {
2849 \box_if_empty:NF \g_@@_syntax_box
2850 { \msg_error:nn { l3doc } { multiple-syntax } }
2851 \dim_set:Nn \l_@@_syntax_dim
2852 {
2853 \textwidth
2854 \bool_if:NT \l_@@_long_name_bool
2855 { + \marginparwidth - \l_@@_trial_width_dim }
2856 }
2857 \hbox_gset:Nw \g_@@_syntax_box
2858 \small \ttfamily
2859 \arrayrulecolor{white}
2860 \begin{tabular} { @{} l @{} }
2861 \toprule
2862 \begin{minipage}[t]{\l_@@_syntax_dim}
2863 \raggedright
2864 \obeyspaces
2865 \obeylines
2866 }
2867 \cs_new_protected:Npn \@@_syntax_end:
2868 {
2869 \end{minipage}
2870 \end{tabular}
2871 \arrayrulecolor{black}
2872 \hbox_gset_end:
2873 \bool_if:NF \l_@@_in_function_bool
2874 {
2875 \begin{quote}
2876 \mode_leave_vertical:
2877 \box_use_drop:N \g_@@_syntax_box
2878 \end{quote}
2879 }
2880 }
2881 % \end{macrocode}
2882 % \end{macro}
2883 %
2884 % \subsubsection{The \env{macro} environment}
2885 %
2886 % Keyval for the \env{macro} environment.
2887 % TODO: provide document command for documenting keys.
2888 % \begin{macrocode}
2889 \keys_define:nn { l3doc/macro }
2890 {
2891 aux .value_forbidden:n = true ,
2892 aux .code:n =
2893 {
2894 \msg_warning:nnnn { l3doc } { deprecated-option }
2895 { aux } { function/macro }
2896 } ,
2897 deprecated .bool_set:N = \l_@@_macro_deprecated_bool ,
2898 internal .value_forbidden:n = true ,
2899 internal .code:n =
2900 { \bool_set_true:N \l_@@_macro_internal_bool } ,
2901 int .value_forbidden:n = true ,
2902 int .code:n =
2903 { \bool_set_true:N \l_@@_macro_internal_bool } ,
2904 no-user-doc .bool_set:N = \l_@@_macro_nodoc_bool ,
2905 var .value_forbidden:n = true ,
2906 var .code:n =
2907 { \bool_set_true:N \l_@@_macro_var_bool } ,
2908 TF .value_forbidden:n = true ,
2909 TF .code:n =
2910 { \bool_set_true:N \l_@@_macro_TF_bool } ,
2911 pTF .value_forbidden:n = true ,
2912 pTF .code:n =
2913 {
2914 \bool_set_true:N \l_@@_macro_TF_bool
2915 \bool_set_true:N \l_@@_macro_pTF_bool
2916 \bool_set_true:N \l_@@_macro_EXP_bool
2917 \bool_set_false:N \l_@@_macro_rEXP_bool
2918 } ,
2919 noTF .value_forbidden:n = true ,
2920 noTF .code:n =
2921 {
2922 \bool_set_true:N \l_@@_macro_TF_bool
2923 \bool_set_true:N \l_@@_macro_noTF_bool
2924 } ,
2925 EXP .value_forbidden:n = true ,
2926 EXP .code:n =
2927 {
2928 \bool_set_true:N \l_@@_macro_EXP_bool
2929 \bool_set_false:N \l_@@_macro_rEXP_bool
2930 } ,
2931 rEXP .value_forbidden:n = true ,
2932 rEXP .code:n =
2933 {
2934 \bool_set_false:N \l_@@_macro_EXP_bool
2935 \bool_set_true:N \l_@@_macro_rEXP_bool
2936 } ,
2937 tested .code:n =
2938 {
2939 \bool_set_true:N \l_@@_macro_tested_bool
2940 } ,
2941 added .code:n = {} , % TODO
2942 updated .code:n = {} , % TODO
2943 verb .bool_set:N = \l_@@_names_verb_bool ,
2944 module .tl_set:N = \l_@@_override_module_tl ,
2945 documented-as .tl_set:N = \l_@@_macro_documented_tl ,
2946 do-not-index .value_required:n = true ,
2947 do-not-index .tl_set:N = \l_@@_macro_do_not_index_tl ,
2948 % do-not-index .default:n = \q_no_value ,
2949 }
2950 % \end{macrocode}
2951 %
2952 % \begin{macro}{\@@_macro:nnw}
2953 % The arguments are a key--value list of \meta{options} and a
2954 % comma-list of \meta{names}, read verbatim by \pkg{ltcmd}. First
2955 % initialize some variables before applying the \meta{options}, then
2956 % parse the \meta{names} to get a sequence of macro names, then apply
2957 % \cs{@@_macro_single:nNN} to each (this step is more subtle than
2958 % \cs{seq_map_function:NN} because of |TF|/|pTF|/|noTF|). Finally typeset
2959 % the macro names in the margin.
2960 % \begin{macrocode}
2961 \cs_new_protected:Npn \@@_macro:nnw #1#2
2962 {
2963 \@@_macro_init:
2964 \tl_set:Nn \l_@@_macro_argument_tl {#2}
2965 \keys_set:nn { l3doc/macro } {#1}
2966 \@@_names_get_seq:nN {#2} \l_@@_names_seq
2967 \@@_names_parse:
2968 \@@_macro_exclude_index:
2969 \@@_macro_save_names:
2970 \@@_names_typeset:
2971 \@@_macro_dump:
2972 \@@_macro_reset:
2973 }
2974 % \end{macrocode}
2975 % \end{macro}
2976 %
2977 % \begin{macro}{\@@_macro_init:}
2978 % The booleans hold various key--value options,
2979 % \cs{l_@@_nested_macro_int} counts the number of \env{macro}
2980 % environments around the current point (is $0$ outside).
2981 % \begin{macrocode}
2982 \cs_new_protected:Npn \@@_macro_init:
2983 {
2984 \int_incr:N \l_@@_nested_macro_int
2985 \bool_set_false:N \l_@@_macro_deprecated_bool
2986 \bool_set_false:N \l_@@_macro_internal_bool
2987 \bool_set_false:N \l_@@_macro_TF_bool
2988 \bool_set_false:N \l_@@_macro_pTF_bool
2989 \bool_set_false:N \l_@@_macro_noTF_bool
2990 \bool_set_false:N \l_@@_macro_EXP_bool
2991 \bool_set_false:N \l_@@_macro_rEXP_bool
2992 \bool_set_false:N \l_@@_macro_var_bool
2993 \bool_set_false:N \l_@@_macro_tested_bool
2994 \bool_set_false:N \l_@@_names_verb_bool
2995 \tl_set:Nn \l_@@_override_module_tl { \q_no_value }
2996 \tl_clear:N \l_@@_macro_documented_tl
2997 \cs_set_eq:NN \testfile \@@_print_testfile:n
2998 \box_clear:N \l_@@_macro_index_box
2999 \vbox_set:Nn \l_@@_macro_box
3000 {
3001 \hbox:n
3002 {
3003 \strut
3004 \int_compare:nNnT \l_@@_macro_int = 0 { \@@_target: }
3005 }
3006 \vskip \int_eval:n { \l_@@_macro_int - 1 } \baselineskip
3007 }
3008 }
3009 % \end{macrocode}
3010 % \end{macro}
3011 %
3012 % \begin{macro}{\@@_macro_reset:}
3013 % We ensure that \cs{cs} commands nested inside a macro whose module
3014 % is imposed are not affected.
3015 % \begin{macrocode}
3016 \cs_new_protected:Npn \@@_macro_reset:
3017 {
3018 \tl_set:Nn \l_@@_override_module_tl { \q_no_value }
3019 }
3020 % \end{macrocode}
3021 % \end{macro}
3022 %
3023 % \begin{macro}{\@@_macro_save_names:}
3024 % \begin{macro}[EXP]{\@@_macro_save_names_aux:w}
3025 % The list of names defined in a set of \env{macro} environments is
3026 % eventually used to display on which page they are documented. If
3027 % the |documented-as| key is given, use that, otherwise find names in
3028 % \cs{l_@@_names_block_tl}. The |documented-as| needs to be detokenized
3029 % without adding a space, so it has to be treated in a slightly awkward
3030 % way.
3031 % \begin{macrocode}
3032 \cs_new_protected:Npn \@@_macro_save_names:
3033 {
3034 \tl_if_empty:NTF \l_@@_macro_documented_tl
3035 { \@@_names_block_base_map:N \@@_macro_save_names_aux:n }
3036 {
3037 \seq_gput_right:Ne \g_@@_nested_names_seq
3038 {
3039 \exp_after:wN \@@_macro_save_names_aux:w
3040 \l_@@_macro_documented_tl \q_@@_stop
3041 }
3042 }
3043 }
3044 \cs_new:Npn \@@_macro_save_names_aux:w #1#2 \q_@@_stop
3045 { \token_to_str:N #1 \tl_to_str:n {#2} }
3046 \cs_new_protected:Npn \@@_macro_save_names_aux:n #1
3047 { \seq_gput_right:Nn \g_@@_nested_names_seq {#1} }
3048 % \end{macrocode}
3049 % \end{macro}
3050 % \end{macro}
3051 %
3052 % \begin{macro}{\@@_macro_exclude_index:}
3053 % Some control sequences in a \env{macrocode} environment shouldn't
3054 % be indexed, for different reasons. This macro parses the argument
3055 % of the |do-not-index| option and locally removes the given macros
3056 % from the index.
3057 %
3058 % The optional argument to \env{macro} is not scanned with verbatim
3059 % catcodes, so we use \cs{tl_set_rescan:NnV} to rescan the commands
3060 % with the same catcodes as \cs{DoNotIndex}. The scanned token list
3061 % contains spaces after control sequences, which are not there when
3062 % \cs{DoNotIndex} is used. Since \cs{seq_set_from_clist:Nn} removes
3063 % spaces around the items, we can abuse that and \cs{seq_use:Nn} to
3064 % normalize each item. After that \cs{DoNotIndex} can do its thing.
3065 % \begin{macrocode}
3066 \cs_new_protected:Npn \@@_macro_exclude_index:
3067 {
3068 \tl_if_empty:NF \l_@@_macro_do_not_index_tl
3069 {
3070 \tl_set_rescan:NnV \l_@@_macro_do_not_index_tl
3071 { \MakePrivateLetters \catcode`\\12 }
3072 \l_@@_macro_do_not_index_tl
3073 \exp_args:NNV \seq_set_from_clist:Nn
3074 \l_@@_tmpa_seq \l_@@_macro_do_not_index_tl
3075 \__kernel_tl_set:Nx \l_@@_macro_do_not_index_tl
3076 { \seq_use:Nn \l_@@_tmpa_seq { , } }
3077 \exp_args:NV \DoNotIndex \l_@@_macro_do_not_index_tl
3078 }
3079 }
3080 % \end{macrocode}
3081 % \end{macro}
3082 %
3083 % \begin{macro}{\@@_macro_dump:}
3084 % This calls |\makelabel{}|
3085 % \begin{macrocode}
3086 \cs_new_protected:Npn \@@_macro_dump:
3087 {
3088 \topsep\MacroTopsep
3089 \trivlist
3090 \cs_set:Npn \makelabel ##1
3091 {
3092 \llap
3093 {
3094 \hbox_unpack_drop:N \l_@@_macro_index_box
3095 \vtop to \baselineskip
3096 {
3097 \vbox_unpack_drop:N \l_@@_macro_box
3098 \vss
3099 }
3100 }
3101 }
3102 \item [ ]
3103 }
3104 % \end{macrocode}
3105 % \end{macro}
3106 %
3107 % \begin{macro}{\@@_macro_typeset_block:nN}
3108 % Used to typeset a macro and its variants. |#1| is the macro name,
3109 % |#2| is a boolean controlling whether to add |TF|.
3110 % \begin{macrocode}
3111 \cs_new_protected:Npn \@@_macro_typeset_block:nN #1#2
3112 {
3113 \@@_macro_single:nNN {#1} \c_true_bool #2
3114 \seq_if_empty:NF \g_@@_variants_seq
3115 {
3116 \@@_macro_typeset_variant_list:eN
3117 { \@@_get_function_name:n {#1} } #2
3118 }
3119 }
3120 \cs_new_protected:Npn \@@_macro_typeset_variant_list:nN #1#2
3121 {
3122 \seq_map_inline:Nn \g_@@_variants_seq
3123 { \@@_macro_single:nNN { #1 : ##1 } \c_false_bool #2 }
3124 }
3125 \cs_generate_variant:Nn \@@_macro_typeset_variant_list:nN { e }
3126 % \end{macrocode}
3127 % \end{macro}
3128 %
3129 % \begin{macro}{\@@_macro_single:nNN}
3130 % The arguments are |#1| a macro name (without |TF|), |#2| a boolean
3131 % determining whether or not to index, and |#3| whether or not to add |TF|.
3132 % Let's start to mess around with \cls{doc}'s \env{macro} environment.
3133 % See \file{doc.dtx} for a full explanation of the original
3134 % environment. It's rather \emph{enthusiastically} commented.
3135 % \begin{arguments}
3136 % \item Macro/function/whatever name; input has already been
3137 % sanitized.
3138 % \end{arguments}
3139 % The assignments to \cs{saved@macroname} and \cs{saved@indexname}
3140 % are used by \pkg{doc}'s \cs{changes} mechanism.
3141 % \begin{macrocode}
3142 \cs_new_protected:Npn \@@_macro_single:nNN #1#2#3
3143 {
3144 \tl_set:Nn \saved@macroname {#1}
3145 \@@_macro_typeset_one:nN {#1} #3
3146 \bool_if:NT #3 { \DoNotIndex {#1} }
3147 \exp_args:Ne \@@_macro_index:nN
3148 { #1 \bool_if:NT #3 { \tl_to_str:n { TF } } }
3149 #2
3150 }
3151 \cs_new_protected:Npn \@@_macro_index:nN #1#2
3152 {
3153 \DoNotIndex {#1}
3154 \bool_if:NT #2
3155 {
3156 \bool_lazy_any:nF
3157 {
3158 { \@@_if_macro_internal_p:n {#1} }
3159 { \l_@@_macro_deprecated_bool }
3160 { \l_@@_macro_nodoc_bool }
3161 }
3162 { \seq_gput_right:Nn \g_doc_macros_seq {#1} }
3163 \hbox_set:Nw \l_@@_macro_index_box
3164 \hbox_unpack_drop:N \l_@@_macro_index_box
3165 \int_gincr:N \c@CodelineNo
3166 \@@_special_index:nn {#1} { main }
3167 \int_gdecr:N \c@CodelineNo
3168 \exp_args:NNNo \hbox_set_end:
3169 \tl_set:Nn \saved@indexname { \l_@@_index_key_tl }
3170 }
3171 }
3172 % \end{macrocode}
3173 % \end{macro}
3174 %
3175 % \begin{macro}{\@@_macro_typeset_one:nN}
3176 % For a long time, \cls{l3doc} collected the macro names as labels in
3177 % the first items of nested \tn{trivlist}, but these were not closed
3178 % properly with \tn{endtrivlist}. Also, it interacted in surprising
3179 % ways with \pkg{hyperref} targets. Now, we collect typeset macro
3180 % names by hand in the box \cs{l_@@_macro_box}. The fixed-size space
3181 % |\MacroFont\ | could be replaced by an customizable horizontal
3182 % space; it is important for it to be the same for all macros.
3183 % |#1| is the macro name, |#2| whether to add |TF|.
3184 % \begin{macrocode}
3185 \cs_new_protected:Npn \@@_macro_typeset_one:nN #1#2
3186 {
3187 \vbox_set:Nn \l_@@_macro_box
3188 {
3189 \vbox_unpack_drop:N \l_@@_macro_box
3190 \hbox { \llap { \@@_print_macroname:nN {#1} #2
3191 \MacroFont \
3192 } }
3193 }
3194 \int_incr:N \l_@@_macro_int
3195 }
3196 % \end{macrocode}
3197 % \end{macro}
3198 %
3199 % \begin{macro}{\@@_print_macroname:nN}
3200 % In the name, spaces are replaced by other spaces to ensure they get
3201 % displayed in case there are any.
3202 % \begin{macrocode}
3203 \cs_new_protected:Npn \@@_print_macroname:nN #1#2
3204 {
3205 \strut
3206 \@@_get_hyper_target:eN
3207 {
3208 \exp_not:n {#1}
3209 \bool_if:NT #2 { \tl_to_str:n {TF} }
3210 }
3211 \l_@@_tmpa_tl
3212 \cs_if_exist:cTF { r@ \l_@@_tmpa_tl }
3213 { \exp_last_unbraced:NNo \hyperref [ \l_@@_tmpa_tl ] }
3214 { \use:n }
3215 {
3216 \int_compare:nTF { \str_count:n {#1} <= 28 }
3217 { \MacroFont } { \MacroLongFont }
3218 \tl_set:Nn \l_@@_tmpa_tl {#1}
3219 \tl_replace_all:NnV \l_@@_tmpa_tl
3220 { ~ } \c_catcode_other_space_tl
3221 \@@_print_macroname_aux:on
3222 \l_@@_tmpa_tl { \bool_if:NT #2 { \@@_typeset_TF: } }
3223 }
3224 }
3225 % \end{macrocode}
3226 % \end{macro}
3227 %
3228 % \begin{macro}{\@@_print_macroname_aux:nn, \@@_print_macroname_aux:on}
3229 % |#1| is prefix, |#2| is optional |TF| suffix.
3230 % \begin{macrocode}
3231 \cs_new_protected:Npn \@@_print_macroname_aux:nn #1#2
3232 {
3233 \@@_if_macro_internal:nTF {#1}
3234 { \@@_typeset_aux:n { #1 #2 } } { #1 #2 }
3235 }
3236 \cs_generate_variant:Nn \@@_print_macroname_aux:nn { o }
3237 % \end{macrocode}
3238 % \end{macro}
3239 %
3240 % \begin{macro}{\MacroLongFont}
3241 % \begin{macrocode}
3242 \providecommand \MacroLongFont
3243 {
3244 \fontfamily{lmtt}\fontseries{lc}\small
3245 }
3246 % \end{macrocode}
3247 % \end{macro}
3248 %
3249 % \begin{macro}{\@@_print_testfile:n, \@@_print_testfile_aux:n}
3250 % Used to show that a macro has a test, somewhere.
3251 % \begin{macrocode}
3252 \cs_new_protected:Npn \@@_print_testfile:n #1
3253 {
3254 \bool_set_true:N \l_@@_macro_tested_bool
3255 \tl_if_eq:nnF {#1} {*}
3256 {
3257 \seq_if_in:NnF \g_@@_testfiles_seq {#1}
3258 {
3259 \seq_gput_right:Nn \g_@@_testfiles_seq {#1}
3260 \par
3261 \@@_print_testfile_aux:n {#1}
3262 }
3263 }
3264 }
3265 \cs_new_protected:Npn \@@_print_testfile_aux:n #1
3266 {
3267 \footnotesize
3268 (
3269 \textit
3270 {
3271 The~ test~ suite~ for~ this~ command,~
3272 and~ others~ in~ this~ file,~ is~ \textsf{#1}
3273 }.
3274 )\par
3275 }
3276 % \end{macrocode}
3277 % \end{macro}
3278 %
3279 % \begin{macro}{\TestFiles}
3280 % \begin{macrocode}
3281 \DeclareDocumentCommand \TestFiles {m}
3282 {
3283 \par
3284 \textit
3285 {
3286 The~ following~ test~ files~ are~
3287 used~ for~ this~ code:~ \textsf{#1}.
3288 }
3289 \par \ignorespaces
3290 }
3291 % \end{macrocode}
3292 % \end{macro}
3293 %
3294 % \begin{macro}{\UnitTested}
3295 % \begin{macrocode}
3296 \DeclareDocumentCommand \UnitTested { } { \testfile* }
3297 % \end{macrocode}
3298 % \end{macro}
3299 %
3300 % \begin{macro}{\TestMissing}
3301 % \begin{macrocode}
3302 \DeclareDocumentCommand \TestMissing { m }
3303 { \@@_test_missing:n {#1} }
3304 % \end{macrocode}
3305 % \end{macro}
3306 %
3307 % \begin{macro}{\@@_test_missing:n}
3308 % Keys in \cs{g_@@_missing_tests_prop} are lists of macros given as
3309 % arguments of one \env{macro} environment. Values are pairs of a
3310 % file name and a comment about the missing tests.
3311 % \begin{macrocode}
3312 \cs_new_protected:Npn \@@_test_missing:n #1
3313 {
3314 \@@_test_missing_aux:Nen
3315 \g_@@_missing_tests_prop
3316 { \seq_use:Nn \l_@@_names_seq { , } }
3317 { { \g_file_curr_name_str \c_space_tl (#1) } }
3318 }
3319 \cs_new_protected:Npn \@@_test_missing_aux:Nnn #1#2#3
3320 {
3321 \prop_get:NnNTF #1 {#2} \l_@@_tmpa_tl
3322 { \tl_put_right:Nn \l_@@_tmpa_tl { , #3 } }
3323 { \tl_set:Nn \l_@@_tmpa_tl {#3} }
3324 \prop_put:Nno #1 {#2} \l_@@_tmpa_tl
3325 }
3326 \cs_generate_variant:Nn \@@_test_missing_aux:Nnn { Ne }
3327 % \end{macrocode}
3328 % \end{macro}
3329 %
3330 % \begin{macro}{\@@_macro_end:}
3331 % It is too late for anyone to declare a test file for this macro, so
3332 % we can check now whether the macro is tested. If the \env{macro}
3333 % environment which is being ended is the outermost one, then wrap
3334 % each macro in \tn{texttt} (with the addition of |TF| if relevant)
3335 % and typeset two pieces of information: that this ends the definition of some
3336 % macros, and that they are documented on some page.
3337 % \begin{macrocode}
3338 \cs_new_protected:Npn \@@_macro_end:
3339 {
3340 \endtrivlist
3341 \@@_macro_end_check_tested:
3342 \int_compare:nNnT \l_@@_nested_macro_int = 1
3343 { \@@_macro_end_style:n { \@@_print_end_definition: } }
3344 }
3345 % \end{macrocode}
3346 % \end{macro}
3347 %
3348 % \begin{macro}{\@@_macro_end_check_tested:}
3349 % If the |checktest| option was issued and the macro is not an
3350 % auxiliary nor a variable (and it does not have a test), then add it
3351 % to the sequence of non-tested macros.
3352 % \begin{macrocode}
3353 \cs_new_protected:Npn \@@_macro_end_check_tested:
3354 {
3355 \bool_lazy_all:nT
3356 {
3357 { \g_@@_checktest_bool }
3358 { ! \l_@@_macro_var_bool }
3359 { ! \l_@@_macro_tested_bool }
3360 }
3361 {
3362 \seq_set_filter:NNn \l_@@_tmpa_seq \l_@@_names_seq
3363 { ! \@@_if_macro_internal_p:n {##1} }
3364 \seq_gput_right:Ne \g_@@_not_tested_seq
3365 {
3366 \seq_use:Nn \l_@@_tmpa_seq { , }
3367 \bool_if:NTF \l_@@_macro_pTF_bool {~(pTF)}
3368 { \bool_if:NT \l_@@_macro_TF_bool {~(TF)} }
3369 }
3370 }
3371 }
3372 % \end{macrocode}
3373 % \end{macro}
3374 %
3375 % \begin{macro}{\@@_macro_end_style:n}
3376 % Style for the extra information at the end of a top-level
3377 % \env{macro} environment.
3378 % \begin{macrocode}
3379 \cs_new_protected:Npn \@@_macro_end_style:n #1
3380 {
3381 \nobreak \noindent
3382 { \footnotesize ( \emph{#1} ) \par }
3383 }
3384 % \end{macrocode}
3385 % \end{macro}
3386 %
3387 % \begin{macro}
3388 % {
3389 % \@@_print_end_definition:,
3390 % \@@_macro_end_wrap_item:n,
3391 % \@@_print_documented:
3392 % }
3393 % Surround each item by \tn{texttt}, replacing |_|
3394 % by \tn{_} as well. Then list the
3395 % macro names through \cs{seq_use:Nnnn}, unless there are too many.
3396 % Finally, if the macro is neither auxiliary nor internal, add a link
3397 % to where it is documented.
3398 % \begin{macrocode}
3399 \cs_new_protected:Npn \@@_macro_end_wrap_item:n #1
3400 {
3401 \tl_set:Nn \l_@@_tmpa_tl {#1}
3402 \tl_replace_all:NVn \l_@@_tmpa_tl
3403 \c_underscore_str { \_ }
3404 \texttt { \l_@@_tmpa_tl }
3405 }
3406 \cs_new_protected:Npn \@@_print_end_definition:
3407 {
3408 \seq_set_map:NNn \l_@@_tmpa_seq
3409 \g_@@_nested_names_seq
3410 { \@@_macro_end_wrap_item:n {##1} }
3411 End~ of~ definition~ for~
3412 \int_compare:nTF { \seq_count:N \l_@@_tmpa_seq <= 3 }
3413 {
3414 \seq_use:Nnnn \l_@@_tmpa_seq
3415 { \,~and~ } { \,,~ } { \,,~and~ }
3416 }
3417 { \seq_item:Nn \l_@@_tmpa_seq {1}\,~and~others }
3418 \@.
3419 \@@_print_documented:
3420 }
3421 \cs_new_protected:Npn \@@_print_documented:
3422 {
3423 \seq_gset_filter:NNn \g_@@_nested_names_seq
3424 \g_@@_nested_names_seq
3425 {
3426 ! \bool_lazy_any_p:n
3427 {
3428 { \@@_if_macro_internal_p:n {##1} }
3429 { \l_@@_macro_deprecated_bool }
3430 { \l_@@_macro_nodoc_bool }
3431 }
3432 }
3433 \seq_if_empty:NF \g_@@_nested_names_seq
3434 {
3435 \int_set:Nn \l_@@_tmpa_int
3436 { \seq_count:N \g_@@_nested_names_seq }
3437 \int_compare:nNnTF \l_@@_tmpa_int = 1 {~This~} {~These~}
3438 \bool_if:NTF \l_@@_macro_var_bool {variable} {function}
3439 \int_compare:nNnTF \l_@@_tmpa_int = 1 {~is~} {s~are~}
3440 documented~on~page~
3441 \@@_get_hyper_target:eN
3442 { \seq_item:Nn \g_@@_nested_names_seq { 1 } }
3443 \l_@@_tmpa_tl
3444 \exp_args:Ne \pageref { \l_@@_tmpa_tl } .
3445 }
3446 \seq_gclear:N \g_@@_nested_names_seq
3447 }
3448 % \end{macrocode}
3449 % \end{macro}
3450 %
3451 % \subsubsection{Misc}
3452 %
3453 % \begin{macro}{\DescribeOption}
3454 % For describing package options: retained for consistency, but updated for
3455 % \pkg{doc}~v3.
3456 % \begin{macrocode}
3457 \NewDocElement[idxtype = option, idxgroup = options]{Option}{optionenv}
3458 % \end{macrocode}
3459 % \end{macro}
3460 %
3461 % Here are some definitions for additional markup that helps to
3462 % structure your documentation.
3463 %
3464 % \begin{environment}{danger}
3465 % \begin{environment}{ddanger}
3466 % \begin{syntax}
3467 % |\begin{[d]danger}|\\
3468 % dangerous code\\
3469 % |\end{[d]danger}|
3470 % \end{syntax}
3471 % \begin{danger}
3472 % Provides a danger bend, as known from the \TeX{}book.
3473 % \end{danger}
3474 % The actual character from the font |manfnt|:
3475 % \begin{macrocode}
3476 \font \manual = manfnt \scan_stop:
3477 \cs_gset:Npn \dbend { {\manual\char127} }
3478 % \end{macrocode}
3479 %
3480 % Defines the single danger bend. Use it whenever there is a feature in
3481 % your package that might be tricky to use. FIXME: Has to be fixed when
3482 % in combination with a macro-definition.
3483 % \begin{macrocode}
3484 \newenvironment {danger}
3485 {
3486 \begin{trivlist}\item[]\noindent
3487 \begingroup\hangindent=2pc\hangafter=-2
3488 \cs_set:Npn \par{\endgraf\endgroup}
3489 \hbox to0pt{\hskip-\hangindent\dbend\hfill}\ignorespaces
3490 }
3491 {
3492 \par\end{trivlist}
3493 }
3494 % \end{macrocode}
3495 %
3496 % \begin{ddanger}
3497 % Use the double danger bend if there is something which could cause
3498 % serious problems when used in a wrong way. Better the normal user
3499 % does not know about such things.
3500 % \end{ddanger}
3501 % \begin{macrocode}
3502 \newenvironment {ddanger}
3503 {
3504 \begin{trivlist}\item[]\noindent
3505 \begingroup\hangindent=3.5pc\hangafter=-2
3506 \cs_set:Npn \par{\endgraf\endgroup}
3507 \hbox to0pt{\hskip-\hangindent\dbend\kern2pt\dbend\hfill}\ignorespaces
3508 }{
3509 \par\end{trivlist}
3510 }
3511 % \end{macrocode}
3512 % \end{environment}
3513 % \end{environment}
3514 %
3515 % \subsubsection{NB and NOTE}
3516 %
3517 % These macros are intended for additional notes added to the source that are not typeset.
3518 %
3519 % \begin{macro}{\NB}
3520 % \NB{wspr}{this is what I think about this!}
3521 % \begin{verbatim}
3522 % \NB{wspr}{this is what I think about this!}
3523 % \end{verbatim}
3524 % \begin{macrocode}
3525 \bool_if:NTF \g_@@_show_notes_bool
3526 {
3527 \NewDocumentCommand\NB{mm}
3528 {
3529 (\emph{Note}\footnote{\ttfamily [#1]:~\detokenize{#2}})
3530 }
3531 }
3532 {
3533 \NewDocumentCommand\NB{mm}{}
3534 }
3535 % \end{macrocode}
3536 % \end{macro}
3537 %
3538 % \begin{environment}{NOTE}
3539 % \begin{NOTE}{wspr}
3540 % this is what I #$%& think about this!
3541 % \end{NOTE}
3542 % \begin{verbatim}
3543 % \begin{NOTE}{wspr}
3544 % this is what I #$%& think about this!
3545 % \end{NOTE}
3546 % \end{verbatim}
3547 % \begin{macrocode}
3548 \bool_if:NTF \g_@@_show_notes_bool
3549 {
3550 \NewDocumentEnvironment{NOTE}{m}
3551 {
3552 \par\noindent (\emph{Note}~[\texttt{#1}]:\par
3553 \verbatim
3554 }
3555 {
3556 \endverbatim
3557 \par\noindent \emph{Note~end})\par
3558 }
3559 }
3560 {
3561 \NewDocumentEnvironment{NOTE}{m}{\comment}{\endcomment}
3562 }
3563 % \end{macrocode}
3564 % \end{environment}
3565 %
3566 % \subsection{Footnote support}
3567 % The environments \env{function} and \env{variable} are boxes
3568 % and so looses footnotes. The following implements support.
3569 % It relies currently on an internal from hyperref to get the correct targets.
3570 %
3571 % \begin{macrocode}
3572 \providecommand\Hy@footnote@currentHref{}
3573 \prop_new:N\g_@@_fnmark_prop
3574 \cs_new_protected:Npn \@@_fn_store:
3575 {
3576 \prop_gput:Nee\g_@@_fnmark_prop
3577 {fn\int_use:N\c@footnote}{{\Hy@footnote@currentHref}{\int_use:N\c@footnote}}
3578 }
3579 \cs_new_protected:Npn \@@_fn_restore:n #1
3580 {
3581 \prop_get:NnN \g_@@_fnmark_prop {fn#1}\l_@@_tmpa_tl
3582 \tl_gset:Ne\Hy@footnote@currentHref
3583 {\exp_last_unbraced:NV\use_i:nn \l_@@_tmpa_tl }
3584 \setcounter{footnote}{\exp_last_unbraced:NV\use_ii:nn \l_@@_tmpa_tl}
3585 }
3586
3587 \cs_generate_variant:Nn \hook_gput_next_code:nn {ne}
3588 \cs_new_protected:Npn \@@_fn_footnote:nn #1 #2
3589 {
3590 \footnotemark
3591 \@@_fn_store:
3592 \hook_gput_next_code:ne {env/#1/after}
3593 {\exp_not:N\@@_fn_restore:n{\int_use:N\c@footnote}{\exp_not:n{\footnotetext{#2}}}}}
3594
3595 \AddToHook{env/function/begin}{\def\footnote{\@@_fn_footnote:nn{function}}}
3596 \AddToHook{env/variable/begin}{\def\footnote{\@@_fn_footnote:nn{variable}}}
3597 % \end{macrocode}
3598 %
3599 % \subsection{Documenting templates}
3600 %
3601 % \begin{macrocode}
3602 \newenvironment{TemplateInterfaceDescription}[1]
3603 {
3604 \subsection{The~template~type~`#1'}
3605 \begingroup
3606 \@beginparpenalty\@M
3607 \description
3608 \def\TemplateArgument##1##2{\item[Arg:~##1]##2\par}
3609 \def\TemplateSemantics
3610 {
3611 \enddescription\endgroup
3612 \subsubsection*{Semantics:}
3613 }
3614 }
3615 {
3616 \par\bigskip
3617 }
3618 % \end{macrocode}
3619 %
3620 % \begin{macrocode}
3621 \newenvironment{TemplateDescription}[2]
3622 {
3623 \subsection{The~template~`#2'~(template~type~#1)}
3624 \subsubsection*{Attributes:}
3625 \begingroup
3626 \@beginparpenalty\@M
3627 \description
3628 \def\TemplateKey##1##2##3##4
3629 {
3630 \item[##1~(##2)]##3%
3631 \ifx\TemplateKey##4\TemplateKey\else
3632 % \hskip0ptplus3em\penalty-500\hskip 0pt plus 1filll Default:~##4%
3633 \hfill\penalty500\hbox{}\hfill Default:~##4%
3634 \nobreak\hskip-\parfillskip\hskip0pt\relax
3635 \fi
3636 \par
3637 }
3638 \def\TemplateSemantics
3639 {
3640 \enddescription\endgroup
3641 \subsubsection*{Semantics~\&~Comments:}
3642 }
3643 }
3644 { \par \bigskip }
3645 % \end{macrocode}
3646 %
3647 % \begin{macrocode}
3648 \newenvironment{InstanceDescription}[4][xxxxxxxxxxxxxxx]
3649 {
3650 \subsubsection{The~instance~`#3'~(template~#2/#4)}
3651 \subsubsection*{Attribute~values:}
3652 \begingroup
3653 \@beginparpenalty\@M
3654 \def\InstanceKey##1##2{\>\textbf{##1}\>##2\\}
3655 \def\InstanceSemantics{\endtabbing\endgroup
3656 \vskip-30pt\vskip0pt
3657 \subsubsection*{Layout~description~\&~Comments:}}
3658 \tabbing
3659 xxxx\=#1\=\kill
3660 }
3661 { \par \bigskip }
3662 % \end{macrocode}
3663 %
3664 % \subsection{Inheriting doc}
3665 %
3666 % Code here is taken from \pkg{doc}, stripped of comments and translated
3667 % into \pkg{expl3} syntax. New features are added in various places.
3668 %
3669 % \begin{macro}
3670 % {\StopEventually, \MaybeStop, \Finale, \AlsoImplementation, \OnlyDescription}
3671 % \begin{variable}{\g_@@_finale_tl}
3672 % TODO: remove these four commands altogether, document that it is
3673 % better to use the \env{documentation} and \env{implementation}
3674 % environments.
3675 % \begin{macrocode}
3676 \DeclareDocumentCommand \OnlyDescription { }
3677 { \bool_gset_false:N \g_@@_typeset_implementation_bool }
3678 \DeclareDocumentCommand \AlsoImplementation { }
3679 { \bool_gset_true:N \g_@@_typeset_implementation_bool }
3680 \DeclareDocumentCommand \StopEventually { m }
3681 {
3682 \bool_if:NTF \g_@@_typeset_implementation_bool
3683 {
3684 \@bsphack
3685 \tl_gset:Nn \g_@@_finale_tl { #1 \check@checksum }
3686 \init@checksum
3687 \@esphack
3688 }
3689 { #1 \endinput }
3690 }
3691 % \end{macrocode}
3692 % We also need to support doc V3 \cs{MaybeStop} if it is around
3693 % (which may not be the case).
3694 % \begin{macrocode}
3695 \cs_if_exist:NT \MaybeStop
3696 { \RenewCommandCopy \MaybeStop \StopEventually }
3697 % \end{macrocode}
3698 %
3699 % \begin{macrocode}
3700 \DeclareDocumentCommand \Finale { }
3701 { \tl_use:N \g_@@_finale_tl }
3702 \tl_new:N \g_@@_finale_tl
3703 % \end{macrocode}
3704 % \end{variable}
3705 % \end{macro}
3706 %
3707 % \begin{macro}{\@@_input:n}
3708 % Inputting a file, with some setup: the module name should be empty
3709 % before the first |<@@=|\meta{module}|>| line in the file.
3710 % \begin{macrocode}
3711 \cs_new_protected:Npn \@@_input:n #1
3712 {
3713 \tl_gclear:N \g_@@_module_name_tl
3714 \MakePercentIgnore
3715 \input{#1}
3716 \MakePercentComment
3717 }
3718 % \end{macrocode}
3719 % \end{macro}
3720 %
3721 % \begin{macro}{\DocInput}
3722 % Modified from \pkg{doc} to accept comma-list input (who has commas
3723 % in filenames?).
3724 % \begin{macrocode}
3725 \DeclareDocumentCommand \DocInput { m }
3726 {
3727 \clist_map_inline:nn {#1}
3728 {
3729 \clist_gput_right:Nn \g_docinput_clist {##1}
3730 \@@_input:n {##1}
3731 }
3732 }
3733 % \end{macrocode}
3734 % \end{macro}
3735 %
3736 % \begin{macro}{\DocInputAgain}
3737 % Uses \cs{g_docinput_clist} to re-input whatever's already been
3738 % \tn{DocInput}-ed until now. May be used multiple times.
3739 % \begin{macrocode}
3740 \DeclareDocumentCommand \DocInputAgain { }
3741 { \clist_map_function:NN \g_docinput_clist \@@_input:n }
3742 % \end{macrocode}
3743 % \end{macro}
3744 %
3745 % \begin{macro}{\DocInclude}
3746 % More or less exactly the same as \tn{include}, but uses
3747 % \tn{DocInput} on a \file{.fdd} or \file{.dtx} file (without file
3748 % extension), not \tn{input} on a \file{.tex} file.
3749 %
3750 % \begin{macrocode}
3751 \msg_new:nnn { l3doc } { missing-endgroup }
3752 {
3753 \str_if_eq:VnTF \@currenvir { document }
3754 {
3755 There~are~\int_use:N \tex_currentgrouplevel:D
3756 \c_space_tl unclosed~groups~in~#1.
3757 }
3758 {
3759 The~\@currenvir \c_space_tl environment~on~line~\@currenvline
3760 \c_space_tl doesn't~have~a~matching~\iow_char:N\\end{\@currenvir}.
3761 }
3762 }
3763 \NewDocumentCommand \DocInclude { m }
3764 {
3765 \relax\clearpage
3766 \docincludeaux
3767 \IfFileExists{#1.fdd}
3768 { \cs_set:Npn \currentfile{#1.fdd} }
3769 { \cs_set:Npn \currentfile{#1.dtx} }
3770 \int_compare:nNnTF \@auxout = \@partaux
3771 { \@latexerr{\string\include\space cannot~be~nested}\@eha }
3772 { \@docinclude {#1} }
3773 % check missing \endgroup, e.g., missing "\end{macro}" in time
3774 \int_compare:nNnF { \tex_currentgrouplevel:D } = { 0 }
3775 {
3776 \int_compare:nNnT { \tex_interactionmode:D } = { 0 }
3777 { \int_gset:Nn \tex_interactionmode:D { 1 } }
3778 \msg_fatal:nne { l3doc } { missing-endgroup } { \currentfile }
3779 }
3780 }
3781 % \end{macrocode}
3782 %
3783 % \begin{macrocode}
3784 \cs_gset:Npn \@docinclude #1
3785 {
3786 \clearpage
3787 \immediate\write\@mainaux{\string\@input{#1.aux}}
3788 \@tempswatrue
3789 \if@partsw
3790 \@tempswafalse
3791 \cs_set:Npe \@tempb {#1}
3792 \clist_map_inline:Nn \@partlist
3793 {
3794 \if_meaning:w \@tempa \@tempb
3795 \@tempswatrue
3796 \fi:
3797 }
3798 \fi
3799 \if@tempswa
3800 \cs_set_eq:NN \@auxout \@partaux
3801 \immediate\openout\@partaux #1.aux
3802 \immediate\write\@partaux{\relax}
3803 \cs_set_eq:NN \@ltxdoc@PrintIndex \PrintIndex
3804 \cs_set_eq:NN \PrintIndex \relax
3805 \cs_set_eq:NN \@ltxdoc@PrintChanges \PrintChanges
3806 \cs_set_eq:NN \PrintChanges \relax
3807 \cs_set_eq:NN \@ltxdoc@theglossary \theglossary
3808 \cs_set_eq:NN \@ltxdoc@endtheglossary \endtheglossary
3809 \part{\currentfile}
3810 {
3811 \cs_set_eq:NN \ttfamily\relax
3812 \cs_gset:Npe \filekey
3813 { \filekey,~ \thepart = { \ttfamily \currentfile } }
3814 }
3815 \DocInput{\currentfile}
3816 \cs_set_eq:NN \PrintIndex \@ltxdoc@PrintIndex
3817 \cs_set_eq:NN \PrintChanges \@ltxdoc@PrintChanges
3818 \cs_set_eq:NN \theglossary \@ltxdoc@theglossary
3819 \cs_set_eq:NN \endtheglossary \@ltxdoc@endtheglossary
3820 \clearpage
3821 \@writeckpt{#1}
3822 \immediate \closeout \@partaux
3823 \else
3824 \@nameuse{cp@#1}
3825 \fi
3826 \cs_set_eq:NN \@auxout \@mainaux
3827 }
3828 % \end{macrocode}
3829 %
3830 % Here, |MMMMI| (for page references) and |MMMMV| (for codeline
3831 % references) are interpreted by |makeindex| as an uppercase Roman
3832 % number pages, and should be large enough to avoid collisions with
3833 % other uses of uppercase Roman number pages. Two subtle differences
3834 % between \cs{@wrindex} and \cs{codeline@wrindex} are that the first
3835 % must be a delayed write because the page number is not known yet, and
3836 % it must close a group and finish some space-hack.
3837 %
3838 % We also provide versions for our use that refer
3839 % \begin{macrocode}
3840 \cs_gset_protected:Npn \@wrindex #1
3841 {
3842 \protected@write \@indexfile {}
3843 { \string \indexentry {#1} { MMMMI - \thepage } }
3844 \endgroup \@esphack
3845 }
3846 \cs_gset_protected:Npn \codeline@wrindex #1
3847 {
3848 \immediate\write\@indexfile
3849 {
3850 \string\indexentry{#1}
3851 { MMMMV - \filesep \int_use:N \c@CodelineNo }
3852 }
3853 }
3854 \tl_clear_new:N \filesep
3855 \cs_new_protected:Npn \@@_index_page_hc:nn #1#2
3856 {
3857 \protected@write \@indexfile {}
3858 {
3859 \string \indexentry { #1 \encapchar hdpindex{#2} }
3860 { MMMMI - \thepage }
3861 }
3862 }
3863 \cs_new_protected:Npn \@@_index_codeline_hc:nn #1#2
3864 {
3865 \immediate\write\@indexfile
3866 {
3867 \string \indexentry { #1 \encapchar hdclindex{\the\c@HD@hypercount}{#2} }
3868 { MMMMV - \filesep \int_use:N \c@CodelineNo - MMMD - \the\c@HD@hypercount - M }
3869 }
3870 }
3871 % \end{macrocode}
3872 % We already have a single |HD.xx| target per code line. It would be
3873 % better to have a target |CL.\the\c@CodelineNo| per code line and
3874 % change |hdclindex{\the\c@HD@hypercount}| to a mechanism closer to
3875 % |hdpindex|, but we need to understand better the different types of
3876 % indexings, and there are subtleties with indexing |\{| and |\}|.
3877 % \end{macro}
3878 %
3879 % \begin{macro}{\docincludeaux}
3880 % \begin{macrocode}
3881 \cs_gset:Npn \docincludeaux
3882 {
3883 \tl_set:Nn \thepart { \alphalph { part } }
3884 \tl_set:Nn \filesep { \thepart - }
3885 \cs_set_eq:NN \filekey \use_none:n
3886 \tl_gput_right:Nn \index@prologue
3887 {
3888 \cs_gset:Npn \@oddfoot
3889 {
3890 \parbox { \textwidth }
3891 {
3892 \strut \footnotesize
3893 \raggedright { \bfseries File~Key: } ~ \filekey
3894 }
3895 }
3896 \cs_set_eq:NN \@evenfoot \@oddfoot
3897 }
3898 \cs_gset_eq:NN \docincludeaux \relax
3899 \cs_gset:Npn \@oddfoot
3900 {
3901 \cs_if_exist:cTF { ver @ \currentfile }
3902 { File~\thepart :~{\ttfamily\currentfile}~ }
3903 {
3904 \GetFileInfo{\currentfile}
3905 File~\thepart :~{\ttfamily\filename}~
3906 Date:~\ExplFileDate\ % space
3907 Version~\ExplFileVersion
3908 }
3909 \hfill \thepage
3910 }
3911 \cs_set_eq:NN \@evenfoot \@oddfoot
3912 }
3913 % \end{macrocode}
3914 % \end{macro}
3915 %
3916 % \subsubsection{The \env{macrocode} environment}
3917 %
3918 % \begin{macro}{\xmacro@code, \@@_xmacro_code:n, \@@_xmacro_code:w}
3919 % Hook into the \texttt{macrocode} environment in a dirty way:
3920 % \tn{xmacro@code} is responsible for grabbing (and tokenizing) the
3921 % body of the environment. Redefine it to pass what it grabs to
3922 % \cs{@@_xmacro_code:n}. This new macro replaces all |@@| by the
3923 % appropriate module name. One exceptional case is the
3924 % |<@@=|\meta{module}|>| lines themselves, where |@@| should not be
3925 % modified. Actually, we search for such lines, to set the module
3926 % name automatically. We need to be careful: no |<@@=| should appear
3927 % as such in the code below since \pkg{l3doc} is also typeset using
3928 % this code.
3929 % At each |<@@=| found, replace the \meta{module} in the code behind
3930 % it, update the \meta{module}, and loop to check for further
3931 % occurrences of |<@@=|.
3932 % \begin{macrocode}
3933 \group_begin:
3934 \char_set_catcode_other:N \^^A
3935 \char_set_catcode_active:N \^^S
3936 \char_set_catcode_active:N \^^B
3937 \char_set_catcode_other:N \^^L
3938 \char_set_catcode_other:N \^^R
3939 \char_set_lccode:nn { `\^^A } { `\% }
3940 \char_set_lccode:nn { `\^^S } { `\ }
3941 \char_set_lccode:nn { `\^^B } { `\\ }
3942 \char_set_lccode:nn { `\^^L } { `\{ }
3943 \char_set_lccode:nn { `\^^R } { `\} }
3944 \tex_lowercase:D
3945 {
3946 \group_end:
3947 \cs_set_protected:Npn \xmacro@code
3948 #1 ^^A ^^S^^S^^S^^S ^^Bend ^^Lmacrocode^^R
3949 { \@@_xmacro_code:n {#1} \end{macrocode} }
3950 }
3951 \group_begin:
3952 \char_set_catcode_active:N \<
3953 \char_set_catcode_active:N \>
3954 \cs_new_protected:Npn \@@_xmacro_code:n #1
3955 {
3956 \tl_clear:N \l_@@_tmpa_tl
3957 \tl_if_in:nnTF {#1} { < @ @ = }
3958 { \@@_xmacro_code:w #1 < @ @ = \q_recursion_tail > \q_recursion_stop }
3959 {
3960 \tl_set:Nn \l_@@_tmpa_tl {#1}
3961 \@@_detect_internals:N \l_@@_tmpa_tl
3962 \@@_replace_at_at:N \l_@@_tmpa_tl
3963 \tl_use:N \l_@@_tmpa_tl
3964 }
3965 }
3966 \cs_new_protected:Npn \@@_xmacro_code:w #1 < @ @ = #2 >
3967 {
3968 % Add code before <@@@@=...>
3969 \tl_set:Nn \l_@@_tmpb_tl {#1}
3970 \@@_detect_internals:N \l_@@_tmpb_tl
3971 \@@_replace_at_at:N \l_@@_tmpb_tl
3972 \tl_put_right:NV \l_@@_tmpa_tl \l_@@_tmpb_tl
3973 % Check for \q_recursion_tail
3974 \quark_if_recursion_tail_stop_do:nn {#2}
3975 { \tl_use:N \l_@@_tmpa_tl }
3976 % Change module name and add <@@@@=#2> to typeset output
3977 \tl_gset:Nn \g_@@_module_name_tl {#2}
3978 \tl_put_right:Nn \l_@@_tmpa_tl { < \text { \verbatim@font @ @ = #2 } > }
3979 % Loop
3980 \@@_xmacro_code:w
3981 }
3982 \group_end:
3983 % \end{macrocode}
3984 % \end{macro}
3985 %
3986 % \subsection{At end document}
3987 %
3988 % Print all defined and documented macros/functions.
3989 %
3990 % \begin{macrocode}
3991 \iow_new:N \g_@@_func_iow
3992 % \end{macrocode}
3993 %
3994 % \begin{macrocode}
3995 \tl_new:N \l_@@_doc_def_tl
3996 \tl_new:N \l_@@_doc_undef_tl
3997 \tl_new:N \l_@@_undoc_def_tl
3998 \tl_const:Nn \c_@@_iow_separator_tl { ---- }
3999 \tl_const:Nn \c_@@_iow_midrule_tl { -- }
4000 % \end{macrocode}
4001 %
4002 % \begin{macrocode}
4003 \cs_new_protected:Npn \@@_show_functions_defined:
4004 {
4005 \bool_lazy_and:nnT
4006 { \g_@@_typeset_implementation_bool } { \g_@@_checkfunc_bool }
4007 {
4008 \iow_term:e { \c_@@_iow_separator_tl \iow_newline: }
4009 \iow_open:Nn \g_@@_func_iow { \c_sys_jobname_str .cmds }
4010
4011 \tl_clear:N \l_@@_doc_def_tl
4012 \tl_clear:N \l_@@_doc_undef_tl
4013 \tl_clear:N \l_@@_undoc_def_tl
4014 \seq_gremove_duplicates:N \g_doc_functions_seq
4015 \seq_gremove_duplicates:N \g_doc_macros_seq
4016 \seq_map_inline:Nn \g_doc_functions_seq
4017 {
4018 \seq_if_in:NnTF \g_doc_macros_seq {##1}
4019 {
4020 \tl_put_right:Ne \l_@@_doc_def_tl
4021 { \iow_newline: > ~ ##1 }
4022 }
4023 {
4024 \tl_put_right:Ne \l_@@_doc_undef_tl
4025 { \iow_newline: ! ~ ##1 }
4026 }
4027 }
4028 \seq_map_inline:Nn \g_doc_macros_seq
4029 {
4030 \seq_if_in:NnF \g_doc_functions_seq {##1}
4031 {
4032 \tl_put_right:Ne \l_@@_undoc_def_tl
4033 { \iow_newline: ? ~ ##1 }
4034 }
4035 }
4036 \@@_functions_typeout:nN
4037 {
4038 Functions~both~documented~and~defined: \iow_newline:
4039 (In~order~of~being~documented)
4040 }
4041 \l_@@_doc_def_tl
4042 \@@_functions_typeout:nN
4043 { Functions~documented~but~not~defined: }
4044 \l_@@_doc_undef_tl
4045 \@@_functions_typeout:nN
4046 { Functions~defined~but~not~documented: }
4047 \l_@@_undoc_def_tl
4048
4049 \iow_close:N \g_@@_func_iow
4050 \iow_term:e { \c_@@_iow_separator_tl }
4051 }
4052 }
4053 \AtEndDocument { \@@_show_functions_defined: }
4054 % \end{macrocode}
4055 %
4056 % TODO: use \cs{iow_term:e}.
4057 % \begin{macrocode}
4058 \cs_new_protected:Npn \@@_functions_typeout:nN #1#2
4059 {
4060 \tl_if_empty:NF #2
4061 {
4062 \iow_now:Ne \g_@@_func_iow
4063 {
4064 \c_@@_iow_midrule_tl \iow_newline:
4065 #1 \iow_newline:
4066 \c_@@_iow_midrule_tl
4067 #2
4068 }
4069 \tl_clear:N #2
4070 }
4071 }
4072 % \end{macrocode}
4073 %
4074 % \begin{macrocode}
4075 \cs_new_protected:Npn \@@_show_not_tested:
4076 {
4077 \bool_if:NT \g_@@_checktest_bool
4078 {
4079 \tl_clear:N \l_@@_tmpa_tl
4080 \prop_if_empty:NF \g_@@_missing_tests_prop
4081 {
4082 \cs_set:Npn \@@_tmpa:w ##1##2
4083 {
4084 \iow_newline:
4085 \space\space\space\space \exp_not:n {##1}
4086 \clist_map_function:nN {##2} \@@_tmpb:w
4087 }
4088 \cs_set:Npn \@@_tmpb:w ##1
4089 {
4090 \iow_newline:
4091 \space\space\space\space\space\space * ~ ##1
4092 }
4093 \tl_put_right:Ne \l_@@_tmpa_tl
4094 {
4095 \iow_newline: \iow_newline:
4096 The~ following~ macro(s)~ have~ incomplete~ tests:
4097 \iow_newline:
4098 \prop_map_function:NN
4099 \g_@@_missing_tests_prop \@@_tmpa:w
4100 }
4101 }
4102 \seq_if_empty:NF \g_@@_not_tested_seq
4103 {
4104 \cs_set:Npn \@@_tmpa:w ##1
4105 { \clist_map_function:nN {##1} \@@_tmpb:w }
4106 \cs_set:Npn \@@_tmpb:w ##1
4107 {
4108 \iow_newline:
4109 \space\space\space\space ##1
4110 }
4111 \tl_put_right:Ne \l_@@_tmpa_tl
4112 {
4113 \iow_newline:
4114 \iow_newline:
4115 The~ following~ macro(s)~ do~ not~ have~ any~ tests:
4116 \iow_newline:
4117 \seq_map_function:NN
4118 \g_@@_not_tested_seq \@@_tmpa:w
4119 }
4120 }
4121 \tl_if_empty:NF \l_@@_tmpa_tl
4122 {
4123 \int_set:Nn \l_@@_tmpa_int { \tex_interactionmode:D }
4124 \errorstopmode
4125 \ClassError { l3doc } { \l_@@_tmpa_tl } { }
4126 \int_gset:Nn \tex_interactionmode:D { \l_@@_tmpa_int }
4127 }
4128 }
4129 }
4130 \AtEndDocument { \@@_show_not_tested: }
4131 % \end{macrocode}
4132 %
4133 % \subsection{Indexing}
4134 %
4135 % \subsubsection{Necessary patching}
4136 %
4137 % The following is useful to set up \pkg{hyperref} targets, for instance
4138 % for the purpose of indexing. Contrarily to \pkg{hypdoc} we do not try
4139 % to save pdf destinations, as this leads to too many \pdfTeX{} warnings
4140 % on early runs.
4141 % \begin{macrocode}
4142 \cs_new_protected:Npn \@@_target:
4143 {
4144 \mode_leave_vertical:
4145 \group_begin:
4146 \HD@savedestfalse \HD@target
4147 \group_end:
4148 }
4149 % \end{macrocode}
4150 % Force targets on every code line.
4151 % \begin{macrocode}
4152 \cs_set_nopar:Npe \theCodelineNo
4153 {
4154 \group_begin:
4155 \exp_not:N \HD@savedestfalse
4156 \exp_not:o \theCodelineNo
4157 \group_end:
4158 }
4159 % \end{macrocode}
4160 %
4161 % Inside the table of contents (and other similar lists introduced by
4162 % \cs{@starttoc}), we suppress indexing. This is because \cs{cmd},
4163 % \cs{cs}, or \cs{tn} appearing in titles only gets typeset in the
4164 % second run, and getting their indexing right would require even more
4165 % runs than we already need. Besides, it is not useful to index uses of
4166 % some command in the table of contents.
4167 % \begin{macrocode}
4168 \bool_new:N \l_@@_allow_indexing_bool
4169 \bool_set_true:N \l_@@_allow_indexing_bool
4170 \use:e
4171 {
4172 \exp_not:n { \cs_set_nopar:Npn \@starttoc #1 }
4173 {
4174 \group_begin:
4175 \bool_set_false:N \l_@@_allow_indexing_bool
4176 \exp_not:o { \@starttoc {#1} }
4177 \group_end:
4178 }
4179 }
4180 % \end{macrocode}
4181 %
4182 % \subsubsection{Userspace commands}
4183 %
4184 % Fix index (for now):
4185 % \begin{macrocode}
4186 \g@addto@macro \theindex { \MakePrivateLetters }
4187 \cs_gset:Npn \verbatimchar {&}
4188 % \end{macrocode}
4189 %
4190 % \begin{macrocode}
4191 \setcounter { IndexColumns } { 2 }
4192 % \end{macrocode}
4193 %
4194 % Set up the Index to use \tn{part}
4195 % \begin{macrocode}
4196 \IndexPrologue
4197 {
4198 \part*{Index}
4199 \markboth{Index}{Index}
4200 \addcontentsline{toc}{part}{Index}
4201 The~italic~numbers~denote~the~pages~where~the~
4202 corresponding~entry~is~described,~
4203 numbers~underlined~point~to~the~definition,~
4204 all~others~indicate~the~places~where~it~is~used.
4205 }
4206 % \end{macrocode}
4207 %
4208 % \begin{macro}{\SpecialIndex}
4209 % An attempt at affecting how commands which appear within the
4210 % \env{macrocode} environment are treated in the index.
4211 % \begin{macrocode}
4212 \cs_gset_protected:Npn \SpecialIndex #1
4213 {
4214 \@bsphack
4215 \@@_special_index:nn {#1} { }
4216 \@esphack
4217 }
4218 % \end{macrocode}
4219 % \end{macro}
4220 %
4221 % \begin{macrocode}
4222 \msg_new:nnn { l3doc } { print-index-howto }
4223 {
4224 Generate~the~index~by~executing\\
4225 \iow_indent:n
4226 { makeindex~-s~gind.ist~-o~\c_sys_jobname_str.ind~\c_sys_jobname_str.idx }
4227 }
4228 \tl_gput_right:Nn \PrintIndex
4229 { \AtEndDocument { \msg_info:nn { l3doc } { print-index-howto } } }
4230 % \end{macrocode}
4231 %
4232 % \subsubsection{Internal index commands}
4233 %
4234 % \begin{macro}{\it@is@a}
4235 % The index of one-character commands within the \env{macrocode}
4236 % environment is produced using \tn{it@is@a} \meta{char}. Alter that
4237 % command.
4238 % \begin{macrocode}
4239 \cs_gset_protected:Npn \it@is@a #1
4240 {
4241 \use:e
4242 {
4243 \@@_special_index_module:nnnnN
4244 {#1}
4245 { \bslash #1 }
4246 { }
4247 { }
4248 \c_false_bool
4249 }
4250 }
4251 % \end{macrocode}
4252 % \end{macro}
4253 %
4254 % \begin{macro}{\@@_special_index:nn}
4255 % ^^A TODO this override is somewhat a hack
4256 % \begin{macrocode}
4257 \cs_new_protected:Npn \@@_special_index:nn #1#2
4258 {
4259 \@@_key_get:n {#1}
4260 \quark_if_no_value:NF \l_@@_override_module_tl
4261 { \tl_set_eq:NN \l_@@_index_module_tl \l_@@_override_module_tl }
4262 \@@_special_index_module:ooonN
4263 { \l_@@_index_key_tl }
4264 { \l_@@_index_macro_tl }
4265 { \l_@@_index_module_tl }
4266 {#2}
4267 \l_@@_index_internal_bool
4268 }
4269 % \end{macrocode}
4270 % \end{macro}
4271 %
4272 % \begin{macro}
4273 % {
4274 % \@@_special_index_module:nnnnN,
4275 % \@@_special_index_module:ooonN,
4276 % \@@_special_index_aux:nnnnnn,
4277 % \@@_special_index_set:Nn,
4278 % }
4279 % Remotely based on Heiko's replacement to play nicely with
4280 % \pkg{hypdoc}. We use \tn{verb} or a \tn{verbatim@font} construction
4281 % depending on whether the number of tokens in |#2| is equal to its
4282 % number of characters: if it is not then that suggests that there is
4283 % a construct such as |\meta{...}|.
4284 % \begin{macrocode}
4285 \tl_new:N \l_@@_index_escaped_macro_tl
4286 \tl_new:N \l_@@_index_escaped_key_tl
4287 % \end{macrocode}
4288 %
4289 % \begin{macrocode}
4290 \cs_new_protected:Npn \@@_special_index_module:nnnnN #1#2#3#4#5
4291 % \end{macrocode}
4292 % \begin{arguments}
4293 % \item key
4294 % \item macro
4295 % \item module
4296 % \item index `type' (\texttt{main}/\texttt{usage}/etc.)
4297 % \item boolean whether internal command
4298 % \end{arguments}
4299 % \begin{macrocode}
4300 {
4301 \use:e
4302 {
4303 \exp_not:n { \@@_special_index_aux:nnnnnn {#1} {#2} }
4304 \tl_if_empty:nTF {#3}
4305 { { } { } { } }
4306 {
4307 \str_if_eq:nnTF {#3} { TeX }
4308 {
4309 { TeX~and~LaTeX2e }
4310 { \string\TeX{}~and~\string\LaTeXe{} }
4311 }
4312 {
4313 {#3}
4314 { \string\pkg{#3} }
4315 }
4316 { \bool_if:NT #5 { ~internal } ~commands: }
4317 }
4318 }
4319 {#4}
4320 }
4321 % \end{macrocode}
4322 %
4323 % \begin{macrocode}
4324 \cs_generate_variant:Nn \@@_special_index_module:nnnnN { ooo }
4325 % \end{macrocode}
4326 %
4327 % \begin{macrocode}
4328 \cs_new_protected:Npn \@@_special_index_aux:nnnnnn #1#2#3#4#5#6
4329 % \end{macrocode}
4330 % \begin{arguments}
4331 % \item key
4332 % \item macro
4333 % \item index subheading string
4334 % \item index subheading text
4335 % \item index subheading suffix (appended to both arg 3 and 4)
4336 % \item index `type' (\texttt{main}/\texttt{usage}/etc.)
4337 % \end{arguments}
4338 % \begin{macrocode}
4339 {
4340 \tl_set:Nn \l_@@_index_escaped_key_tl {#1}
4341 \@@_quote_special_char:N \l_@@_index_escaped_key_tl
4342 \@@_special_index_set:Nn \l_@@_index_escaped_macro_tl {#2}
4343 \str_if_eq:onTF { \@currenvir } { macrocode }
4344 { \@@_index_codeline_hc:nn }
4345 {
4346 \str_case:nnF {#6}
4347 {
4348 { main } { \@@_index_codeline_hc:nn }
4349 { usage } { \@@_index_page_hc:nn }
4350 }
4351 { \@@_target: \@@_index_page_hc:nn }
4352 }
4353 {
4354 \tl_if_empty:nF { #3 #4 #5 }
4355 { #3 #5 \actualchar #4 #5 \levelchar }
4356 \l_@@_index_escaped_key_tl
4357 \actualchar
4358 {
4359 \token_to_str:N \verbatim@font \c_space_tl
4360 \l_@@_index_escaped_macro_tl
4361 }
4362 }
4363 {#6}
4364 }
4365 % \end{macrocode}
4366 %
4367 % \begin{macro}{\hdpindex, \@@_old_hdpindex:nn, \hdclindex, \@@_old_hdclindex:nnn, \@@_hdindex:nn, \c_@@_active_minus_tl, \@@_hdindex_aux:nn, \@@_hdindex_aux:w}
4368 % Note that |#3| here could contain |MMMMI-| or |MMMMV-| more than once
4369 % if several successive code lines have been merged into a range
4370 % somehow. Note incidentally that the dash is active in some of our
4371 % sources, like |interface3.tex| or |source2e.tex|.
4372 % \begin{macrocode}
4373 \group_begin:
4374 \char_set_active_eq:NN - \scan_stop:
4375 \tl_const:Ne \c_@@_active_minus_tl { \char_generate:nn { `- } { 13 } }
4376 \group_end:
4377 \cs_new_eq:NN \@@_old_hdpindex:nn \hdpindex
4378 \cs_new_eq:NN \@@_old_hdclindex:nnn \hdclindex
4379 \cs_gset_protected:Npn \hdpindex #1
4380 { \@@_hdindex:nn { \@@_old_hdpindex:nn {#1} } }
4381 \cs_gset_protected:Npn \hdclindex #1#2
4382 { \@@_hdindex:nn { \@@_old_hdclindex:nnn {#1} {#2} } }
4383 \cs_new_protected:Npn \@@_hdindex:nn #1#2
4384 {
4385 \tl_set:Nn \l_@@_tmpa_tl {#2}
4386 \tl_replace_all:Nen \l_@@_tmpa_tl
4387 { \exp_not:V \c_@@_active_minus_tl \exp_not:V \c_@@_active_minus_tl }
4388 { -- }
4389 \seq_set_split:NnV \l_@@_tmpa_seq { -- } \l_@@_tmpa_tl
4390 \seq_set_map:NNn \l_@@_tmpa_seq \l_@@_tmpa_seq
4391 { \@@_hdindex_aux:nn {#1} {##1} }
4392 \seq_use:Nn \l_@@_tmpa_seq { -- }
4393 }
4394 \cs_new_protected:Npn \@@_hdindex_aux:nn #1#2
4395 {
4396 \tl_set:Nn \l_@@_tmpa_tl {#2}
4397 \tl_replace_all:Nnn \l_@@_tmpa_tl { MMMM } { \use_none:nn }
4398 \tl_if_in:NnT \l_@@_tmpa_tl { MMMD }
4399 {
4400 \tl_replace_all:Nen \l_@@_tmpa_tl
4401 { \exp_not:V \c_@@_active_minus_tl MMMD } { - MMMD }
4402 \tl_replace_all:Nnn \l_@@_tmpa_tl { - MMMD } { \@@_hdindex_aux:w }
4403 }
4404 \use:e { \exp_not:n {#1} { \exp_not:V \l_@@_tmpa_tl } }
4405 }
4406 \cs_new_protected:Npn \@@_hdindex_aux:w #1 M { }
4407 % \end{macrocode}
4408 % \end{macro}
4409 %
4410 % \begin{macrocode}
4411 \cs_new_protected:Npn \@@_special_index_set:Nn #1#2
4412 {
4413 \__kernel_tl_set:Nx #1 { \tl_to_str:n {#2} }
4414 \@@_if_almost_str:nTF {#2}
4415 {
4416 \tl_replace_all:Nen #1 { \tl_to_str:n { __ } }
4417 {
4418 \verbatimchar
4419 \token_to_str:N \_ \token_to_str:N \_
4420 \token_to_str:N \verb * \verbatimchar
4421 }
4422 \exp_args:Ne \tl_map_inline:nn
4423 { \tl_to_str:N \verbatimchar \token_to_str:N _ }
4424 {
4425 \tl_replace_all:Nnn #1 {##1}
4426 {
4427 \verbatimchar \c_backslash_str ##1
4428 \token_to_str:N \verb * \verbatimchar
4429 }
4430 }
4431 \__kernel_tl_set:Nx #1
4432 {
4433 \token_to_str:N \verb * \verbatimchar
4434 #1 \verbatimchar
4435 }
4436 }
4437 {
4438 \tl_set:Nn #1 {#2}
4439 \tl_replace_all:NVn #1
4440 \c_backslash_str
4441 { \token_to_str:N \bslash \c_space_tl }
4442 }
4443 \@@_quote_special_char:N #1
4444 }
4445 % \end{macrocode}
4446 % \end{macro}
4447 %
4448 % \begin{macro}{\@@_quote_special_char:N}
4449 % Quote some special characters.
4450 % \begin{macrocode}
4451 \cs_new_protected:Npn \@@_quote_special_char:N #1
4452 {
4453 \tl_map_inline:nn { \quotechar \actualchar \encapchar \levelchar \bslash }
4454 {
4455 \tl_replace_all:Nen #1
4456 { \tl_to_str:N ##1 } { \quotechar \tl_to_str:N ##1 }
4457 }
4458 }
4459 % \end{macrocode}
4460 % \end{macro}
4461 %
4462 % \subsubsection{Finding sort-key and module}
4463 %
4464 % \begin{macro}{\@@_key_get:n}
4465 % Sets \cs{l_@@_index_macro_tl}, \cs{l_@@_index_key_tl}, and
4466 % \cs{l_@@_index_module_tl} from |#1|. The base function is stored by
4467 % \cs{@@_key_get_base:nN} in \cs{l_@@_index_macro_tl}, falling back to
4468 % |#1| if it contains markup or has no signature.
4469 %
4470 % The starting point for the \meta{key} is \cs{l_@@_index_key_tl} as a
4471 % string. If it the first character is a backslash, remove
4472 % it. Then recognize |expl| functions and variables by the presence
4473 % of |:| or~|_| and \TeX{}/\LaTeXe{} commands by the presence of~|@|.
4474 % For |expl| names, we call \cs{@@_key_func:} or \cs{@@_key_var:},
4475 % which are responsible for removing some characters and finding the
4476 % module name, while for \TeX{}/\LaTeXe{} commands the module name is
4477 % |TeX|, and others have an empty module name.
4478 % \begin{macrocode}
4479 \cs_new_protected:Npe \@@_key_get:n #1
4480 {
4481 \exp_not:N \@@_key_get_base:nN {#1} \exp_not:N \l_@@_index_macro_tl
4482 \__kernel_tl_set:Nx \exp_not:N \l_@@_index_key_tl
4483 { \exp_not:N \tl_to_str:N \exp_not:N \l_@@_index_macro_tl }
4484 \tl_clear:N \exp_not:N \l_@@_index_module_tl
4485 \tl_if_in:NnTF \exp_not:N \l_@@_index_key_tl { \tl_to_str:n { __ } }
4486 { \bool_set_true:N \exp_not:N \l_@@_index_internal_bool }
4487 { \bool_set_false:N \exp_not:N \l_@@_index_internal_bool }
4488 \exp_not:N \tl_if_head_eq_charcode:VNT
4489 \exp_not:N \l_@@_index_key_tl \c_backslash_str
4490 { \exp_not:N \@@_key_pop: }
4491 \tl_if_in:NnTF \exp_not:N \l_@@_index_key_tl { \token_to_str:N : }
4492 { \exp_not:N \@@_key_func: }
4493 {
4494 \tl_if_in:NnTF \exp_not:N \l_@@_index_key_tl { \token_to_str:N _ }
4495 { \exp_not:N \@@_key_var: }
4496 {
4497 \tl_if_in:NnT \exp_not:N \l_@@_index_key_tl { \token_to_str:N @ }
4498 { \tl_set:Nn \exp_not:N \l_@@_index_module_tl { TeX } }
4499 }
4500 }
4501 }
4502 \cs_new_protected:Npn \@@_key_pop:
4503 {
4504 \__kernel_tl_set:Nx \l_@@_index_key_tl
4505 { \tl_tail:N \l_@@_index_key_tl }
4506 }
4507 % \end{macrocode}
4508 % \end{macro}
4509 %
4510 % \begin{macro}{\@@_key_trim_module:n, \@@_key_drop_underscores:}
4511 % Helper that removes from \cs{l_@@_index_module_tl} everything after
4512 % the first occurrence of |#1|. Helper that removes any leading
4513 % underscore from \cs{l_@@_index_key_tl}.
4514 % \begin{macrocode}
4515 \cs_new_protected:Npn \@@_key_trim_module:n #1
4516 {
4517 \cs_set:Npn \@@_tmpa:w ##1 #1 ##2 \q_stop
4518 { \exp_not:n {##1} }
4519 \__kernel_tl_set:Nx \l_@@_index_module_tl
4520 { \exp_after:wN \@@_tmpa:w \l_@@_index_module_tl #1 \q_stop }
4521 }
4522 \cs_new_protected:Npn \@@_key_drop_underscores:
4523 {
4524 \tl_if_head_eq_charcode:VNT \l_@@_index_key_tl _
4525 { \@@_key_pop: \@@_key_drop_underscores: }
4526 }
4527 % \end{macrocode}
4528 % \end{macro}
4529 %
4530 % \begin{macro}{\@@_key_func:}
4531 % The function \cs{@@_key_func:} is used if there is a colon, so
4532 % either for usual \pkg{expl3} functions or for keys from
4533 % \pkg{l3keys}. After removing from the key a leading dot (for the
4534 % latter case), and any leading underscore, the module name is the
4535 % part before any colon or underscore.
4536 % \begin{macrocode}
4537 \cs_new_protected:Npn \@@_key_func:
4538 {
4539 \tl_if_head_eq_charcode:VNT \l_@@_index_key_tl .
4540 { \@@_key_pop: }
4541 \@@_key_drop_underscores:
4542 \tl_set_eq:NN \l_@@_index_module_tl \l_@@_index_key_tl
4543 \exp_args:No \@@_key_trim_module:n { \token_to_str:N : }
4544 \exp_args:No \@@_key_trim_module:n { \token_to_str:N _ }
4545 }
4546 % \end{macrocode}
4547 % \end{macro}
4548 %
4549 % \begin{macro}{\@@_key_var:, \@@_key_get_module:}
4550 % The function \cs{@@_key_var:} covers cases with no~|:| but with~|_|,
4551 % typically variables but occasionally non-\pkg{expl3} functions such
4552 % as \Lua{} function with underscores. First test the second
4553 % character: if that is~|_| then assume we have a proper variable,
4554 % otherwise use the part before any underscore as the module name.
4555 % For variables, distinguish quarks and scan marks (starting with |q|
4556 % and~|s|), then drop the first letter (local/global/constant marker)
4557 % and underscores to improve the index sorting.
4558 % Then get the module as the first (underscore-delimited) \enquote{word}.
4559 % In the past, we distinguished according to how many such words there
4560 % were, to detect commands like \cs[no-index]{c_zero}, which should be
4561 % sorted as |int| variables, and \cs[no-index]{l_tmpa_dim}, which should
4562 % be sorted in the |dim| and not the |tmpa| module.
4563 % Now the first case has been deprecated for some time, while |tmpa| and
4564 % similar are special-cased through an explicit list given below.
4565 % The way it works is that if the module is in a list of special names
4566 % that are not valid modules, then we try the last word, and if that
4567 % also fails (for instance in the deprecated \cs[no-index]{c_one_hundred})
4568 % we empty the module completely.
4569 % \begin{macrocode}
4570 \cs_new_protected:Npn \@@_key_var:
4571 {
4572 \exp_args:Ne \tl_if_head_eq_charcode:nNTF
4573 { \exp_args:No \str_tail:n \l_@@_index_key_tl } _
4574 {
4575 \str_case:en { \str_head:N \l_@@_index_key_tl }
4576 {
4577 { q } { \tl_set:Nn \l_@@_index_module_tl { quark } }
4578 { s } { \tl_set:Nn \l_@@_index_module_tl { scan } }
4579 }
4580 \@@_key_pop:
4581 \@@_key_pop:
4582 \@@_key_drop_underscores:
4583 \tl_if_empty:NT \l_@@_index_module_tl
4584 {
4585 \seq_set_split:NoV \l_@@_tmpa_seq
4586 { \token_to_str:N _ } \l_@@_index_key_tl
4587 \seq_get_left:NN \l_@@_tmpa_seq \l_@@_index_module_tl
4588 \clist_if_in:NoT \g_@@_non_modules_clist \l_@@_index_module_tl
4589 {
4590 \seq_get_right:NN \l_@@_tmpa_seq \l_@@_index_module_tl
4591 \clist_if_in:NoT \g_@@_non_modules_clist \l_@@_index_module_tl
4592 {
4593 \tl_clear:N \l_@@_index_module_tl
4594 }
4595 }
4596 }
4597 }
4598 {
4599 \tl_set_eq:NN \l_@@_index_module_tl \l_@@_index_key_tl
4600 \exp_args:No \@@_key_trim_module:n { \token_to_str:N _ }
4601 }
4602 }
4603 % \end{macrocode}
4604 % \end{macro}
4605 %
4606 % \begin{variable}{\g_@@_non_modules_clist}
4607 % List of names that appear as the first word in an \pkg{expl3}
4608 % command, but that are not true modules, so that they should be
4609 % sorted differently in an index.
4610 % \begin{macrocode}
4611 \clist_new:N \g_@@_non_modules_clist
4612 \clist_gset:Ne \g_@@_non_modules_clist
4613 {
4614 \tl_to_str:n
4615 {
4616 alignment, ampersand, atsign, backslash, catcode, circumflex,
4617 code, colon, document, dollar, e, empty, false, hash, inf,
4618 initex, job, left, log, math, mark, max, minus, nan, nil, no,
4619 novalue, other, parameter, percent, pi, recursion, right, space,
4620 stop, term, tilde, tmpa, tmpb, true, underscore, zero, one, two,
4621 three, four, five, six, seven, eight, nine, ten, eleven, twelve,
4622 thirteen, fourteen, fifteen, sixteen, thirty, hundred
4623 }
4624 }
4625 % \end{macrocode}
4626 % \end{variable}
4627 %
4628 % \subsection{Change history}
4629 %
4630 % Set the change history to use \tn{part}.
4631 % Allow control names to be hyphenated in here\dots
4632 % \begin{macrocode}
4633 \GlossaryPrologue
4634 {
4635 \part*{Change~History}
4636 {\GlossaryParms\ttfamily\hyphenchar\font=`\-}
4637 \markboth{Change~History}{Change~History}
4638 \addcontentsline{toc}{part}{Change~History}
4639 }
4640 % \end{macrocode}
4641 %
4642 % \begin{macrocode}
4643 \msg_new:nnn { l3doc } { print-changes-howto }
4644 {
4645 Generate~the~change~list~by~executing\\
4646 \iow_indent:n
4647 { makeindex~-s~gglo.ist~-o~\c_sys_jobname_str.gls~\c_sys_jobname_str.glo }
4648 }
4649 \tl_gput_right:Nn \PrintChanges
4650 { \AtEndDocument { \msg_info:nn { l3doc } { print-changes-howto } } }
4651 % \end{macrocode}
4652 %
4653 %^^A The standard \changes command modified slightly to better cope with
4654 %^^A this multiple file document.
4655 %^^A\def\changes@#1#2#3{%
4656 %^^A \let\protect\@unexpandable@protect
4657 %^^A \edef\@tempa{\noexpand\glossary{#2\space\currentfile\space#1\levelchar
4658 %^^A \ifx\saved@macroname\@empty
4659 %^^A \space
4660 %^^A \actualchar
4661 %^^A \generalname
4662 %^^A \else
4663 %^^A \expandafter\@gobble
4664 %^^A \saved@macroname
4665 %^^A \actualchar
4666 %^^A \string\verb\quotechar*%
4667 %^^A \verbatimchar\saved@macroname
4668 %^^A \verbatimchar
4669 %^^A \fi
4670 %^^A :\levelchar #3}}%
4671 %^^A \@tempa\endgroup\@esphack}
4672 %
4673 % \subsection{Default configuration}
4674 %
4675 % \begin{macrocode}
4676 \bool_if:NTF \g_@@_typeset_implementation_bool
4677 {
4678 \RecordChanges
4679 \CodelineIndex
4680 \EnableCrossrefs
4681 \AlsoImplementation
4682 }
4683 {
4684 \CodelineNumbered
4685 \DisableCrossrefs
4686 \OnlyDescription
4687 }
4688 % \end{macrocode}
4689 %
4690 %
4691 % \begin{macrocode}
4692 %</class>
4693 % \end{macrocode}
4694 %
4695 % \subsection{Internal macros for \LaTeX3 sources}
4696 %
4697 % These definitions are only used by the \LaTeX3 documentation; they are
4698 % not necessary for third-party users of \cls{l3doc}. In time this will
4699 % be broken into a separate package that is specifically loaded in the
4700 % various \pkg{expl3} modules, etc.
4701 %
4702 % \begin{macrocode}
4703 %<*cfg>
4704 % \end{macrocode}
4705 %
4706 % The Guilty Parties.
4707 % \begin{macrocode}
4708 \tl_const:Nn \Team
4709 {
4710 The~\LaTeX{}~Project~team\thanks
4711 {\url{https://www.latex-project.org/latex3/}}
4712 }
4713 % \end{macrocode}
4714 %
4715 % \begin{macrocode}
4716 \NewDocumentCommand{\ExplMakeTitle}{mm}
4717 {
4718 \title
4719 {
4720 The~\pkg{#1}~package \\ #2
4721 }
4722 \author
4723 {
4724 The~\LaTeX~Project~team\thanks{E-mail:~
4725 \href{mailto:[email protected]}
4726 {[email protected]}}
4727 }
4728 \date{Released~\ExplFileDate}
4729 \maketitle
4730 }
4731 % \end{macrocode}
4732 %
4733 % \subsection{Math extras}
4734 %
4735 % For \pkg{l3fp}.
4736 %
4737 % \begin{macrocode}
4738 \AtBeginDocument
4739 {
4740 \clist_map_inline:nn
4741 {
4742 asin, acos, atan, acot,
4743 asinh, acosh, atanh, acoth, round, floor, ceil
4744 }
4745 { \exp_args:Nc \DeclareMathOperator{#1}{#1} }
4746 }
4747 % \end{macrocode}
4748 %
4749 % \begin{macro}{\nan}
4750 % \begin{macrocode}
4751 \NewDocumentCommand { \nan } { } { \text { \texttt { nan } } }
4752 % \end{macrocode}
4753 % \end{macro}
4754 %
4755 % \begin{macrocode}
4756 %</cfg>
4757 % \end{macrocode}
4758 %
4759 %
4760 % \subsection{Makeindex configuration}
4761 %
4762 % \begin{macrocode}
4763 %<*docist>
4764 % \end{macrocode}
4765 %
4766 % The makeindex style \file{l3doc.ist} is used in place of the usual
4767 % \file{gind.ist} to ensure that |I| is used in the sequence |I J K| not
4768 % |I II II|, which would be the default makeindex behavior.
4769 %
4770 % Will: Do we need this?
4771 %
4772 % Frank: at the moment we do not distribute or generate this file.
4773 % \file{gind.ist} is used instead.
4774 %
4775 % \begin{macro}[do-not-index={\\,\n}]{}
4776 % \begin{macrocode}
4777 actual '='
4778 quote '!'
4779 level '>'
4780 preamble
4781 "\n \\begin{theindex} \n \\makeatletter\\scan@allowedfalse\n"
4782 postamble
4783 "\n\n \\end{theindex}\n"
4784 item_x1 "\\efill \n \\subitem "
4785 item_x2 "\\efill \n \\subsubitem "
4786 delim_0 "\\pfill "
4787 delim_1 "\\pfill "
4788 delim_2 "\\pfill "
4789 % The next lines will produce some warnings when
4790 % running Makeindex as they try to cover two different
4791 % versions of the program:
4792 lethead_prefix "{\\bfseries\\hfil "
4793 lethead_suffix "\\hfil}\\nopagebreak\n"
4794 lethead_flag 1
4795 heading_prefix "{\\bfseries\\hfil "
4796 heading_suffix "\\hfil}\\nopagebreak\n"
4797 headings_flag 1
4798
4799 % and just for source3:
4800 % Remove R so I is treated in sequence I J K not I II III
4801 page_precedence "rnaA"
4802 % \end{macrocode}
4803 % \end{macro}
4804 %
4805 % \begin{macrocode}
4806 %</docist>
4807 % \end{macrocode}
4808 %
4809 % \end{implementation}
4810 %
4811 % \PrintIndex