[latex3-commits] [git/latex3] master: Treat macros as internal/not-internal on a individual basis (bf32250)

Bruno Le Floch bruno at le-floch.fr
Thu Nov 30 21:15:39 CET 2017


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/bf322508b013dd5bda25e3debc6ede3ad018c269

>---------------------------------------------------------------

commit bf322508b013dd5bda25e3debc6ede3ad018c269
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Thu Nov 30 15:15:39 2017 -0500

    Treat macros as internal/not-internal on a individual basis
    
    When the key "int" is not given (nor "internal" nor "deprecated")
    all macros in a given block are marked as internal.  Otherwise each
    macro's name determines whether it is internal or public.
    See for instance \if_int_compare:w and \__int_to_roman:w in l3basics.


>---------------------------------------------------------------

bf322508b013dd5bda25e3debc6ede3ad018c269
 l3kernel/l3doc.dtx |  149 +++++++++++++++++++++++++++++++++-------------------
 1 file changed, 94 insertions(+), 55 deletions(-)

diff --git a/l3kernel/l3doc.dtx b/l3kernel/l3doc.dtx
index ee838f0..1b43966 100644
--- a/l3kernel/l3doc.dtx
+++ b/l3kernel/l3doc.dtx
@@ -652,6 +652,7 @@ and all files in that bundle must be distributed together.
 %
 % \begin{variable}
 %   {
+%     \l_@@_macro_internal_set_bool,
 %     \l_@@_macro_internal_bool,
 %     \l_@@_macro_TF_bool,
 %     \l_@@_macro_pTF_bool,
@@ -666,6 +667,7 @@ and all files in that bundle must be distributed together.
 %   environments.  We initialize \cs{l_@@_override_module_tl} to avoid
 %   overriding module names by an empty name (meaning no module).
 %    \begin{macrocode}
+\bool_new:N \l_@@_macro_internal_set_bool
 \bool_new:N \l_@@_macro_internal_bool
 \bool_new:N \l_@@_macro_TF_bool
 \bool_new:N \l_@@_macro_pTF_bool
@@ -936,9 +938,11 @@ and all files in that bundle must be distributed together.
 %   A few missing variants.
 %    \begin{macrocode}
 \cs_generate_variant:Nn \seq_set_split:Nnn { NoV }
+\cs_generate_variant:Nn \seq_gput_right:Nn { Nf }
 \cs_generate_variant:Nn \str_case:nn { fn }
 \cs_generate_variant:Nn \tl_count:n { f }
 \cs_generate_variant:Nn \tl_greplace_all:Nnn { Nx , Nno }
+\cs_generate_variant:Nn \tl_if_empty:nTF { f }
 \cs_generate_variant:Nn \tl_if_head_eq_charcode:nNTF { o }
 \cs_generate_variant:Nn \tl_if_head_eq_charcode:nNT  { o }
 \cs_generate_variant:Nn \tl_if_head_eq_charcode:nNF  { o }
@@ -2197,6 +2201,64 @@ and all files in that bundle must be distributed together.
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}[pTF]{\@@_if_macro_internal:n}
+% \begin{macro}[EXP]{\@@_if_macro_internal_aux:w}
+%   Determines whether the given macro should be considered internal or
+%   public.  If an option such as |int| was given then the answer is
+%   \cs{l_@@_macro_internal_bool}, otherwise check for whether the macro
+%   name contains~|__|.
+%    \begin{macrocode}
+\prg_new_conditional:Npnn \@@_if_macro_internal:n #1 { p , T , F , TF }
+  {
+    \bool_if:NTF \l_@@_macro_internal_set_bool
+      {
+        \bool_if:NTF \l_@@_macro_internal_bool
+          { \prg_return_true: } { \prg_return_false: }
+      }
+      {
+        \tl_if_empty:fTF
+          {
+            \exp_after:wN \@@_if_macro_internal_aux:w
+            \tl_to_str:n { #1 ~ __ }
+          }
+          { \prg_return_false: } { \prg_return_true: }
+      }
+  }
+\exp_last_unbraced:NNNNo
+  \cs_new:Npn \@@_if_macro_internal_aux:w #1 { \tl_to_str:n { __ } } { }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@@_names_block_base_map:N}
+%   The \cs{l_@@_names_block_tl} contains sequence variables
+%   corresponding to different base functions and their variants.  For
+%   each such sequence, put the first and second items in
+%   \cs{l_@@_tmpa_tl} and \cs{l_@@_tmpb_tl} and build the base
+%   function's name.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_names_block_base_map:N #1
+  {
+    \tl_map_inline:Nn \l_@@_names_block_tl
+      {
+        \group_begin:
+          \seq_set_eq:NN \l_@@_tmpa_seq ##1
+          \seq_pop:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
+          \seq_get:NN \l_@@_tmpa_seq \l_@@_tmpb_tl
+          \exp_args:NNx
+        \group_end:
+        #1
+          {
+            \l_@@_tmpa_tl
+            \str_if_eq_x:nnF { \l_@@_tmpb_tl } { \scan_stop: }
+              { : \l_@@_tmpb_tl }
+            \bool_if:NT \l_@@_macro_TF_bool { TF }
+          }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsubsection{The \env{function} environment}
 %
 %    \begin{macrocode}
@@ -2283,6 +2345,7 @@ and all files in that bundle must be distributed together.
           { \l_@@_tmpa_tl }
       }
     \bool_set_true:N \l_@@_macro_internal_bool
+    \bool_set_true:N \l_@@_macro_internal_set_bool
   }
 %    \end{macrocode}
 % \end{macro}
@@ -2674,10 +2737,16 @@ and all files in that bundle must be distributed together.
       } ,
     internal .value_forbidden:n = true ,
     internal .code:n =
-      { \bool_set_true:N \l_@@_macro_internal_bool } ,
+      {
+        \bool_set_true:N \l_@@_macro_internal_bool
+        \bool_set_true:N \l_@@_macro_internal_set_bool
+      } ,
     int .value_forbidden:n = true ,
     int .code:n =
-      { \bool_set_true:N \l_@@_macro_internal_bool } ,
+      {
+        \bool_set_true:N \l_@@_macro_internal_bool
+        \bool_set_true:N \l_@@_macro_internal_set_bool
+      } ,
     var .value_forbidden:n = true ,
     var .code:n =
       { \bool_set_true:N \l_@@_macro_var_bool } ,
@@ -2739,7 +2808,6 @@ and all files in that bundle must be distributed together.
     \keys_set:nn { l3doc/macro } {#1}
     \@@_names_get_seq:nN {#2} \l_@@_names_seq
     \@@_names_parse:
-    \@@_macro_adjust_internal:
     \@@_macro_save_names:
     \@@_names_typeset:
     \@@_macro_dump:
@@ -2757,6 +2825,7 @@ and all files in that bundle must be distributed together.
   {
     \int_incr:N \l_@@_nested_macro_int
     \bool_set_false:N \l_@@_macro_internal_bool
+    \bool_set_false:N \l_@@_macro_internal_set_bool
     \bool_set_false:N \l_@@_macro_TF_bool
     \bool_set_false:N \l_@@_macro_pTF_bool
     \bool_set_false:N \l_@@_macro_noTF_bool
@@ -2794,43 +2863,23 @@ and all files in that bundle must be distributed together.
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_macro_adjust_internal:}
-%   If all
-%   macros in \cs{l_@@_names_seq} contain |__| then mark them as being
-%   internal. Probably a mix should be an error \dots
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_macro_adjust_internal:
-  {
-    \bool_set_true:N \l_@@_macro_internal_bool
-    \seq_map_inline:Nn \l_@@_names_seq
-      {
-        \tl_if_in:noF {##1} { \tl_to_str:n { __ } }
-          { \l_@@_macro_internal_bool }
-      }
-  }
-%    \end{macrocode}
-% \end{macro}
-%
 % \begin{macro}{\@@_macro_save_names:}
 %   The list of names defined in a set of \env{macro} environments is
-%   eventually used to display on which page they are documented.
+%   eventually used to display on which page they are documented.  If
+%   the |documented-as| key is given, use that, otherwise find names in
+%   \cs{l_@@_names_block_tl}.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_macro_save_names:
   {
-    \tl_map_inline:Nn \l_@@_names_block_tl
+    \tl_if_empty:NTF \l_@@_macro_documented_tl
+      { \@@_names_block_base_map:N \@@_macro_save_names_aux:n }
       {
-        \seq_set_eq:NN \l_@@_tmpa_seq ##1
-        \seq_pop:NN \l_@@_tmpa_seq \l_@@_tmpa_tl
-        \seq_get:NN \l_@@_tmpa_seq \l_@@_tmpb_tl
-        \seq_gput_right:Nx \g_@@_nested_names_seq
-          {
-            \l_@@_tmpa_tl
-            \str_if_eq_x:nnF { \l_@@_tmpb_tl } { \scan_stop: }
-              { : \l_@@_tmpb_tl }
-            \bool_if:NT \l_@@_macro_TF_bool { TF }
-          }
+        \seq_gput_right:Nf \g_@@_nested_names_seq
+          { \exp_after:wN \token_to_str:N \l_@@_macro_documented_tl }
       }
   }
+\cs_new_protected:Npn \@@_macro_save_names_aux:n #1
+  { \seq_gput_right:Nn \g_@@_nested_names_seq {#1} }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2908,7 +2957,7 @@ and all files in that bundle must be distributed together.
     \DoNotIndex {#1}
     \bool_if:NT #2
       {
-        \bool_if:NF \l_@@_macro_internal_bool
+        \@@_if_macro_internal:nF {#1}
           { \seq_gput_right:Nn \g_doc_macros_seq {#1} }
         \hbox_set:Nw \l_@@_macro_index_box
           \hbox_unpack_clear:N \l_@@_macro_index_box
@@ -2970,7 +3019,7 @@ and all files in that bundle must be distributed together.
   }
 \cs_new_protected:Npn \@@_macroname_prefix:n #1
   {
-    \bool_if:NTF \l_@@_macro_internal_bool
+    \@@_if_macro_internal:nTF {#1}
       { \@@_typeset_aux:n {#1} } {#1}
   }
 \cs_generate_variant:Nn \@@_macroname_prefix:n { o }
@@ -3082,10 +3131,7 @@ and all files in that bundle must be distributed together.
     \endtrivlist
     \@@_macro_end_check_tested:
     \int_compare:nNnT \l_@@_nested_macro_int = 1
-      {
-        \@@_macro_end_style:n { \@@_print_end_definition: }
-        \seq_gclear:N \g_@@_nested_names_seq
-      }
+      { \@@_macro_end_style:n { \@@_print_end_definition: } }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -3100,14 +3146,15 @@ and all files in that bundle must be distributed together.
     \bool_lazy_all:nT
      {
        { \g_@@_checktest_bool }
-       { ! \l_@@_macro_internal_bool }
        { ! \l_@@_macro_var_bool }
        { ! \l_@@_macro_tested_bool }
      }
      {
+       \seq_set_filter:NNn \l_@@_tmpa_seq \l_@@_names_seq
+         { ! \@@_if_macro_internal_p:n {##1} }
        \seq_gput_right:Nx \g_@@_not_tested_seq
          {
-           \seq_use:Nn \l_@@_names_seq { , }
+           \seq_use:Nn \l_@@_tmpa_seq { , }
            \bool_if:NTF \l_@@_macro_pTF_bool {~(pTF)}
              { \bool_if:NT \l_@@_macro_TF_bool {~(TF)} }
          }
@@ -3164,31 +3211,23 @@ and all files in that bundle must be distributed together.
   }
 \cs_new_protected:Npn \@@_print_documented:
   {
-    \bool_if:NF \l_@@_macro_internal_bool
+    \seq_gset_filter:NNn \g_@@_nested_names_seq
+      \g_@@_nested_names_seq
+      { ! \@@_if_macro_internal_p:n {##1} }
+    \seq_if_empty:NF \g_@@_nested_names_seq
       {
         \int_set:Nn \l_@@_tmpa_int
           { \seq_count:N \g_@@_nested_names_seq }
-        \tl_if_empty:NTF \l_@@_macro_documented_tl
-          {
-            \tl_set:Nx \l_@@_macro_documented_tl
-              { \seq_item:Nn \g_@@_nested_names_seq { 1 } }
-          }
-          {
-            \tl_set:Nf \l_@@_macro_documented_tl
-              {
-                \exp_after:wN \token_to_str:N
-                \l_@@_macro_documented_tl
-              }
-          }
         \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~
-        \@@_get_hyper_target:oN
-          \l_@@_macro_documented_tl
+        \@@_get_hyper_target:xN
+          { \seq_item:Nn \g_@@_nested_names_seq { 1 } }
           \l_@@_tmpa_tl
         \exp_args:Nx \pageref { \l_@@_tmpa_tl } .
       }
+    \seq_gclear:N \g_@@_nested_names_seq
   }
 %    \end{macrocode}
 % \end{macro}





More information about the latex3-commits mailing list