[latex3-commits] [git/LaTeX3-latex3-latex2e] lthooks2: move emulation packages make shipout-006 actually test something (was missing a \START) (8a703865)

Frank Mittelbach frank.mittelbach at latex-project.org
Wed Aug 19 14:31:44 CEST 2020


Repository : https://github.com/latex3/latex2e
On branch  : lthooks2
Link       : https://github.com/latex3/latex2e/commit/8a7038653e5a3f6906c2c5cf9988fee787ea5d12

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

commit 8a7038653e5a3f6906c2c5cf9988fee787ea5d12
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Wed Aug 19 14:31:44 2020 +0200

    move emulation packages
    make shipout-006 actually test something (was missing a \START)


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

8a7038653e5a3f6906c2c5cf9988fee787ea5d12
 base/ltfilehook.dtx                    | 278 +++++++++++++++++----------------
 base/testfiles-lthooks/shipout-006.lvt |  15 +-
 base/testfiles-lthooks/shipout-006.tlg |   3 +
 3 files changed, 155 insertions(+), 141 deletions(-)

diff --git a/base/ltfilehook.dtx b/base/ltfilehook.dtx
index 96ad31c6..25021085 100644
--- a/base/ltfilehook.dtx
+++ b/base/ltfilehook.dtx
@@ -1076,7 +1076,147 @@
 %
 %
 %
-% \section{Package emulation for compatibility}
+% \section{A sample package for structuring the log output}
+%
+%    \begin{macrocode}
+%<*structuredlog>
+%<@@=filehook>
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\ProvidesExplPackage
+    {structuredlog}{\ltfilehookdate}{\ltfilehookversion}
+    {Structuring the TeX transcript file}
+%    \end{macrocode}
+%
+% \begin{macro}{\g_@@_nesting_level_int}
+%   Stores the current package nesting level.
+%    \begin{macrocode}
+\int_new:N \g_@@_nesting_level_int
+%    \end{macrocode}
+%   Initialise the counter with the number of files in the
+%   \cs{@currnamestack} (the number of items divided by $3$) minus one,
+%   because this package is skipped when printing to the log.
+%    \begin{macrocode}
+\int_gset:Nn \g_@@_nesting_level_int
+  { ( \tl_count:N \@currnamestack ) / 3 - 1 }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_log_file_record:n}
+%   This macro is responsible for increasing and decresing the file
+%   nesting level, as well as printing to the log.  The argument is
+%   either |STOPTART| or |STOP| and the action it takes on the nesting
+%   integer depends on that.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_log_file_record:n #1
+  {
+    \str_if_eq:nnT {#1} {START} { \int_gincr:N \g_@@_nesting_level_int }
+    \iow_term:x
+      {
+        \prg_replicate:nn { \g_@@_nesting_level_int } { = } ~
+        ( LEVEL ~ \int_use:N \g_@@_nesting_level_int \c_space_tl #1 ) ~
+        \CurrentFileUsed
+%    \end{macrocode}
+%   If there was a file replacement, show that as well:
+%    \begin{macrocode}
+        \str_if_eq:NNF \CurrentFileUsed \CurrentFile
+          { ~ ( \CurrentFile \space requested ) }
+        \iow_newline:
+      }
+    \str_if_eq:nnT {#1} {STOP} { \int_gdecr:N \g_@@_nesting_level_int }
+  }
+%    \end{macrocode}
+%
+%   Now just hook the macro above in the generic |file/before|\ldots
+%    \begin{macrocode}
+\AddToHook{file/before}{ \@@_log_file_record:n { START } }
+%    \end{macrocode}
+%   \ldots and |file/after| hooks.
+%   We don't want to install the \hook{file/after} hook immediately,
+%   because that would mean it is the first time executed when the
+%   package finishes. We therefore put the declaration inside
+%   \cs{AddToHookNext} so that it gets only installed when we have
+%   left this package.
+%    \begin{macrocode}
+\AddToHookNext{file/after}
+  { \AddToHook{file/after}{ \@@_log_file_record:n { STOP } } }
+%    \end{macrocode}
+% \end{macro}
+%
+%    \begin{macrocode}
+%<@@=>
+%</structuredlog>
+%    \end{macrocode}
+%
+%
+%
+%
+%
+%
+% \section{Package emulations}
+%
+%
+% \subsection{Package \pkg{atveryend} emulation}
+%
+%    With the new hook management and the hooks in \cs{enddocument}
+%    all of \pkg{atveryend} is taken care of.
+%    We can make an emulation only here after the substitution
+%    functionality is available:
+%    \begin{macrocode}
+%<*2ekernel>
+\declare at file@substitution{atveryend.sty}{atveryend-ltx.sty}
+%</2ekernel>
+%    \end{macrocode}
+%
+%    Here is the package file we point to:
+%    \begin{macrocode}
+%<*atveryend-ltx>
+\ProvidesPackage{atveryend}
+   [2020/08/19 v1.0a
+     Emulation of the original atvery package^^Jwith kernel methods]
+%    \end{macrocode}
+%
+%
+%    Here are new definitions for its interfaces now pointing to the
+%    hooks in \cs{enddocument}
+%    \begin{macrocode}
+\newcommand\AfterLastShipout  {\AddToHook{enddocument/afterlastpage}}
+\newcommand\AtVeryEndDocument {\AddToHook{enddocument/afteraux}}
+%    \end{macrocode}
+%    Next one is a bit of a fake, but the result should normally be as
+%    expected. If not, one needs to add a rule to sort the code chunks
+%    in \hook{enddocument/info}.
+%    \begin{macrocode}
+\newcommand\AtEndAfterFileList{\AddToHook{enddocument/info}}
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+\newcommand\AtVeryVeryEnd     {\AddToHook{enddocument/end}}
+%    \end{macrocode}
+
+%  \begin{macro}{\BeforeClearDocument}
+%    This one is the only one we don't implement or rather don't have
+%    a dedicated hook in the code. 
+%    \begin{macrocode}
+\ExplSyntaxOn
+\newcommand\BeforeClearDocument[1]
+  { \AtEndDocument{#1}
+    \atveryend at DEPRECATED{BeforeClearDocument \tl_to_str:n{#1}}
+  }
+%    \end{macrocode}
+%    
+%    \begin{macrocode}
+\cs_new:Npn\atveryend at DEPRECATED #1
+   {\iow_term:x{======~DEPRECATED~USAGE~#1~==========}}
+\ExplSyntaxOff
+%    \end{macrocode}
+%  \end{macro}
+%
+%    
+%    \begin{macrocode}
+%</atveryend-ltx>
+%    \end{macrocode}
 %
 %
 % \subsection{Package \pkg{filehook} emulation}
@@ -1257,143 +1397,7 @@
 %    \end{macrocode}
 %
 %
-%
-% \section{A sample package for structuring the log output}
-%
-%    \begin{macrocode}
-%<*structuredlog>
-%<@@=filehook>
-%    \end{macrocode}
-%
-%    \begin{macrocode}
-\ProvidesExplPackage
-    {structuredlog}{\ltfilehookdate}{\ltfilehookversion}
-    {Structuring the TeX transcript file}
-%    \end{macrocode}
-%
-% \begin{macro}{\g_@@_nesting_level_int}
-%   Stores the current package nesting level.
-%    \begin{macrocode}
-\int_new:N \g_@@_nesting_level_int
-%    \end{macrocode}
-%   Initialise the counter with the number of files in the
-%   \cs{@currnamestack} (the number of items divided by $3$) minus one,
-%   because this package is skipped when printing to the log.
-%    \begin{macrocode}
-\int_gset:Nn \g_@@_nesting_level_int
-  { ( \tl_count:N \@currnamestack ) / 3 - 1 }
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_log_file_record:n}
-%   This macro is responsible for increasing and decresing the file
-%   nesting level, as well as printing to the log.  The argument is
-%   either |STOPTART| or |STOP| and the action it takes on the nesting
-%   integer depends on that.
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_log_file_record:n #1
-  {
-    \str_if_eq:nnT {#1} {START} { \int_gincr:N \g_@@_nesting_level_int }
-    \iow_term:x
-      {
-        \prg_replicate:nn { \g_@@_nesting_level_int } { = } ~
-        ( LEVEL ~ \int_use:N \g_@@_nesting_level_int \c_space_tl #1 ) ~
-        \CurrentFileUsed
-%    \end{macrocode}
-%   If there was a file replacement, show that as well:
-%    \begin{macrocode}
-        \str_if_eq:NNF \CurrentFileUsed \CurrentFile
-          { ~ ( \CurrentFile \space requested ) }
-        \iow_newline:
-      }
-    \str_if_eq:nnT {#1} {STOP} { \int_gdecr:N \g_@@_nesting_level_int }
-  }
-%    \end{macrocode}
-%
-%   Now just hook the macro above in the generic |file/before|\ldots
-%    \begin{macrocode}
-\AddToHook{file/before}{ \@@_log_file_record:n { START } }
-%    \end{macrocode}
-%   \ldots and |file/after| hooks.
-%   We don't want to install the \hook{file/after} hook immediately,
-%   because that would mean it is the first time executed when the
-%   package finishes. We therefore put the declaration inside
-%   \cs{AddToHookNext} so that it gets only installed when we have
-%   left this package.
-%    \begin{macrocode}
-\AddToHookNext{file/after}
-  { \AddToHook{file/after}{ \@@_log_file_record:n { STOP } } }
-%    \end{macrocode}
-% \end{macro}
-%
-%    \begin{macrocode}
-%<@@=>
-%</structuredlog>
-%    \end{macrocode}
-
-%
-%
-% \subsection{Package \pkg{atveryend} emulation}
-%
-%    With the new hook management and the hooks in \cs{enddocument}
-%    all of \pkg{atveryend} is taken care of.
-%    We can make an emulation only here after the substitution
-%    functionality is available:
-%    \begin{macrocode}
-%<*2ekernel>
-\declare at file@substitution{atveryend.sty}{atveryend-ltx.sty}
-%</2ekernel>
-%    \end{macrocode}
-%
-%    Here is the package file we point to:
-%    \begin{macrocode}
-%<*atveryend-ltx>
-\ProvidesPackage{atveryend}
-   [2020/08/19 v1.0a
-     Emulation of the original atvery package^^Jwith kernel methods]
-%    \end{macrocode}
-%
-%
-%    Here are new definitions for its interfaces now pointing to the
-%    hooks in \cs{enddocument}
-%    \begin{macrocode}
-\newcommand\AfterLastShipout  {\AddToHook{enddocument/afterlastpage}}
-\newcommand\AtVeryEndDocument {\AddToHook{enddocument/afteraux}}
-%    \end{macrocode}
-%    Next one is a bit of a fake, but the result should normally be as
-%    expected. If not, one needs to add a rule to sort the code chunks
-%    in \hook{enddocument/info}.
-%    \begin{macrocode}
-\newcommand\AtEndAfterFileList{\AddToHook{enddocument/info}}
-%    \end{macrocode}
-%    
-%    \begin{macrocode}
-\newcommand\AtVeryVeryEnd     {\AddToHook{enddocument/end}}
-%    \end{macrocode}
 
-%  \begin{macro}{\BeforeClearDocument}
-%    This one is the only one we don't implement or rather don't have
-%    a dedicated hook in the code. 
-%    \begin{macrocode}
-\ExplSyntaxOn
-\newcommand\BeforeClearDocument[1]
-  { \AtEndDocument{#1}
-    \atveryend at DEPRECATED{BeforeClearDocument \tl_to_str:n{#1}}
-  }
-%    \end{macrocode}
-%    
-%    \begin{macrocode}
-\cs_new:Npn\atveryend at DEPRECATED #1
-   {\iow_term:x{======~DEPRECATED~USAGE~#1~==========}}
-\ExplSyntaxOff
-%    \end{macrocode}
-%  \end{macro}
-%
-%    
-%    \begin{macrocode}
-%</atveryend-ltx>
-%    \end{macrocode}
-%
 %    \Finale
 %
 
diff --git a/base/testfiles-lthooks/shipout-006.lvt b/base/testfiles-lthooks/shipout-006.lvt
index 495b9805..0d999aa6 100644
--- a/base/testfiles-lthooks/shipout-006.lvt
+++ b/base/testfiles-lthooks/shipout-006.lvt
@@ -1,15 +1,22 @@
+% gh #152
+
 \documentclass{article}
 
 \input{regression-test}
 
-\usepackage
-    {lthooks}
+\START
 
+%\DebugHooksOn
 
 \AddToHook {shipout/background}{\put(0,0){x}}
 \AddToHook {begindocument}{blub\clearpage} %fails
 %\AddToHook {begindocument/end}{blub\clearpage} %works
+
+\OMIT
 \begin{document}
+\TIMO
+
 abc
-\typeout{There should be no error and no log output}
-\end{document}
+\typeout{-- There should be no error and no log output other than this line --}
+
+\END
diff --git a/base/testfiles-lthooks/shipout-006.tlg b/base/testfiles-lthooks/shipout-006.tlg
index e69de29b..944f14ef 100644
--- a/base/testfiles-lthooks/shipout-006.tlg
+++ b/base/testfiles-lthooks/shipout-006.tlg
@@ -0,0 +1,3 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+-- There should be no error and no log output other than this line --





More information about the latex3-commits mailing list.