diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx | 174 |
1 files changed, 94 insertions, 80 deletions
diff --git a/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx b/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx index 3119370847e..feffe2b561c 100644 --- a/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx +++ b/Master/texmf-dist/source/latex/l3packages/xtemplate/xtemplate.dtx @@ -4,14 +4,14 @@ %% David Carlisle %% (C) Copyright 2004-2010 Frank Mittelbach, %% The LaTeX3 Project -%% (C) Copyright 2011-2016 The LaTeX3 Project +%% (C) Copyright 2011-2017 The LaTeX3 Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this % license or (at your option) any later version. The latest version % of this license is in the file % -% http://www.latex-project.org/lppl.txt +% https://www.latex-project.org/lppl.txt % % This file is part of the "l3packages bundle" (The Work in LPPL) % and all files in that bundle must be distributed together. @@ -27,8 +27,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2017/11/14] -%<package>\@ifpackagelater{expl3}{2017/11/14} +\RequirePackage{expl3}[2017/12/05] +%<package>\@ifpackagelater{expl3}{2017/12/05} %<package> {} %<package> {% %<package> \PackageError{xtemplate}{Support package l3kernel too old} @@ -63,7 +63,7 @@ % }^^A % } % -% \date{Released 2017/11/14} +% \date{Released 2017/12/05} % % \maketitle % @@ -682,7 +682,7 @@ % \end{macrocode} % % \begin{macrocode} -\ProvidesExplPackage{xtemplate}{2017/11/14}{} +\ProvidesExplPackage{xtemplate}{2017/12/05}{} {L3 Experimental prototype document functions} % \end{macrocode} % @@ -717,13 +717,12 @@ % \end{variable} % % \begin{variable}{\c_@@_keytypes_arg_seq} -% A list of keytypes which also need additional data (an argument), used -% to parse the keytype correctly. +% A list of keytypes which also need additional data (an argument), +% used to parse the keytype correctly. We suspend debugging to allow +% an assignment to a constant. % \begin{macrocode} -\seq_new:N \c_@@_keytypes_arg_seq -\seq_put_right:Nn \c_@@_keytypes_arg_seq { choice } -\seq_put_right:Nn \c_@@_keytypes_arg_seq { function } -\seq_put_right:Nn \c_@@_keytypes_arg_seq { instance } +\seq_const_from_clist:Nn \c_@@_keytypes_arg_seq + { choice , function , instance } % \end{macrocode} % \end{variable} % @@ -1070,34 +1069,64 @@ % \begin{macro}{\@@_recover_vars:n} % Recovering the stored data for a template is rather less complex % than storing it. All that happens is the data is transferred from -% the permanent to the scratch storage. +% the permanent to the scratch storage. However, we need to check the +% scratch storage does exist. % \begin{macrocode} \cs_new_protected:Npn \@@_recover_defaults:n #1 { - \prop_set_eq:Nc \l_@@_values_prop + \prop_if_exist:cTF { \c_@@_defaults_root_tl #1 } + { + \prop_set_eq:Nc \l_@@_values_prop + { \c_@@_defaults_root_tl #1 } + } + { \prop_clear:N \l_@@_values_prop } } \cs_new_protected:Npn \@@_recover_keytypes:n #1 { - \prop_set_eq:Nc \l_@@_keytypes_prop + \prop_if_exist:cTF { \c_@@_keytypes_root_tl #1 } - \seq_set_eq:Nc \l_@@_key_order_seq - { \c_@@_key_order_root_tl #1 } + { + \prop_set_eq:Nc \l_@@_keytypes_prop + { \c_@@_keytypes_root_tl #1 } + } + { \prop_clear:N \l_@@_keytypes_prop } + \seq_if_exist:cTF { \c_@@_key_order_root_tl #1 } + { + \seq_set_eq:Nc \l_@@_key_order_seq + { \c_@@_key_order_root_tl #1 } + } + { \seq_clear:N \l_@@_key_order_seq } } \cs_new_protected:Npn \@@_recover_restrictions:n #1 { - \clist_set_eq:Nc \l_@@_restrict_clist + \clist_if_exist:cTF { \c_@@_restrict_root_tl #1 } + { + \clist_set_eq:Nc \l_@@_restrict_clist + { \c_@@_restrict_root_tl #1 } + } + { \clist_clear:N \l_@@_restrict_clist } } \cs_new_protected:Npn \@@_recover_values:n #1 { - \prop_set_eq:Nc \l_@@_values_prop + \prop_if_exist:cTF { \c_@@_values_root_tl #1 } + { + \prop_set_eq:Nc \l_@@_values_prop + { \c_@@_values_root_tl #1 } + } + { \prop_clear:N \l_@@_values_prop } } \cs_new_protected:Npn \@@_recover_vars:n #1 { - \prop_set_eq:Nc \l_@@_vars_prop + \prop_if_exist:cTF { \c_@@_vars_root_tl #1 } + { + \prop_set_eq:Nc \l_@@_vars_prop + { \c_@@_vars_root_tl #1 } + } + { \prop_clear:N \l_@@_vars_prop } } % \end{macrocode} % \end{macro} @@ -1169,8 +1198,8 @@ % \end{macro} % % \begin{macro}{\@@_parse_keys_elt:n} -% \begin{macro}[aux]{\@@_parse_keys_elt_aux:n} -% \begin{macro}[aux]{\@@_parse_keys_elt_aux:} +% \begin{macro}{\@@_parse_keys_elt_aux:n} +% \begin{macro}{\@@_parse_keys_elt_aux:} % Processing the key part of the key--value pair is always carried out % using this function, even if a value was found. First, the key name % is separated from the keytype, and if necessary the keytype is @@ -1252,7 +1281,7 @@ % \end{macro} % % \begin{macro}{\@@_split_keytype:n} -% \begin{macro}[aux]{\@@_split_keytype_aux:w} +% \begin{macro}{\@@_split_keytype_aux:w} % The keytype and key name should be separated by |:|. As the % definition might be given inside or outside of a code block, spaces % are removed and the category code of colons is standardised. After @@ -1307,8 +1336,8 @@ % \end{macro} % % \begin{macro}{\@@_split_keytype_arg:n, \@@_split_keytype_arg:o} -% \begin{macro}[aux]{\@@_split_keytype_arg_aux:n} -% \begin{macro}[aux]{\@@_split_keytype_arg_aux:w} +% \begin{macro}{\@@_split_keytype_arg_aux:n} +% \begin{macro}{\@@_split_keytype_arg_aux:w} % The second stage of sorting out the keytype is to check for an % argument. As there is no convenient delimiting token to look for, % a check is made instead for each possible text value for the keytype. @@ -1571,8 +1600,8 @@ } % \end{macrocode} % \end{macro} -% \begin{macro}[aux]{\@@_parse_vars_elt_aux:n} -% \begin{macro}[aux]{\@@_parse_vars_elt_aux:w} +% \begin{macro}{\@@_parse_vars_elt_aux:n} +% \begin{macro}{\@@_parse_vars_elt_aux:w} % There now needs to be some sanity checking on the variable name % given. This does not apply for \texttt{choice} or % \texttt{code} \enquote{variables}, but in all other cases the variable @@ -1656,7 +1685,7 @@ % \end{macro} % % \begin{macro}{\@@_implement_choices:n} -% \begin{macro}[aux]{\@@_implement_choices_default:} +% \begin{macro}{\@@_implement_choices_default:} % Implementing choices requires a second key--value loop. So after a % little set-up, the standard parser is called. % \begin{macrocode} @@ -1778,7 +1807,7 @@ % \end{macro} % % \begin{macro}{\@@_edit_defaults:nnn} -% \begin{macro}[aux]{\@@_edit_defaults_aux:nnn} +% \begin{macro}{\@@_edit_defaults_aux:nnn} % Editing the template defaults means getting the values back out % of the store, then parsing the list of new values before putting % the updated list back into storage. The auxiliary function is used @@ -1831,7 +1860,7 @@ % \end{macro} % % \begin{macro}{\@@_parse_values_elt:nn} -% \begin{macro}[aux]{\@@_parse_values_elt_aux:n} +% \begin{macro}{\@@_parse_values_elt_aux:n} % To store the value, find the keytype then call the saving function. % These need the current key name saved as \cs{l_@@_key_name_tl}. % When a template is being restricted, the setting code will be @@ -1889,7 +1918,7 @@ %\subsection{Creating instances of templates} % % \begin{macro}{\@@_declare_instance:nnnnn} -% \begin{macro}[aux]{\@@_declare_instance_aux:nnnnn} +% \begin{macro}{\@@_declare_instance_aux:nnnnn} % Making an instance has two distinct parts. First, the keys given are % parsed to transfer the values into the structured data format used % internally. This allows the default and given values to be combined @@ -1935,8 +1964,8 @@ % \end{macro} % % \begin{macro}{\@@_edit_instance:nnnn} -% \begin{macro}[aux]{\@@_edit_instance_aux:nnnnn} -% \begin{macro}[aux]{\@@_edit_instance_aux:nonnn} +% \begin{macro}{\@@_edit_instance_aux:nnnnn} +% \begin{macro}{\@@_edit_instance_aux:nonnn} % Editing an instance is almost identical to declaring one. The only % variation is the source of the values to use. When editing, they are % recovered from the previous instance run. @@ -1968,9 +1997,9 @@ % \end{macro} % % \begin{macro}{\@@_convert_to_assignments:} -% \begin{macro}[aux]{\@@_convert_to_assignments_aux:n} -% \begin{macro}[aux]{\@@_convert_to_assignments_aux:nn} -% \begin{macro}[aux]{\@@_convert_to_assignments_aux:no} +% \begin{macro}{\@@_convert_to_assignments_aux:n} +% \begin{macro}{\@@_convert_to_assignments_aux:nn} +% \begin{macro}{\@@_convert_to_assignments_aux:no} % The idea on converting to a set of assignments is to loop over each % key, so that the loop order follows the declaration order of the keys. % This is done using a sequence as property lists are not @@ -2022,7 +2051,7 @@ % \end{macro} % % \begin{macro}{\@@_find_global:} -% \begin{macro}[aux]{\@@_find_global_aux:w} +% \begin{macro}{\@@_find_global_aux:w} % Global assignments should have the phrase |global| at the front. % This is pretty easy to find: no other error checking, though. % \begin{macrocode} @@ -2068,7 +2097,7 @@ % \subsection{Assigning values to variables} % % \begin{macro}{\@@_assign_boolean:} -% \begin{macro}[aux]{\@@_assign_boolean_aux:n} +% \begin{macro}{\@@_assign_boolean_aux:n} % Setting a Boolean value is slightly different to everything else % as the value can be used to work out which \texttt{set} function to % call. As long as there is no need to recover things from another @@ -2107,7 +2136,7 @@ % \end{macro} % % \begin{macro}{\@@_assign_choice:} -% \begin{macro}[aux] +% \begin{macro} % {\@@_assign_choice_aux:n, \@@_assign_choice_aux:o} % The idea here is to find either the choice as-given or else the % special |unknown| choice, and to copy the appropriate code across. @@ -2163,7 +2192,7 @@ % \end{macro} % % \begin{macro}{\@@_assign_function:} -% \begin{macro}[aux]{\@@_assign_function_aux:N} +% \begin{macro}{\@@_assign_function_aux:N} % This looks a bit messy but is only actually one function. % \begin{macrocode} \cs_new_protected:Npn \@@_assign_function: @@ -2188,7 +2217,7 @@ % \end{macro} % % \begin{macro}{\@@_assign_instance:} -% \begin{macro}[aux]{\@@_assign_instance_aux:N} +% \begin{macro}{\@@_assign_instance_aux:N} % Using an instance means adding the appropriate function creation to % the tl. No checks are made at this stage, so if the instance is % not valid then errors will arise later. @@ -2261,7 +2290,7 @@ % \end{macro} % % \begin{macro}{\@@_assign_tokenlist:} -% \begin{macro}[aux]{\@@_assign_tokenlist_aux:NN} +% \begin{macro}{\@@_assign_tokenlist_aux:NN} % Life would be easy here if it were not for \cs{KeyValue}. To deal % correctly with that, we need to allow for the recovery a a stored value % at point of use. @@ -2326,8 +2355,8 @@ % \end{macro} % % \begin{macro}{\@@_key_to_value:} -% \begin{macro}[aux]{\@@_key_to_value_auxi:w} -% \begin{macro}[aux]{\@@_key_to_value_auxii:w} +% \begin{macro}{\@@_key_to_value_auxi:w} +% \begin{macro}{\@@_key_to_value_auxii:w} % The idea here is to recover the attribute value of another key. To % do that, the marker is removed and a look up takes place. If this % is successful, then the name of the variable of the attribute is @@ -2368,8 +2397,8 @@ % \subsection{Using instances} % % \begin{macro}{\@@_use_instance:nn} -% \begin{macro}[aux]{\@@_use_instance_aux:nNnnn} -% \begin{macro}[aux]{\@@_use_instance_aux:nn} +% \begin{macro}{\@@_use_instance_aux:nNnnn} +% \begin{macro}{\@@_use_instance_aux:nn} % Using an instance is just a question of finding the appropriate % function. There is the possibility that a collection instance exists, % so this is checked before trying the general instance. If nothing is @@ -2474,7 +2503,7 @@ % \@@_show_defaults:nn, \@@_show_keytypes:nn, % \@@_show_vars:nn % } -% \begin{macro}[int]{\@@_show:Nnnn} +% \begin{macro}{\@@_show:Nnnn} % A modified version of the property-list printing code, such that % the output refers to templates and instances rather than to the % underlying structures. @@ -2508,11 +2537,11 @@ } \cs_new_protected:Npn \@@_show:Nnnn #1#2#3#4 { - \__msg_show_pre:nnnnnn { xtemplate } - { \prop_if_empty:NTF #1 { show-no-attribute } { show-attribute } } - {#2} {#3} {#4} { } - \__msg_show_wrap:n - { \prop_map_function:NN #1 \__msg_show_item_unbraced:nn } + \msg_show:nnxxxx { xtemplate } { show-attribute } + { \tl_to_str:n {#2} } + { \tl_to_str:n {#3} } + { \tl_to_str:n {#4} } + { \prop_map_function:NN #1 \msg_show_item_unbraced:nn } } % \end{macrocode} % \end{macro} @@ -2527,23 +2556,13 @@ \@@_if_instance_exist:nnnT {#1} {#2} {#3} { \@@_recover_values:n { #1 / #2 / #3 } - \prop_if_empty:NTF \l_@@_values_prop + \msg_show:nnxxxx { xtemplate } { show-values } + { \tl_to_str:n {#1} } + { \tl_to_str:n {#2} } + { \tl_to_str:n {#3} } { - \__msg_show_pre:nnnnnn { xtemplate } { show-no-values } - {#1} {#2} {#3} { } - \__msg_show_wrap:n { } - } - { - \prop_pop:NnNF \l_@@_values_prop { from~template } - \l_@@_tmp_tl - { \tl_clear:N \l_@@_tmp_tl } - \__msg_show_pre:nnnnnV { xtemplate } { show-values } - {#1} {#2} {#3} \l_@@_tmp_tl - \__msg_show_wrap:n - { - \prop_map_function:NN \l_@@_values_prop - \__msg_show_item_unbraced:nn - } + \prop_map_function:NN \l_@@_values_prop + \msg_show_item_unbraced:nn } } } @@ -2740,23 +2759,18 @@ Declaring~interface~for~template~'#2'~of~object~type~'#1'~ \msg_line_context:. } -\msg_new:nnn { xtemplate } { show-no-attribute } - { The~template~'#2'~of~object~type~'#1'~has~no~#3 . } \msg_new:nnn { xtemplate } { show-attribute } - { The~template~'#2'~of~object~type~'#1'~has~#3 : } -\msg_new:nnn { xtemplate } { show-no-values } { - The~ \tl_if_empty:nF {#2} {collection~} instance~'#3'~ - \tl_if_empty:nF {#2} { (from~collection~'#2')~ } - of~object~type~'#1'~has~no~values. + The~template~'#2'~of~object~type~'#1'~has~ + \tl_if_empty:nTF {#4} { no~#3. } { #3 : #4 } } \msg_new:nnn { xtemplate } { show-values } { - The~ \tl_if_empty:nF {#2} {collection~} instance~'#3'~ - \tl_if_empty:nF {#2} { (from~collection~'#2')~ } - of~object~type~'#1'~ - \tl_if_empty:nF {#4} { (from~template~'#4')~ } - has~values: + \tl_if_empty:nTF {#2} + { The~instance~'#3'~ } + { The~collection~ instance~'#3'~ (from~collection~'#2')~ } + of~object~type~'#1'~has~ + \tl_if_empty:nTF {#4} { no~values. } { values: #4 } } % \end{macrocode} % |