summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/xpackages
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-01-11 23:19:23 +0000
committerKarl Berry <karl@freefriends.org>2011-01-11 23:19:23 +0000
commit7bd702012caa7bf7f4c360eacb814e65773e38e0 (patch)
tree876d8b8ff7baa069560c1614e0dab49d20e74726 /Master/texmf-dist/source/latex/xpackages
parent62764a821e78856fc5c6db6525928247bc194581 (diff)
xpackages 2126 (10jan11)
git-svn-id: svn://tug.org/texlive/trunk@21031 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/xpackages')
-rw-r--r--Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx112
1 files changed, 111 insertions, 1 deletions
diff --git a/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx b/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx
index dbcbbf28a84..ab2f5d2887c 100644
--- a/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx
+++ b/Master/texmf-dist/source/latex/xpackages/xbase/xparse.dtx
@@ -41,7 +41,7 @@
\RequirePackage{l3names}
%</driver|package>
%\fi
-\GetIdInfo$Id: xparse.dtx 2073 2010-10-13 07:48:20Z joseph $
+\GetIdInfo$Id: xparse.dtx 2125 2011-01-09 15:24:39Z joseph $
{Generic document command parser}
%\iffalse
%<*driver>
@@ -541,6 +541,41 @@
% which does not conform to the first three requirements. The last
% item is an issue when the function is used, and so is beyond the
% scope of \pkg{xparse} itself.
+%\end{function}
+%
+%\subsection{Access to the argument specification}
+%
+% The argument specifications for document commands and environments are
+% available for examination and use.
+%
+%\begin{function}{
+% \GetDocumentCommandArgSpec |
+% \GetDocumentEnvironmentArgSpec |
+%}
+% \begin{syntax}
+% \cs{GetDocumentCommandArgSpec} \meta{function}
+% \cs{GetDocumentEnvironmentArgSpec} \meta{environment}
+% \end{syntax}
+% These functions transfer the current argument specification for the
+% requested \meta{function} or \meta{environment} into the token list
+% variable \cs{ArgumentSpecification}. If the \meta{function} or
+% \meta{environment} has no known argument specification then an error
+% is issued. The assignment to \cs{ArgumentSpecification} is local to
+% the current \TeX\ group.
+%\end{function}
+%
+%\begin{function}{
+% \ShowDocumentCommandArgSpec |
+% \ShowDocumentEnvironmentArgSpec |
+%}
+% \begin{syntax}
+% \cs{ShowDocumentCommandArgSpec} \meta{function}
+% \cs{ShowDocumentEnvironmentArgSpec} \meta{environment}
+% \end{syntax}
+% These functions show the current argument specification for the
+% requested \meta{function} or \meta{environment} at the terminal. If
+% the \meta{function} or \meta{environment} has no known argument
+% specification then an error is issued.
%\end{function}
%
%\subsection{Variables and constants}
@@ -2521,6 +2556,65 @@
\cs_new_eq:NN \xparse_exp_set:cpx \cs_set_nopar:cpx
% \end{macrocode}
%\end{macro}
+%
+%\subsection{Access to the argument specification}
+%
+%\begin{macro}{\parse_get_arg_spec:N}
+%\begin{macro}{\parse_get_arg_spec:n}
+%\begin{macro}{\ArgumentSpecification}
+% Recovering the argument specification is also trivial, using the
+% \cs{tl_set_eq:cN} function.
+% \begin{macrocode}
+\cs_new_protected:Npn \parse_get_arg_spec:N #1 {
+ \cs_if_exist:cTF { l_parse_ \token_to_str:N #1 _arg_spec_tl }
+ {
+ \tl_set_eq:Nc \ArgumentSpecification
+ { l_parse_ \token_to_str:N #1 _arg_spec_tl }
+ }
+ {
+ \msg_kernel_error:nx { unknown-document-command }
+ { \token_to_str:N #1 }
+ }
+}
+\cs_new_protected:Npn \parse_get_arg_spec:n #1 {
+ \cs_if_exist:cTF { l_parse_ #1 _arg_spec_tl }
+ { \tl_set_eq:Nc \ArgumentSpecification { l_parse_ #1 _arg_spec_tl } }
+ { \msg_kernel_error:nx { unknown-document-environment } {#1} }
+}
+\tl_new:N \ArgumentSpecification
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\parse_show_arg_spec:N}
+%\begin{macro}{\parse_show_arg_spec:n}
+% Showing the argument specification simply means finding it and then
+% calling the \cs{tl_show:c} function.
+% \begin{macrocode}
+\cs_new_protected:Npn \parse_show_arg_spec:N #1 {
+ \cs_if_exist:cTF { l_parse_ \token_to_str:N #1 _arg_spec_tl }
+ {
+ \tl_set_eq:Nc \ArgumentSpecification
+ { l_parse_ \token_to_str:N #1 _arg_spec_tl }
+ \tl_show:N \ArgumentSpecification
+ }
+ {
+ \msg_kernel_error:nx { unknown-document-command }
+ { \token_to_str:N #1 }
+ }
+}
+\cs_new_protected:Npn \parse_show_arg_spec:n #1 {
+ \cs_if_exist:cTF { l_parse_ #1 _arg_spec_tl }
+ {
+ \tl_set_eq:Nc \ArgumentSpecification { l_parse_ #1 _arg_spec_tl }
+ \tl_show:N \ArgumentSpecification
+ }
+ { \msg_kernel_error:nx { unknown-document-environment } {#1} }
+}
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
%
%\subsection{Messages}
%
@@ -2829,6 +2923,22 @@
%\end{macro}
%\end{macro}
%
+%\begin{macro}{\GetDocumentCommandArgSpec}
+%\begin{macro}{\GetDocumentEnvironmentArgSpec}
+%\begin{macro}{\ShowDocumentCommandArgSpec}
+%\begin{macro}{\ShowDocumentEnvironmentArgSpec}
+% More simple mappings.
+% \begin{macrocode}
+\cs_new_eq:NN \GetDocumentCommandArgSpec \parse_get_arg_spec:N
+\cs_new_eq:NN \GetDocumentEnvironmmentArgSpec \parse_get_arg_spec:n
+\cs_new_eq:NN \ShowDocumentCommandArgSpec \parse_show_arg_spec:N
+\cs_new_eq:NN \ShowDocumentEnvironmentArgSpec \parse_show_arg_spec:n
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}