[latex3-commits] [git/LaTeX3-latex3-latex3] gh1010-doc: Add bool_to_str and fix some documentation (fixes #1010) (1328e05fa)

Bruno Le Floch blflatex at gmail.com
Mon Nov 1 20:34:31 CET 2021


Repository : https://github.com/latex3/latex3
On branch  : gh1010-doc
Link       : https://github.com/latex3/latex3/commit/1328e05faa1f1b9b95e27253f39872559a284a9b

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

commit 1328e05faa1f1b9b95e27253f39872559a284a9b
Author: Bruno Le Floch <blflatex at gmail.com>
Date:   Mon Nov 1 20:30:22 2021 +0100

    Add bool_to_str and fix some documentation (fixes #1010)


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

1328e05faa1f1b9b95e27253f39872559a284a9b
 l3kernel/CHANGELOG.md           |  1 +
 l3kernel/l3keys.dtx             | 22 +++++++++++-----------
 l3kernel/l3prg.dtx              | 30 ++++++++++++++++++++++--------
 l3kernel/testfiles/m3prg005.lvt |  7 +++++++
 l3kernel/testfiles/m3prg005.tlg | 12 ++++++++++++
 5 files changed, 53 insertions(+), 19 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 694d34257..4932bea1b 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -12,6 +12,7 @@ this project uses date-based 'snapshot' version identifiers.
 
 ### Added
 - `.str_set:N`, etc., key properties (issue #1007)
+- `\bool_to_str:n` (issue #1010)
 
 ## [2021-10-18]
 
diff --git a/l3kernel/l3keys.dtx b/l3kernel/l3keys.dtx
index 69fd3fb56..f652bc536 100644
--- a/l3kernel/l3keys.dtx
+++ b/l3kernel/l3keys.dtx
@@ -178,10 +178,10 @@
 % \begin{function}[updated = 2013-07-08]
 %   {.bool_set:N, .bool_set:c, .bool_gset:N, .bool_gset:c}
 %   \begin{syntax}
-%     \meta{key} .bool_set:N = \meta{boolean}
+%     \meta{key} .bool_set:N = \meta{boolean variable}
 %   \end{syntax}
-%   Defines \meta{key} to set \meta{boolean} to \meta{value} (which
-%   must be either \texttt{true} or \texttt{false}).  If the variable
+%   Defines \meta{key} to set \meta{boolean variable} to \meta{value} (which
+%   must be either \enquote{\texttt{true}} or \enquote{\texttt{false}}).  If the variable
 %   does not exist, it will be created globally at the point that
 %   the key is set up.
 % \end{function}
@@ -192,12 +192,12 @@
 %     .bool_gset_inverse:N, .bool_gset_inverse:c
 %   }
 %   \begin{syntax}
-%     \meta{key} .bool_set_inverse:N = \meta{boolean}
+%     \meta{key} .bool_set_inverse:N = \meta{boolean variable}
 %   \end{syntax}
-%   Defines \meta{key} to set \meta{boolean} to the logical
-%   inverse of \meta{value} (which  must be either \texttt{true} or
-%   \texttt{false}).
-%   If the \meta{boolean} does not exist, it will be created globally
+%   Defines \meta{key} to set \meta{boolean variable} to the logical
+%   inverse of \meta{value} (which  must be either \enquote{\texttt{true}} or
+%   \enquote{\texttt{false}}).
+%   If the \meta{boolean variable} does not exist, it will be created globally
 %   at the point that the key is set up.
 % \end{function}
 %
@@ -488,7 +488,7 @@
 %   \end{syntax}
 %   Specifies that \meta{key} cannot receive a \meta{value} when used.
 %   If a \meta{value} is given then an error will be issued. Setting
-%   the property \texttt{false} cancels the restriction.
+%   the property \enquote{\texttt{false}} cancels the restriction.
 % \end{function}
 %
 % \begin{function}[added = 2015-07-14]{.value_required:n}
@@ -497,7 +497,7 @@
 %   \end{syntax}
 %   Specifies that \meta{key} must receive a \meta{value} when used.
 %   If a \meta{value} is not given then an error will be issued. Setting
-%   the property \texttt{false} cancels the restriction.
+%   the property \enquote{\texttt{false}} cancels the restriction.
 % \end{function}
 %
 % \section{Sub-dividing keys}
@@ -2073,7 +2073,7 @@
       }
       {
         \msg_error:nnx { keys }
-          { property-boolean-values-only }
+          { boolean-values-only }
           { .value_ #1 :n }
       }
   }
diff --git a/l3kernel/l3prg.dtx b/l3kernel/l3prg.dtx
index ae119af20..b70bde39c 100644
--- a/l3kernel/l3prg.dtx
+++ b/l3kernel/l3prg.dtx
@@ -313,6 +313,16 @@
 %   based on this result.
 % \end{function}
 %
+% \begin{function}[EXP, added = 2021-11-01]{\bool_to_str:N, \bool_to_str:c, \bool_to_str:n}
+%   \begin{syntax}
+%     \cs{bool_to_str:N} \meta{boolean}
+%     \cs{bool_to_str:n} \meta{boolean expression}
+%   \end{syntax}
+%   Expands to the letters \texttt{true} or \texttt{false} depending on
+%   the logical truth of the \meta{boolean} or \meta{boolean
+%   expression}.
+% \end{function}
+%
 % \begin{function}[added = 2012-02-09, updated = 2021-04-29]{\bool_show:N, \bool_show:c}
 %   \begin{syntax}
 %     \cs{bool_show:N} \meta{boolean}
@@ -961,20 +971,24 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}[EXP]{\bool_to_str:N, \bool_to_str:c, \bool_to_str:n}
+%   Expands to \texttt{true} or \texttt{false} with category code letter.
+%    \begin{macrocode}
+\cs_new:Npn \bool_to_str:N #1 { \bool_if:NTF #1 { true } { false } }
+\cs_generate_variant:Nn \bool_to_str:N { c }
+\cs_new:Npn \bool_to_str:n #1 { \bool_if:nTF {#1} { true } { false } }
+%    \end{macrocode}
+% \end{function}
+%
 % \begin{macro}{\bool_show:n, \bool_log:n}
-% \begin{macro}{\@@_to_str:n}
-%   Show the truth value of the boolean, as \texttt{true} or
-%   \texttt{false}.
+%   Show the truth value of the boolean.
 %    \begin{macrocode}
 \cs_new_protected:Npn \bool_show:n
-  { \msg_show_eval:Nn \@@_to_str:n }
+  { \msg_show_eval:Nn \bool_to_str:n }
 \cs_new_protected:Npn \bool_log:n
-  { \msg_log_eval:Nn \@@_to_str:n }
-\cs_new:Npn \@@_to_str:n #1
-  { \bool_if:nTF {#1} { true } { false } }
+  { \msg_log_eval:Nn \bool_to_str:n }
 %    \end{macrocode}
 % \end{macro}
-% \end{macro}
 %
 % \begin{macro}{\bool_show:N, \bool_show:c, \bool_log:N, \bool_log:c, \@@_show:NN}
 %   Show the truth value of the boolean, as \texttt{true} or
diff --git a/l3kernel/testfiles/m3prg005.lvt b/l3kernel/testfiles/m3prg005.lvt
index c28817842..1aa21aad6 100644
--- a/l3kernel/testfiles/m3prg005.lvt
+++ b/l3kernel/testfiles/m3prg005.lvt
@@ -111,4 +111,11 @@
     \NEWLINE
   }
 
+\TESTEXP { bool_to_str }
+  {
+    \bool_to_str:c { c_true_bool } ,
+    \bool_to_str:N ? ,
+    \bool_to_str:n { ! ! \c_false_bool && \c_false_bool }
+  }
+
 \END
diff --git a/l3kernel/testfiles/m3prg005.tlg b/l3kernel/testfiles/m3prg005.tlg
index 7791e05b5..8d8e36387 100644
--- a/l3kernel/testfiles/m3prg005.tlg
+++ b/l3kernel/testfiles/m3prg005.tlg
@@ -57,3 +57,15 @@ FALSE
 TRUETRUE
 FALSE
 ============================================================
+============================================================
+TEST 6: bool_to_str
+============================================================
+! Missing number, treated as zero.
+<to be read again> 
+                   ?
+l. ...  }
+A number should have been here; I inserted `0'.
+(If you can't figure out why I needed to see a number,
+look up `weird error' in the index to The TeXbook.)
+true,false,false
+============================================================





More information about the latex3-commits mailing list.