[latex3-commits] [l3svn] r6677 - l3doc: add keys "documented-as" (macro) and "label" (function)

noreply at latex-project.org noreply at latex-project.org
Thu Aug 18 22:30:17 CEST 2016


Author: bruno
Date: 2016-08-18 22:30:17 +0200 (Thu, 18 Aug 2016)
New Revision: 6677

Modified:
   trunk/l3kernel/l3doc.dtx
Log:
l3doc: add keys "documented-as" (macro) and "label" (function)

See next commit for uses.  The documented-as key of the macro
environment is meant for cases which define variants rather
than the original function: this messes up the link to the
documentation.  The label key is used to avoid duplicates
labels when a function is documented multiple times (as done
in l3expan).



Modified: trunk/l3kernel/l3doc.dtx
===================================================================
--- trunk/l3kernel/l3doc.dtx	2016-08-18 18:31:23 UTC (rev 6676)
+++ trunk/l3kernel/l3doc.dtx	2016-08-18 20:30:17 UTC (rev 6677)
@@ -665,6 +665,7 @@
 %     \l_@@_macro_rEXP_bool,
 %     \l_@@_macro_var_bool,
 %     \l_@@_override_module_tl,
+%     \l_@@_macro_documented_clist,
 %   }
 %   Contain information about some options of function/macro
 %   environments.  We initialize \cs{l_@@_override_module_tl} to avoid
@@ -679,6 +680,7 @@
 \bool_new:N \l_@@_macro_var_bool
 \tl_new:N \l_@@_override_module_tl
 \tl_set:Nn \l_@@_override_module_tl { \q_no_value }
+\clist_new:N \l_@@_macro_documented_clist
 %    \end{macrocode}
 % \end{variable}
 %
@@ -855,13 +857,13 @@
 %    \end{macrocode}
 % \end{variable}
 %
-% \begin{variable}[int]{\l_@@_no_label_bool}
-%   This boolean prevents the insertions of \tn{label}s in a
-%   \env{function} environment.  This is only useful when a function's
-%   documentation appears multiple times, for instance in
-%   \file{source3body.tex} some examples repeat the documentation from
-%   actual functions.
+% \begin{variable}[int]{\l_@@_function_label_clist, \l_@@_no_label_bool}
+%   Option of a \env{function} environment which replaces the label that
+%   would normally be inserted by labels for the given list of control
+%   sequences.  This is only useful to avoid duplicate labels when a
+%   function's documentation appears multiple times.
 %    \begin{macrocode}
+\clist_new:N \l_@@_function_label_clist
 \bool_new:N \l_@@_no_label_bool
 %    \end{macrocode}
 % \end{variable}
@@ -919,6 +921,7 @@
 %     \tl_replace_all:Nno,
 %     \tl_replace_once:Noo,
 %     \tl_to_str:f,
+%     \tl_to_str:o,
 %     \prop_get:NxNTF,
 %     \prop_put:Nxn,
 %     \prop_gput:NVx,
@@ -940,7 +943,7 @@
 \cs_generate_variant:Nn \tl_remove_all:Nn   { Nx }
 \cs_generate_variant:Nn \tl_replace_all:Nnn { Nx , Nnx, No , Nno }
 \cs_generate_variant:Nn \tl_replace_once:Nnn { Noo }
-\cs_generate_variant:Nn \tl_to_str:n { f }
+\cs_generate_variant:Nn \tl_to_str:n { f , o }
 \cs_generate_variant:Nn \prop_get:NnNTF { Nx }
 \cs_generate_variant:Nn \prop_put:Nnn { Nx }
 \cs_generate_variant:Nn \prop_gput:Nnn { NVx }
@@ -2110,7 +2113,11 @@
     updated .tl_set:N = \l_@@_date_updated_tl ,
     deprecated .code:n = { \@@_deprecated_on:n {#1} } ,
     tested .code:n = { } ,
-    no-label .bool_set:N = \l_@@_no_label_bool ,
+    label .code:n =
+      {
+        \clist_set:Nn \l_@@_function_label_clist {#1}
+        \bool_set_true:N \l_@@_no_label_bool
+      } ,
     verb .value_forbidden:n = true ,
     verb .bool_set:N = \l_@@_names_verb_bool ,
     module .tl_set:N = \l_@@_override_module_tl ,
@@ -2119,6 +2126,8 @@
 %
 % \begin{macro}[aux]{\@@_deprecated_on:n}
 %   Complain if a deprecated function should have been removed earlier.
+%   In any case, mark it as internal to suppress the text
+%   \enquote{documented on page \ldots{}}.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_deprecated_on:n #1
   {
@@ -2127,6 +2136,7 @@
         \msg_error:nnxx { l3doc } { deprecated-function }
           { \tl_to_str:N \l_@@_macro_argument_tl } {#1}
       }
+    \bool_set_true:N \l_@@_macro_internal_bool
   }
 %    \end{macrocode}
 % \end{macro}
@@ -2208,6 +2218,7 @@
       \bool_set_false:N \l_@@_macro_rEXP_bool
       \bool_set_false:N \l_@@_no_label_bool
       \bool_set_false:N \l_@@_names_verb_bool
+      \clist_clear:N \l_@@_function_label_clist
       \tl_set:Nn \l_@@_override_module_tl { \q_no_value }
       \char_set_catcode_active:N \<
       \cs_set_protected:Npn < ##1 > { \meta {##1} }
@@ -2326,6 +2337,7 @@
     \small\ttfamily
     \begin{tabular} { @{} l @{} r @{} }
       \toprule
+      \@@_function_extra_labels:
       \@@_names_typeset:
       \@@_typeset_dates:
       \bottomrule
@@ -2398,6 +2410,18 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
+\cs_new_protected:Npn \@@_function_extra_labels:
+  {
+    \bool_if:NT \l_@@_no_label_bool
+      {
+        \clist_map_inline:Nn \l_@@_function_label_clist
+          {
+            \exp_args:No \@@_get_hyper_target:nN
+              { \token_to_str:N ##1 } \l_@@_tmpa_tl
+            \exp_args:No \label { \l_@@_tmpa_tl }
+          }
+      }
+  }
 \cs_new_protected:Npn \@@_function_label:n #1
   {
     \bool_if:NF \l_@@_no_label_bool
@@ -2522,6 +2546,7 @@
     deprecated .code:n = { \@@_deprecated_on:n {#1} } ,
     verb .bool_set:N = \l_@@_names_verb_bool ,
     module .tl_set:N = \l_@@_override_module_tl ,
+    documented-as .clist_set:N = \l_@@_macro_documented_clist ,
   }
 %    \end{macrocode}
 %
@@ -2567,6 +2592,7 @@
     \bool_set_false:N \l_@@_macro_tested_bool
     \bool_set_false:N \l_@@_names_verb_bool
     \tl_set:Nn \l_@@_override_module_tl { \q_no_value }
+    \clist_clear:N \l_@@_macro_documented_clist
     \cs_set_eq:NN \testfile \@@_print_testfile:n
     \box_clear:N \l_@@_macro_index_box
     \vbox_set:Nn \l_@@_macro_box
@@ -2944,6 +2970,15 @@
         ! \l_@@_macro_internal_bool
       }
       {
+        \clist_if_empty:NF \l_@@_macro_documented_clist
+          {
+            \seq_gset_from_clist:NN
+              \g_@@_nested_names_seq
+              \l_@@_macro_documented_clist
+            \seq_gset_map:NNn \g_@@_nested_names_seq
+              \g_@@_nested_names_seq
+              { \tl_to_str:o { \token_to_str:N ##1 } }
+          }
         \int_set:Nn \l_@@_tmpa_int
           { \seq_count:N \g_@@_nested_names_seq }
         \int_compare:nNnTF \l_@@_tmpa_int = 1 {~This~} {~These~}



More information about the latex3-commits mailing list