[latex3-commits] [git/LaTeX3-latex3-latex3] master: Show functions for hook entries (cf5e033)
Joseph Wright
joseph.wright at morningstar2.co.uk
Fri Jun 7 15:42:26 CEST 2019
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/cf5e033944a7ad72fe1201852a452d16bc1fabbd
>---------------------------------------------------------------
commit cf5e033944a7ad72fe1201852a452d16bc1fabbd
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Fri Jun 7 14:37:53 2019 +0100
Show functions for hook entries
>---------------------------------------------------------------
cf5e033944a7ad72fe1201852a452d16bc1fabbd
l3trial/l3hooks/l3hooks.dtx | 94 ++++++++++++++++++++++++++++++
l3trial/l3hooks/testfiles/m3hooks001.lvt | 14 +++++
l3trial/l3hooks/testfiles/m3hooks001.tlg | 21 +++++++
3 files changed, 129 insertions(+)
diff --git a/l3trial/l3hooks/l3hooks.dtx b/l3trial/l3hooks/l3hooks.dtx
index 8912065..e03f684 100644
--- a/l3trial/l3hooks/l3hooks.dtx
+++ b/l3trial/l3hooks/l3hooks.dtx
@@ -104,6 +104,14 @@
% is possible for a |next| entry to add to the following |next| hook.
% \end{function}
%
+% \begin{function}[added = 2019-06-07]{\hook_show:nn, \hook_log:nn}
+% \begin{syntax}
+% \cs{hook_show:nn} \Arg{module} \Arg{hook}
+% \end{syntax}
+% Displays entries in the \meta{hook} for the \meta{module} in the terminal
+% or writes them to the log, respectively.
+% \end{function}
+%
% \subsection{Document-wide hooks}
%
% Document-wide hooks may be used only once in a document. These are therefore
@@ -139,6 +147,16 @@
% added to it.
% \end{function}
%
+% \begin{function}[added = 2019-06-07]
+% {\hook_document_show:nn, \hook_document_log:nn}
+% \begin{syntax}
+% \cs{hook_document_show:n}\Arg{hook}
+% \end{syntax}
+% Displays entries in the \meta{hook} for the \meta{module} in the terminal
+% or writes them to the log, respectively.
+% \end{function}
+%
+%
% \end{documentation}
%
% \begin{implementation}
@@ -337,6 +355,62 @@
% \end{macrocode}
% \end{macro}
%
+% \subsection{Showing hooks}
+%
+% \begin{macro}{\hook_show:nn, \hook_log:nn}
+% \begin{macro}{\@@_show:Nnn}
+% \begin{macrocode}
+\cs_new_protected:Npn \hook_show:nn #1#2
+ { \@@_show:Nnn \msg_show:nnxxxx {#1} {#2} }
+\cs_new_protected:Npn \hook_log:nn #1#2
+ { \@@_show:Nnn \msg_log:nnxxxx {#1} {#2} }
+\cs_new_protected:Npn \@@_show:Nnn #1#2#3
+ {
+ \cs_if_free:cTF { g_@@_next_ #2 _ #3 _seq }
+ {
+ \__kernel_msg_error:nnnn { hooks }
+ { unknown-hook } {#2} {#3}
+ }
+ {
+ #1 { LaTeX/hooks } { show-hook }
+ {#2} {#3}
+ {
+ \seq_map_function:cN { g_@@_all_ #2 _ #3 _seq } \msg_show_item:n
+ }
+ {
+ \seq_map_function:cN { g_@@_next_ #2 _ #3 _seq } \msg_show_item:n
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\hook_document_show:n, \hook_document_log:n}
+% \begin{macro}{\@@_document_show:Nn}
+% \begin{macrocode}
+\cs_new_protected:Npn \hook_document_show:n #1
+ { \@@_document_show:Nn \msg_show:nnxxxx {#1} }
+\cs_new_protected:Npn \hook_document_log:n #1
+ { \@@_document_show:Nn \msg_log:nnxxxx {#1} }
+\cs_new_protected:Npn \@@_document_show:Nn #1#2
+ {
+ \cs_if_free:cTF { g_@@_document_ #2 _seq }
+ {
+ \__kernel_msg_error:nnn { hooks }
+ { unknown-document-hook } {#2}
+ }
+ {
+ #1 { LaTeX/hooks } { show-document-hook }
+ {#2}
+ { \seq_map_function:cN { g_@@_document_ #2 _seq } \msg_show_item:n }
+ { } { }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \subsection{Messages}
%
% \begin{macrocode}
@@ -373,6 +447,26 @@
% \end{macrocode}
%
% \begin{macrocode}
+\__kernel_msg_new:nnn { hooks } { show-document-hook }
+ {
+ Document~hook~'#1'~
+ \tl_if_empty:nTF {#2}
+ { has~no~entries \\ >~ . }
+ { contains~entries~: #2 . }
+ }
+\__kernel_msg_new:nnn { hooks } { show-hook }
+ {
+ Module~#1~hook~'#2'~
+ \tl_if_empty:nTF {#3}
+ { has~no~entries~for~all~uses~ }
+ { contains~entries~for~all~uses: #3 \\ }
+ \tl_if_empty:nTF {#4}
+ { and~has~no~entries~for~the~next~use \\ >~ . }
+ { and~has~the~following~entries~for~the~next~use: #4 . }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
%</initex|package>
% \end{macrocode}
%
diff --git a/l3trial/l3hooks/testfiles/m3hooks001.lvt b/l3trial/l3hooks/testfiles/m3hooks001.lvt
index d2853c7..643315b 100644
--- a/l3trial/l3hooks/testfiles/m3hooks001.lvt
+++ b/l3trial/l3hooks/testfiles/m3hooks001.lvt
@@ -78,4 +78,18 @@
\hook_document_use:n { dochook }
}
+\TEST { Show~hooks }
+ {
+ \OMIT
+ \hook_gadd_next:nnnn { mypkg } { hook-a } { newpkg } { foo }
+ \TIMO
+ \hook_show:nn { mypkg } { hook-a }
+ \hook_show:nn { mypkg } { hook-b }
+ \OMIT
+ \hook_document_new:n { demo }
+ \hook_document_gadd:nnn { demo } { entry } { foo }
+ \TIMO
+ \hook_document_show:n { demo }
+ }
+
\END
\ No newline at end of file
diff --git a/l3trial/l3hooks/testfiles/m3hooks001.tlg b/l3trial/l3hooks/testfiles/m3hooks001.tlg
index 9f6d3f9..bb6d8c1 100644
--- a/l3trial/l3hooks/testfiles/m3hooks001.tlg
+++ b/l3trial/l3hooks/testfiles/m3hooks001.tlg
@@ -106,3 +106,24 @@ l. ... }
LaTeX has been asked to use document-wide hook 'dochook' but this hook has
already been used.
============================================================
+============================================================
+TEST 7: Show hooks
+============================================================
+Module mypkg hook 'hook-a' contains entries for all uses:
+> {otherpkg}
+and has the following entries for the next use:
+> {newpkg}.
+<recently read> }
+l. ... }
+Module mypkg hook 'hook-b' contains entries for all uses:
+> {otherpkg/sub-a}
+> {otherpkg/sub-b}
+and has no entries for the next use
+> .
+<recently read> }
+l. ... }
+Document hook 'demo' contains entries :
+> {entry}.
+<recently read> }
+l. ... }
+============================================================
More information about the latex3-commits
mailing list