[latex3-commits] [l3svn] r6672 - l3doc: Index F/T conditionals as TF

noreply at latex-project.org noreply at latex-project.org
Thu Aug 18 15:15:46 CEST 2016


Author: bruno
Date: 2016-08-18 15:15:46 +0200 (Thu, 18 Aug 2016)
New Revision: 6672

Modified:
   trunk/l3kernel/l3doc.dtx
Log:
l3doc: Index F/T conditionals as TF

This slows down compilation quite a lot because we need to
detect F/T endings for every macro in every macrocode environment.
If too slow I can write lower-level code to optimize.


Modified: trunk/l3kernel/l3doc.dtx
===================================================================
--- trunk/l3kernel/l3doc.dtx	2016-08-18 11:40:16 UTC (rev 6671)
+++ trunk/l3kernel/l3doc.dtx	2016-08-18 13:15:46 UTC (rev 6672)
@@ -1020,7 +1020,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[aux]{\@@_split_function_do:nn}
+% \begin{macro}[aux]{\@@_split_function_do:nn, \@@_split_function_do:on}
 % \begin{macro}[aux]{\@@_get_function_name:n, \@@_get_function_signature:n}
 % \begin{macro}[aux]{\@@_split_function_auxi:w, \@@_split_function_auxii:w}
 %   Similar to internal functions defined in \pkg{l3basics}, but here we
@@ -1047,17 +1047,45 @@
       { ##1 {##2} }
   }
 \exp_args:No \@@_tmpa:w { \token_to_str:N : }
+\cs_generate_variant:Nn \@@_split_function_do:nn { o }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}[aux, rEXP]{\@@_base_form:n}
-%   Get the base form of a function and output it within \cs{exp_not:n},
-%   useful for cases where |#1| contains for instance active characters.
+% \begin{macro}[aux, rEXP]{\@@_key_get_base:nN}
+%   Get the base form of a function and store it.  As part of getting
+%   the base form, change trailing |T| or |F| to |TF|.
 %    \begin{macrocode}
-\cs_new:Npn \@@_base_form:n #1
-  { \@@_split_function_do:nn {#1} { \@@_base_form_aux:nnN } }
+\cs_new_protected:Npn \@@_key_get_base:nN #1#2
+  {
+    \@@_if_almost_str:nTF {#1}
+      {
+        \@@_key_get_base_TF:nN {#1} \l_@@_tmpa_tl
+        \tl_set:Nx #2
+          { \@@_split_function_do:on \l_@@_tmpa_tl { \@@_base_form_aux:nnN } }
+      }
+      { \tl_set:Nn #2 {#1} }
+  }
+\cs_new:Npx \@@_key_get_base_TF:nN #1#2
+  {
+    \tl_set:Nx #2 { \exp_not:N \tl_to_str:n {#1} \scan_stop: }
+    \tl_if_in:NnTF #2 { \tl_to_str:n { F } \scan_stop: }
+      {
+        \tl_if_in:NnF #2 { \tl_to_str:n { TF } \scan_stop: }
+          {
+            \tl_replace_once:Nnn #2
+              { \tl_to_str:n { F } \scan_stop: }
+              { \tl_to_str:n { TF } \scan_stop: }
+          }
+      }
+      {
+        \tl_replace_once:Nnn #2
+          { \tl_to_str:n { T } \scan_stop: }
+          { \tl_to_str:n { TF } \scan_stop: }
+      }
+    \tl_remove_once:Nn #2 { \scan_stop: }
+  }
 \cs_new:Npn \@@_base_form_aux:nnN #1#2#3
   {
     \exp_not:n {#1}
@@ -1093,13 +1121,7 @@
             \use:x
               {
                 \exp_not:n {#3}
-                {
-                  \exp_not:n {#4}
-                  \token_to_str:N :
-                  \str_if_eq:nnTF { #4 ~ } { \exp_args }
-                    { \exp_not:n {#5} }
-                    { \@@_signature_base_form:n {#5} }
-                }
+                { \@@_base_form_aux:nnN {#4} {#5} #6 }
               }
                 { {#5} }
           }
@@ -3475,7 +3497,7 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_special_index:nn #1#2
   {
-    \exp_args:Nx \@@_key_get:n { \@@_base_form:n {#1} }
+    \@@_key_get:n {#1}
     \@@_special_index_module:ooonN
       { \l_@@_index_key_tl }
       { \l_@@_index_macro_tl }
@@ -3582,7 +3604,7 @@
 % \begin{macro}[aux]{\@@_key_get:n}
 %   Sets \cs{l_@@_index_macro_tl}, \cs{l_@@_index_key_tl}, and
 %   \cs{l_@@_index_module_tl} from |#1|.  The base function is stored by
-%   \cs{@@_key_get_base:n} in \cs{l_@@_index_macro_tl}, falling back to
+%   \cs{@@_key_get_base:nN} in \cs{l_@@_index_macro_tl}, falling back to
 %   |#1| if it contains markup or has no signature.
 %
 %   The starting point for the \meta{key} is \cs{l_@@_index_key_tl} as a
@@ -3596,7 +3618,7 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_key_get:n #1
   {
-    \@@_key_get_base:n {#1}
+    \@@_key_get_base:nN {#1} \l_@@_index_macro_tl
     \tl_set:Nx \l_@@_index_key_tl
       { \tl_to_str:N \l_@@_index_macro_tl }
     \tl_clear:N \l_@@_index_module_tl
@@ -3617,15 +3639,6 @@
           }
       }
   }
-\cs_new_protected:Npn \@@_key_get_base:n #1
-  {
-    \@@_if_almost_str:nTF {#1}
-      {
-        \tl_set:Nx \l_@@_index_macro_tl
-          { \@@_base_form:n {#1} }
-      }
-      { \tl_set:Nn \l_@@_index_macro_tl {#1} }
-  }
 \cs_new_protected:Npn \@@_key_pop:
   {
     \tl_set:Nx \l_@@_index_key_tl



More information about the latex3-commits mailing list