[latex3-commits] [git/LaTeX3-latex3-latex3] cmd: Rework loading logic (f504988df)
PhelypeOleinik
phelype.oleinik at latex-project.org
Sat Jan 23 20:25:30 CET 2021
Repository : https://github.com/latex3/latex3
On branch : cmd
Link : https://github.com/latex3/latex3/commit/f504988df439eb131f8697d05a8a6c8f5c00ecb4
>---------------------------------------------------------------
commit f504988df439eb131f8697d05a8a6c8f5c00ecb4
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Sat Jan 23 16:25:30 2021 -0300
Rework loading logic
>---------------------------------------------------------------
f504988df439eb131f8697d05a8a6c8f5c00ecb4
l3packages/xparse/xparse.dtx | 80 +++++++++++++++++++++++++++++++-------------
1 file changed, 57 insertions(+), 23 deletions(-)
diff --git a/l3packages/xparse/xparse.dtx b/l3packages/xparse/xparse.dtx
index d0c0af090..506146365 100644
--- a/l3packages/xparse/xparse.dtx
+++ b/l3packages/xparse/xparse.dtx
@@ -969,30 +969,64 @@
%
% \section{\pkg{xparse} implementation}
%
-% Three releases are declared using the rollback mechanism:
-% \begin{description}
-% \item[2018-04-12]
-% contains the full (|package|+|core|) code for \pkg{xparse} as it was
-% before the |core| part was integrated into \LaTeXe. This version
-% should be loaded if \pkg{xparse} is not loaded at all (that is, in
-% \LaTeXe{} older than 2020-10-01);
-% \item[2020-10-01]
-% contains only the deprecated types (|package|) for \pkg{xparse},
-% after the |core| was integrated into \LaTeXe, and a line to load
-% |xparse-generic.tex|.
-% \item[2021-05-01] (or later)
-% contains roughly the same code as |2020-10-01|, except the
-% \pkg{expl3} prefix is now |cmd|, and it doesn't try to load
-% |xparse-generic.tex|. This version is just an extension package for
-% \pkg{ltcmd} in the \LaTeXe{} kernel.
-% \end{description}
-% and one of them is loaded if rolling backwards or forwards.
% \begin{macrocode}
-\providecommand\DeclareRelease[3]{}
-\providecommand\DeclareCurrentRelease[2]{}
-\DeclareRelease{}{2018-04-12}{xparse-2018-04-12.sty}
-\DeclareRelease{}{2020-10-01}{xparse-2020-10-01.sty}
-\DeclareCurrentRelease{}{2021-05-01}
+%<*2ekernel|package>
+% \end{macrocode}
+%
+% This package file, along with the frozen versions in
+% \pkg{xparse-2018-04-12}, \pkg{xparse-2020-10-01}, and
+% |xparse-generic.tex|, is intended to work across different \LaTeX{}
+% releases, respected the minimum \pkg{expl3} version required by
+% \pkg{xparse}.
+%
+% We can't use the \pkg{latexrelease} mechanism with \cs{DeclareRelease}
+% here because cases of rolling forwards or backwards differ, due to the
+% prefix change from |xparse| to |cmd|, so we do our own checks to
+% ensure the right version is loaded.
+%
+% All this loading assumes that if \pkg{latexrelease} should be loaded,
+% it is before \pkg{xparse}. The other way around was not tested at all
+% and is likely to break.
+%
+% In releases prior to 2020-10-01, \cs{NewDocumentCommand} is undefined,
+% so \pkg{xparse} was not loaded, thus we can load the full version from
+% \pkg{xparse-2018-04-12}. Otherwise we will load only the deprecated
+% argument types from \pkg{xparse-2020-10-01}. If we're in |2ekernel|
+% mode, it means rolling forward so load only the code code from
+% |xparse-generic.tex|.
+% \begin{macrocode}
+\providecommand\IfFormatAtLeastTF{\@ifl at t@r\fmtversion}
+\@ifundefined{NewDocumentCommand}
+ {%
+ \IfFormatAtLeastTF{2020/10/01}
+%<2ekernel> {\@@input xparse-generic.tex }
+%<package> {\RequirePackage{xparse-2020-10-01}}
+ {\RequirePackage{xparse-2018-04-12}}
+ \endinput
+ }%
+% \begin{macrocode}
+%
+% In case \cs{NewDocumentCommand} is already defined, we're either in
+% \LaTeX{} 2020-10-01 or later. In the former case, the code loaded in
+% the kernel has the |__xparse| prefix, so we'll load
+% \pkg{xparse-2020-10-01}, otherwise we'll continue in |xparse.sty|,
+% which contains the final remains of \pkg{xparse} with the |__cmd|
+% prefix.
+% \end{macrocode}
+ {%
+ \ifnum
+ \ifdefined\sourceLaTeXdate \sourceLaTeXdate
+ \else \expandafter\@parse at version\fmtversion//00\@nil \fi
+ = \@parse at version 2021-05-01//00\@nil
+ \expandafter\@gobblethree
+ \fi
+ \RequirePackage{xparse-2020-10-01}
+ \endinput
+ }%
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</2ekernel|package>
% \end{macrocode}
%
% In older releases, the prefix was |xparse|, but since the 2021 Spring
More information about the latex3-commits
mailing list.