[latex3-commits] [l3svn] r6658 - Refactoring l3doc: use same parsing code for macro/function environments
noreply at latex-project.org
noreply at latex-project.org
Mon Aug 15 02:33:20 CEST 2016
Author: bruno
Date: 2016-08-15 02:33:20 +0200 (Mon, 15 Aug 2016)
New Revision: 6658
Modified:
trunk/l3kernel/l3doc.dtx
Log:
Refactoring l3doc: use same parsing code for macro/function environments
Modified: trunk/l3kernel/l3doc.dtx
===================================================================
--- trunk/l3kernel/l3doc.dtx 2016-08-14 18:28:21 UTC (rev 6657)
+++ trunk/l3kernel/l3doc.dtx 2016-08-15 00:33:20 UTC (rev 6658)
@@ -308,6 +308,7 @@
% \end{itemize}
% \end{function}
%
+%
% \begin{function}{\tn}
% \begin{syntax}
% \cs{tn} \oarg{options} \marg{csname}
@@ -594,13 +595,13 @@
% \end{variable}
%
% \begin{variable}[int]
-% {\l_@@_names_coffin, \l_@@_descr_coffin, \l_@@_syntax_coffin}
+% {\l_@@_functions_coffin, \l_@@_descr_coffin, \l_@@_syntax_coffin}
% These coffins contain respectively the list of function names
% (argument of the \env{function} environment), the text between
% |\begin{function}| and |\end{function}|, and the syntax given in the
% \env{syntax} environment.
% \begin{macrocode}
-\coffin_new:N \l_@@_names_coffin
+\coffin_new:N \l_@@_functions_coffin
\coffin_new:N \l_@@_descr_coffin
\coffin_new:N \l_@@_syntax_coffin
% \end{macrocode}
@@ -616,7 +617,7 @@
%
% \begin{variable}[int]{\l_@@_long_name_bool, \l_@@_trial_width_dim}
% The boolean \cs{l_@@_long_name_bool} is \texttt{true} if the width
-% \cs{l_@@_trial_width_dim} of the coffin \cs{l_@@_names_coffin}
+% \cs{l_@@_trial_width_dim} of the coffin \cs{l_@@_functions_coffin}
% (containing the current function names) is bigger than the space
% available in the margin.
% \begin{macrocode}
@@ -697,31 +698,32 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{variable}[int]{\l_@@_functions_block_prop}
-% Contains information about the functions to typeset and their
-% variants.
+% \begin{variable}[int]{\l_@@_names_block_prop}
+% Property list used when analysing the argument of \env{function} and
+% \env{macro} environments. Keys are base functions (with |N|/|n|
+% signatures, or no signature) and the associated value is a comma
+% list of variants or \cs{scan_stop:} to denote the absence of
+% signature.
% \begin{macrocode}
-\prop_new:N \l_@@_functions_block_prop
+\prop_new:N \l_@@_names_block_prop
% \end{macrocode}
% \end{variable}
%
-% \begin{variable}[int]{\l_@@_verb_name_bool}
+% \begin{variable}[int]{\l_@@_names_verb_bool}
% Set to |true| if the main argument of a macro/function environment
% should be used as is, without removing any comma or space.
% \begin{macrocode}
-\bool_new:N \l_@@_verb_name_bool
+\bool_new:N \l_@@_names_verb_bool
% \end{macrocode}
% \end{variable}
%
-% \begin{variable}[int]{\l_@@_function_input_seq, \l_@@_macro_input_seq}
-% Both the \env{function} and the \env{macro} environments read their
-% argument verbatim, then remove percent signs (at the beginning of
-% lines), tabs and new lines, convert |_@@| and |@@| by
-% |__|\meta{module name} if appropriate, and interpret the result as a
-% comma list, which they store in these two sequences.
+% \begin{variable}[int]{\l_@@_names_seq}
+% List of functions/environments/\ldots{} appearing as arguments of a
+% given \env{function} or \env{macro} environment. These are the
+% names after conversion of |_@@| and |@@| to |__|\meta{module name}
+% and other sanitizing.
% \begin{macrocode}
-\seq_new:N \l_@@_function_input_seq
-\seq_new:N \l_@@_macro_input_seq
+\seq_new:N \l_@@_names_seq
% \end{macrocode}
% \end{variable}
%
@@ -773,8 +775,8 @@
% indexing commands, and the number of macros so far (including those
% from surrounding \env{macro} environments).
% \begin{macrocode}
+\box_new:N \l_@@_macro_box
\box_new:N \l_@@_macro_index_box
-\box_new:N \l_@@_macro_box
\int_new:N \l_@@_macro_int
% \end{macrocode}
% \end{variable}
@@ -928,40 +930,6 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[aux]{\@@_verb_get_seq:nN}
-% The argument~|#1| (argument of a |function| or |macro| environment)
-% has catcodes $10$ (space), $12$ (other) and $13$ (active). Sanitize
-% catcodes. If the |verb| option was used, output a one-item
-% sequence. Otherwise, remove any \enquote{\%} character at the
-% beginning of a line. Remove tabs and newlines. Finally, convert
-% |_@@| and |@@| to |__|\meta{module name} (if it is non-empty). At
-% this point, \cs{l_@@_tmpa_tl} contains a comma-delimited list of
-% names, where |@| and~|_| have category code letter. Turn it to a
-% string, parse it as a comma-delimited list (in particular this
-% removes spaces), and output a sequence of function/macro names.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_verb_get_seq:nN #1#2
- {
- \tl_set:Nx \l_@@_tmpa_tl { \tl_to_str:n {#1} }
- \bool_if:NTF \l_@@_verb_name_bool
- {
- \seq_clear:N #2
- \seq_put_right:NV #2 \l_@@_tmpa_tl
- }
- {
- \tl_remove_all:Nx \l_@@_tmpa_tl
- { \iow_char:N \^^M \iow_char:N \% }
- \tl_remove_all:Nx \l_@@_tmpa_tl { \tl_to_str:n { ^ ^ A } }
- \tl_remove_all:Nx \l_@@_tmpa_tl { \iow_char:N \^^I }
- \tl_remove_all:Nx \l_@@_tmpa_tl { \iow_char:N \^^M }
- \@@_replace_at_at:N \l_@@_tmpa_tl
- \exp_args:NNx \seq_set_from_clist:Nn #2
- { \tl_to_str:N \l_@@_tmpa_tl }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
% \begin{macro}[aux,rEXP]
% {\@@_signature_base_form:n, \@@_signature_base_form_aux:n}
% Expands to the \enquote{base form} of the signature. For instance,
@@ -1035,6 +1003,7 @@
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \begin{macro}[aux]
% {
@@ -1694,6 +1663,181 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[aux]{\@@_names_get_seq:nN}
+% The argument~|#1| (argument of a |function| or |macro| environment)
+% has catcodes $10$ (space), $12$ (other) and $13$ (active). Sanitize
+% catcodes. If the |verb| option was used, output a one-item
+% sequence. Otherwise, remove any \enquote{\%} character at the
+% beginning of a line. Remove tabs and newlines. Finally, convert
+% |_@@| and |@@| to |__|\meta{module name} (if it is non-empty). At
+% this point, \cs{l_@@_tmpa_tl} contains a comma-delimited list of
+% names, where |@| and~|_| have category code letter. Turn it to a
+% string, parse it as a comma-delimited list (in particular this
+% removes spaces), and output a sequence of function/macro names.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_names_get_seq:nN #1#2
+ {
+ \tl_set:Nx \l_@@_tmpa_tl { \tl_to_str:n {#1} }
+ \bool_if:NTF \l_@@_names_verb_bool
+ {
+ \seq_clear:N #2
+ \seq_put_right:NV #2 \l_@@_tmpa_tl
+ }
+ {
+ \tl_remove_all:Nx \l_@@_tmpa_tl
+ { \iow_char:N \^^M \iow_char:N \% }
+ \tl_remove_all:Nx \l_@@_tmpa_tl { \tl_to_str:n { ^ ^ A } }
+ \tl_remove_all:Nx \l_@@_tmpa_tl { \iow_char:N \^^I }
+ \tl_remove_all:Nx \l_@@_tmpa_tl { \iow_char:N \^^M }
+ \@@_replace_at_at:N \l_@@_tmpa_tl
+ \exp_args:NNx \seq_set_from_clist:Nn #2
+ { \tl_to_str:N \l_@@_tmpa_tl }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[aux]
+% {
+% \@@_names_parse:,
+% \@@_names_parse_one:n,
+% \@@_names_parse_cs_aux:nnN
+% }
+% The idea here is to populate \cs{l_@@_names_block_prop} with
+% information about the functions being typeset and their variants.
+% The property list uses a specific format: the keys contained are the
+% \enquote{base function} (obtained by changing letters to |N| or |n|
+% as appropriate in the signature) with values specified by a
+% comma-separated list of (braced) signatures, such as:
+% \begin{center}
+% |> {\my_function:nn} => { { nn } , { VV } , ... }|
+% |> {\my_function:Nn} => { { cn } , { No } , ... }|
+% |> {\function} => { \scan_stop: }|
+% |> {.bool_set:N} => { { N } , { c } }|
+% \end{center}
+% In the case where the function has no signature (no colon), we use a
+% value of \cs{scan_stop:} (there can be no variant). This somewhat
+% arcane syntax is chosen to display together functions that are
+% variants of each other, but not pairs like |\clist_count:N| and
+% |\clist_count:n| which should be indexed separately for instance.
+% Non-\pkg{expl3}-syntax control sequences simply end up having value
+% \cs{scan_stop:}.
+%
+% We filter out the special case of |#1| containing |\::|, which
+% signals that we have one of the weird functions named |\::N| and so
+% on. Otherwise, split the function into its base name (including the
+% potential backslash) and signature. If there was a |:| then store
+% the signature (braced), otherwise store \cs{scan_stop:}.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_names_parse:
+ {
+ \prop_clear:N \l_@@_names_block_prop
+ \seq_map_function:NN
+ \l_@@_names_seq
+ \@@_names_parse_one:n
+ }
+\cs_new_protected:Npn \@@_names_parse_one:n #1
+ {
+ \tl_if_in:noTF {#1} { \token_to_str:N \:: }
+ { \prop_put:Nnn \l_@@_names_block_prop {#1} { \scan_stop: } }
+ { \@@_split_function_do:nn {#1} \@@_names_parse_cs_aux:nnN }
+ }
+\cs_new_protected:Npn \@@_names_parse_cs_aux:nnN #1#2#3
+ {
+ \bool_if:NTF #3
+ {
+ \@@_clist_prop_put_right:Nxn \l_@@_names_block_prop
+ { #1 : \@@_signature_base_form:n {#2} } { {#2} }
+ }
+ { \prop_put:Nnn \l_@@_names_block_prop {#1} { \scan_stop: } }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[aux]{\@@_names_typeset:}
+% \begin{macro}[aux]{\@@_names_typeset_auxi:nn}
+% \begin{arguments}
+% \item Function/macro/variable name (stripped of signature in the
+% first case, if any)
+% \item Comma-list containing information about the signature
+% variants being documented (if any)
+% \end{arguments}
+% The mapping to \cs{l_@@_names_block_prop} cannot use
+% \cs{prop_map_inline:Nn} because the code following |\\| would not be
+% expandable, thus breaking \tn{bottomrule}. Call
+% \cs{@@_names_typeset_auxi:nn} for each base form and set of
+% variants. The first step is to drop the signature of the base form
+% (it was only used to sort functions by their base form in
+% \cs{l_@@_names_block_prop}) and change spaces to category other so
+% that they get displayed eventually. Then store the variants in
+% \cs{g_@@_variants_clist}, remove the first, which will be displayed
+% more prominently, and reconstruct the actual name, passing it to
+% \cs{@@_names_typeset_auxii:n}.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_names_typeset:
+ {
+ \prop_map_function:NN \l_@@_names_block_prop
+ \@@_names_typeset_auxi:nn
+ }
+\cs_new_protected:Npn \@@_names_typeset_auxi:nn #1#2
+ {
+ \tl_gset:Nx \g_@@_base_name_tl
+ { \@@_get_function_name:n {#1} }
+ \tl_greplace_all:Nno \g_@@_base_name_tl
+ { ~ } { \c_catcode_other_space_tl }
+ \tl_if_eq:nnTF {#2} { \scan_stop: }
+ {
+ \bool_if:NTF \l_@@_macro_TF_bool
+ { \msg_error:nnn { l3doc } { no-signature-TF } {#1} }
+ {
+ \clist_gclear:N \g_@@_variants_clist
+ \@@_names_typeset_auxii:x { \g_@@_base_name_tl }
+ }
+ }
+ {
+ \clist_gset:Nn \g_@@_variants_clist {#2}
+ \clist_gpop:NN \g_@@_variants_clist \l_@@_tmpb_tl
+ \@@_names_typeset_auxii:x
+ { \g_@@_base_name_tl : \l_@@_tmpb_tl }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% ^^A TODO: error message; error recovery
+%
+% \begin{macro}[aux]
+% {\@@_names_typeset_auxii:n, \@@_names_typeset_auxii:x}
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_names_typeset_auxii:n #1
+ {
+ \bool_if:NT \l_@@_macro_pTF_bool
+ {
+ \bool_set_false:N \l_@@_macro_TF_bool
+ \@@_names_typeset_block:x
+ { \@@_predicate_from_base:n {#1} }
+ \bool_set_true:N \l_@@_macro_TF_bool
+ }
+ \@@_names_typeset_block:n {#1}
+ }
+\cs_generate_variant:Nn \@@_names_typeset_auxii:n { x }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[aux]{\@@_names_typeset_block:n, \@@_names_typeset_block:x}
+% Names in \env{function} and \env{macro} environments are typeset
+% differently. A block is a function with all its variants.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_names_typeset_block:n
+ {
+ \int_compare:nNnTF \l_@@_nested_macro_int = 0
+ { \@@_typeset_function_block:n }
+ { \@@_macro_typeset_block:n }
+ }
+\cs_generate_variant:Nn \@@_names_typeset_block:n { x }
+% \end{macrocode}
+% \end{macro}
+%
% \subsubsection{The \env{function} environment}
%
% \begin{macrocode}
@@ -1724,7 +1868,7 @@
updated .tl_set:N = \l_@@_date_updated_tl ,
tested .code:n = { } ,
no-label .bool_set:N = \l_@@_no_label_bool ,
- verb .bool_set:N = \l_@@_verb_name_bool ,
+ verb .bool_set:N = \l_@@_names_verb_bool ,
}
% \end{macrocode}
%
@@ -1741,7 +1885,7 @@
% Initialize some variables. Parse the key--value list. Clean up the
% list of functions, then go through them to extract some data. After
% this, typeset the function names in the coffin
-% \cs{l_@@_names_coffin} and measure it to know if it fits in the
+% \cs{l_@@_functions_coffin} and measure it to know if it fits in the
% margin. Finally, start a vertical coffin for the main part of the
% environment. This coffin stops when the environment ends, then all
% the pieces are assembled into a single coffin, which is typeset.
@@ -1751,8 +1895,8 @@
\@@_function_typeset_start:
\@@_function_init:
\keys_set:nn { l3doc/function } {#1}
- \@@_verb_get_seq:nN {#2} \l_@@_function_input_seq
- \@@_function_parse:
+ \@@_names_get_seq:nN {#2} \l_@@_names_seq
+ \@@_names_parse:
\@@_function_typeset:
\@@_function_descr_start:w
}
@@ -1797,13 +1941,13 @@
\coffin_clear:N \l_@@_descr_coffin
\box_gclear:N \g_@@_syntax_box
\coffin_clear:N \l_@@_syntax_coffin
- \coffin_clear:N \l_@@_names_coffin
+ \coffin_clear:N \l_@@_functions_coffin
\bool_set_false:N \l_@@_macro_TF_bool
\bool_set_false:N \l_@@_macro_pTF_bool
\bool_set_false:N \l_@@_macro_EXP_bool
\bool_set_false:N \l_@@_macro_rEXP_bool
\bool_set_false:N \l_@@_no_label_bool
- \bool_set_false:N \l_@@_verb_name_bool
+ \bool_set_false:N \l_@@_names_verb_bool
\char_set_catcode_active:N \<
\cs_set_protected:Npn < ##1 > { \meta {##1} }
}
@@ -1811,65 +1955,19 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux]
-% {
-% \@@_function_parse:,
-% \@@_function_parse_one:n,
-% \@@_function_parse_cs_aux:nnN
-% }
-% The idea here is to populate \cs{l_@@_functions_block_prop} with
-% information about the functions being typeset and their variants.
-% The property list uses a specific format: the keys contained are the
-% function \enquote{names} (stripped of signature) with values
-% specified by a comma-separated list of (braced) signatures:
-% \begin{center}
-% |> {my_function} => {| \meta{sig_1} |,| \meta{sig_2} |, ... }|
-% \end{center}
-% In the case where the function has no signature (no colon), we use
-% a \meta{sig} equal to \cs{scan_stop:}.
-% This somewhat arcane syntax is chosen to distinguish between all
-% variants of control sequence that may be being documented
-% here. (With or without \pkg{expl3} function syntax.)
-%
-% We filter out the special case of |#1| containing |\::|, which
-% signals that we have one of the weird functions named |\::N| and so
-% on. Otherwise, split the function into base name (including the
-% potential backslash) and signature. If there was a |:| then store
-% the signature (braced), otherwise store \cs{scan_stop:}.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_function_parse:
- {
- \seq_map_function:NN
- \l_@@_function_input_seq
- \@@_function_parse_one:n
- }
-\cs_new_protected:Npn \@@_function_parse_one:n #1
- {
- \tl_if_in:noTF {#1} { \token_to_str:N \:: }
- { \prop_put:Nnn \l_@@_functions_block_prop {#1} { \scan_stop: } }
- { \@@_split_function_do:nn {#1} \@@_function_parse_cs_aux:nnN }
- }
-\cs_new_protected:Npn \@@_function_parse_cs_aux:nnN #1#2#3
- {
- \@@_clist_prop_put_right:Nnf \l_@@_functions_block_prop {#1}
- { \bool_if:NTF #3 { {#2} } { \scan_stop: } }
- }
-% \end{macrocode}
-% \end{macro}
-%
% \begin{macro}[aux]{\@@_function_typeset:}
-% Typeset in the coffin \cs{l_@@_names_coffin} the functions listed in
-% \cs{l_@@_functions_block_prop} and the relevant dates, then set
+% Typeset in the coffin \cs{l_@@_functions_coffin} the functions listed in
+% \cs{l_@@_names_block_prop} and the relevant dates, then set
% \cs{l_@@_long_name_bool} to be \texttt{true} if this coffin is
% larger than the available width in the margin. The function
-% \cs{@@_typeset_names:} is quite involved hence given later.
+% \cs{@@_typeset_functions:} is quite involved hence given later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_function_typeset:
{
\dim_zero:N \l_@@_trial_width_dim
- \hcoffin_set:Nn \l_@@_names_coffin { \@@_typeset_names: }
+ \hcoffin_set:Nn \l_@@_functions_coffin { \@@_typeset_functions: }
\dim_set:Nn \l_@@_trial_width_dim
- { \box_wd:N \l_@@_names_coffin }
+ { \box_wd:N \l_@@_functions_coffin }
\bool_set:Nn \l_@@_long_name_bool
{ \dim_compare_p:nNn \l_@@_trial_width_dim > \marginparwidth }
}
@@ -1913,7 +2011,7 @@
{0pt} {0pt}
\coffin_join:NnnNnnnn
\l_@@_output_coffin {l} {t}
- \l_@@_names_coffin {r} {t}
+ \l_@@_functions_coffin {r} {t}
{-\marginparsep} {0pt}
\coffin_join:NnnNnnnn
\l_@@_output_coffin {l} {b}
@@ -1934,7 +2032,7 @@
{0pt} {-\medskipamount}
\coffin_join:NnnNnnnn
\l_@@_output_coffin {l} {t}
- \l_@@_names_coffin {r} {t}
+ \l_@@_functions_coffin {r} {t}
{-\marginparsep} {0pt}
\coffin_typeset:Nnnnn \l_@@_output_coffin
{\l_@@_syntax_coffin-l} {\l_@@_syntax_coffin-T}
@@ -1944,20 +2042,20 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux]{\@@_typeset_names:}
-% This function builds the \cs{l_@@_names_coffin} by typesetting the
+% \begin{macro}[aux]{\@@_typeset_functions:}
+% This function builds the \cs{l_@@_functions_coffin} by typesetting the
% function names (with variants) and the relevant dates in a
% \env{tabular} environment. The use of rules \tn{toprule},
% \tn{midrule} and \tn{bottomrule} requires whatever lies between the
% last |\\| and the rule to be expandable, making our lives a bit
% complicated.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_typeset_names:
+\cs_new_protected:Npn \@@_typeset_functions:
{
\small\ttfamily
\begin{tabular} { @{} l @{} r @{} }
\toprule
- \@@_typeset_functions:
+ \@@_names_typeset:
\@@_typeset_dates:
\bottomrule
\end{tabular}
@@ -1966,87 +2064,25 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux]{\@@_typeset_functions:}
-% \begin{macro}[aux]
-% {\@@_typeset_functions_auxi:nn, \@@_typeset_functions_auxii:nn}
-% \begin{arguments}
-% \item Function/macro/variable name (stripped of signature in the
-% first case, if any)
-% \item Comma-list containing information about the signature
-% variants being documented (if any)
-% \end{arguments}
-% The mapping to \cs{l_@@_functions_block_prop} cannot use
-% \cs{prop_map_inline:Nn} because the code following |\\| would not be
-% expandable, thus breaking \tn{bottomrule}. The loop goes as
-% follows: go through the list of variants |#2|, and collect them by
-% \enquote{base form} in a \cs{l_@@_variants_prop} whose keys are the
-% base form and whose values are the variants which can be obtained
-% from that base form using \cs{cs_generate_variant:Nn}. Then start a
-% nested loop through these base forms, calling
-% \cs{@@_typeset_functions_auxii:nn}. This auxiliary does not care
-% about the base form. It stores the variants it receives in
-% \cs{g_@@_variants_clist}, remove the first, which will be displayed
-% more prominently, and reconstructs its actual name, passing it to
-% the \cs{@@_typeset_functions_auxiii:n} auxiliary.
-%
-% Braces around |##1| are crucial since this item can be empty.
-%
-% In the base name, spaces are replaced by other spaces to ensure they
-% get displayed in case there are any.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_typeset_functions:
- {
- \prop_map_function:NN \l_@@_functions_block_prop
- \@@_typeset_functions_auxi:nn
- }
-\cs_new_protected:Npn \@@_typeset_functions_auxi:nn #1#2
- {
- \tl_gset:Nn \g_@@_base_name_tl {#1}
- \tl_greplace_all:Nno \g_@@_base_name_tl
- { ~ } { \c_catcode_other_space_tl }
- \prop_clear:N \l_@@_variants_prop
- \clist_map_inline:nn {#2}
- {
- \@@_clist_prop_put_right:Nxn
- \l_@@_variants_prop
- { \@@_signature_base_form:n {##1} }
- { {##1} }
- }
- \prop_map_function:NN \l_@@_variants_prop
- \@@_typeset_functions_auxii:nn
- }
-\cs_new_protected:Npn \@@_typeset_functions_auxii:nn #1#2
- {
- \clist_gset:Nn \g_@@_variants_clist {#2}
- \clist_gpop:NN \g_@@_variants_clist \l_@@_tmpb_tl
- \exp_args:Nx \@@_typeset_functions_auxiii:n
- {
- \g_@@_base_name_tl
- \tl_if_head_eq_meaning:VNF \l_@@_tmpb_tl \scan_stop:
- { : \l_@@_tmpb_tl }
- }
- }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}[aux]{\@@_typeset_functions_auxiii:n}
+% ^^A TODO: collect all index targets from a given function environment in a box and stick it at the top.
+% \begin{macro}[int]
+% {\@@_typeset_function_block:n, \@@_typeset_function_block:x}
% \begin{macro}[aux]{\@@_function_index:n, \@@_function_index:x}
+% The argument is a csname.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_typeset_functions_auxiii:n #1
+\cs_new_protected:Npn \@@_typeset_function_block:n #1
{
- \bool_if:NT \l_@@_macro_pTF_bool
- {
- \tl_set:Nx \l_@@_pTF_name_tl
- { \@@_predicate_from_base:n {#1} }
- \@@_function_index:x { \l_@@_pTF_name_tl }
- }
\@@_function_index:x
{ #1 \bool_if:NT \l_@@_macro_TF_bool { \tl_to_str:n {TF} } }
- \bool_if:NT \l_@@_macro_pTF_bool
- { \@@_typeset_function_block:VN \l_@@_pTF_name_tl \c_false_bool }
- \@@_typeset_function_block:nN {#1} \l_@@_macro_TF_bool
+ \@@_function_label:x {#1}
+ #1
+ \bool_if:NT \l_@@_macro_TF_bool { \@@_typeset_TF: }
+ \@@_typeset_expandability:
+ \clist_if_empty:NF \g_@@_variants_clist
+ { \@@_typeset_variant_list:n {#1} }
+ \\
}
+\cs_generate_variant:Nn \@@_typeset_function_block:n { x }
\cs_new_protected:Npn \@@_function_index:n #1
{
\seq_gput_right:Nn \g_doc_functions_seq {#1}
@@ -2054,28 +2090,8 @@
}
\cs_generate_variant:Nn \@@_function_index:n { x }
% \end{macrocode}
-% \end{macro}
-% \end{macro}
%
-% \begin{macro}[int]
-% {\@@_typeset_function_block:nN, \@@_typeset_function_block:VN}
-% The first argument is a csname, the second a boolean which
-% controls whether to typeset |TF| or not.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_typeset_function_block:nN #1#2
- {
- \@@_function_label:x {#1}
- #1
- \bool_if:NT #2 { \@@_typeset_TF: }
- \@@_typeset_expandability:
- \clist_if_empty:NF \g_@@_variants_clist
- { \@@_typeset_variant_list:nN {#1} #2 }
- \\
- }
-\cs_generate_variant:Nn \@@_typeset_function_block:nN { V }
-% \end{macrocode}
-%
-% \begin{macrocode}
\cs_new_protected:Npn \@@_typeset_expandability:
{
&
@@ -2093,7 +2109,7 @@
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_typeset_variant_list:nN #1#2
+\cs_new_protected:Npn \@@_typeset_variant_list:n #1
{
\\
\@@_typeset_aux:n { \@@_get_function_name:n {#1} }
@@ -2105,7 +2121,7 @@
\clist_use:Nn \g_@@_variants_clist { \textrm| }
\textrm)
}
- \bool_if:NT #2 { \@@_typeset_TF: }
+ \bool_if:NT \l_@@_macro_TF_bool { \@@_typeset_TF: }
\@@_typeset_expandability:
}
% \end{macrocode}
@@ -2122,6 +2138,7 @@
\cs_generate_variant:Nn \@@_function_label:n { x }
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \begin{macro}[internal]{\@@_typeset_dates:}
% To display metadata for when functions are added/modified.
@@ -2224,7 +2241,7 @@
} ,
added .code:n = {} , % TODO
updated .code:n = {} , % TODO
- verb .bool_set:N = \l_@@_verb_name_bool ,
+ verb .bool_set:N = \l_@@_names_verb_bool ,
}
% \end{macrocode}
%
@@ -2241,9 +2258,10 @@
{
\@@_macro_init:
\keys_set:nn { l3doc/macro } {#1}
- \@@_verb_get_seq:nN {#2} \l_@@_macro_input_seq
- \@@_macro_map:N \@@_macro_single:n
- \@@_macro_typeset:
+ \@@_names_get_seq:nN {#2} \l_@@_names_seq
+ \@@_names_parse:
+ \@@_names_typeset:
+ \@@_macro_dump:
}
% \end{macrocode}
% \end{macro}
@@ -2264,7 +2282,7 @@
\bool_set_false:N \l_@@_macro_rEXP_bool
\bool_set_false:N \l_@@_macro_var_bool
\bool_set_false:N \l_@@_macro_tested_bool
- \bool_set_false:N \l_@@_verb_name_bool
+ \bool_set_false:N \l_@@_names_verb_bool
\cs_set_eq:NN \testfile \@@_print_testfile:n
\box_clear:N \l_@@_macro_index_box
\vbox_set:Nn \l_@@_macro_box
@@ -2276,29 +2294,10 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[aux]{\@@_macro_map:N}
-% Applies |#1| to all macros. In the |pTF| case, this means going
-% twice through the sequence \cs{l_@@_macro_input_seq}, once for the
-% predicates and once for the |TF| variants.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_macro_map:N #1
- {
- \bool_if:NT \l_@@_macro_pTF_bool
- {
- \bool_set_false:N \l_@@_macro_TF_bool
- \seq_map_inline:Nn \l_@@_macro_input_seq
- { \exp_args:Nx #1 { \@@_predicate_from_base:n {##1} } }
- \bool_set_true:N \l_@@_macro_TF_bool
- }
- \seq_map_function:NN \l_@@_macro_input_seq #1
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}[aux]{\@@_macro_typeset:}
+% \begin{macro}[aux]{\@@_macro_dump:}
% This calls |\makelabel{}|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_macro_typeset:
+\cs_new_protected:Npn \@@_macro_dump:
{
\topsep\MacroTopsep
\trivlist
@@ -2319,6 +2318,28 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[aux]{\@@_macro_typeset_block:n}
+% Used to typeset a macro and its variants.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_macro_typeset_block:n #1
+ {
+ \@@_macro_single:n {#1}
+ \clist_if_empty:NF \g_@@_variants_clist
+ {
+ \@@_macro_typeset_variant_list:x
+ { \@@_get_function_name:n {#1} }
+ }
+ }
+\cs_generate_variant:Nn \@@_macro_typeset_block:n { x }
+\cs_new_protected:Npn \@@_macro_typeset_variant_list:n #1
+ {
+ \clist_map_inline:Nn \g_@@_variants_clist
+ { \@@_macro_single:n { #1 : ##1 } }
+ }
+\cs_generate_variant:Nn \@@_macro_typeset_variant_list:n { x }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\@@_macro_single:n}
% Let's start to mess around with \cls{doc}'s \env{macro} environment.
% See \file{doc.dtx} for a full explanation of the original
@@ -2490,7 +2511,7 @@
{
\@@_clist_prop_put_right:Nxn
\g_@@_missing_tests_prop
- { \seq_use:Nn \l_@@_macro_input_seq { , } }
+ { \seq_use:Nn \l_@@_names_seq { , } }
{ { \g_file_current_name_tl \iow_char:N \ (#1) } }
}
% \end{macrocode}
@@ -2537,7 +2558,7 @@
{
\seq_gput_right:Nx \g_@@_not_tested_seq
{
- \seq_use:Nn \l_@@_macro_input_seq { , }
+ \seq_use:Nn \l_@@_names_seq { , }
\bool_if:NTF \l_@@_macro_pTF_bool {~(pTF)}
{ \bool_if:NT \l_@@_macro_TF_bool {~(TF)} }
}
@@ -2588,15 +2609,15 @@
\cs_new_protected:Npn \@@_print_end_definition:
{
\group_begin:
- \@@_macro_end_wrap_items:N \l_@@_macro_input_seq
+ \@@_macro_end_wrap_items:N \l_@@_names_seq
End~ definition~ for~
- \int_compare:nTF { \seq_count:N \l_@@_macro_input_seq <= 3 }
+ \int_compare:nTF { \seq_count:N \l_@@_names_seq <= 3 }
{
- \seq_use:Nnnn \l_@@_macro_input_seq
+ \seq_use:Nnnn \l_@@_names_seq
{ \,~and~ } { \,,~ } { \,,~and~ }
\@.
}
- { \seq_item:Nn \l_@@_macro_input_seq {1}\,~and~others. }
+ { \seq_item:Nn \l_@@_names_seq {1}\,~and~others. }
\group_end:
}
\cs_new_protected:Npn \@@_print_documented:
@@ -2608,13 +2629,13 @@
}
{
\int_set:Nn \l_@@_tmpa_int
- { \seq_count:N \l_@@_macro_input_seq }
+ { \seq_count:N \l_@@_names_seq }
\int_compare:nNnTF \l_@@_tmpa_int = 1 {~This~} {~These~}
\bool_if:NTF \l_@@_macro_var_bool {variable} {function}
\int_compare:nNnTF \l_@@_tmpa_int = 1 {~is~} {s~are~}
documented~on~page~
\exp_args:Nx \@@_get_hyper_target:nN
- { \seq_item:Nn \l_@@_macro_input_seq { 1 } }
+ { \seq_item:Nn \l_@@_names_seq { 1 } }
\l_@@_tmpa_tl
\exp_args:Nx \pageref { \l_@@_tmpa_tl } .
}
More information about the latex3-commits
mailing list