[latex3-commits] [latex3/latex3] main: Check missing `\endgroup` at the end of `\DocInclude` (2e1ff83cc)
github at latex-project.org
github at latex-project.org
Mon Feb 12 08:34:30 CET 2024
Repository : https://github.com/latex3/latex3
On branch : main
Link : https://github.com/latex3/latex3/commit/2e1ff83cc855275ee13569fa4b4e864b77f46e00
>---------------------------------------------------------------
commit 2e1ff83cc855275ee13569fa4b4e864b77f46e00
Author: Yukai Chou <muzimuzhi at gmail.com>
Date: Mon Feb 12 12:45:09 2024 +0800
Check missing `\endgroup` at the end of `\DocInclude`
This incorporates latex3/latex2e at 60a6a368 (Prevent time wasted debugging
latex3/latex2e at 50f5256, 2021-10-20) by @PhelypeOleinik, with some modification.
>---------------------------------------------------------------
2e1ff83cc855275ee13569fa4b4e864b77f46e00
l3kernel/CHANGELOG.md | 1 +
l3kernel/l3doc.dtx | 23 +++++++++++++++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index f7230b2f9..68271f7a5 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -18,6 +18,7 @@ this project uses date-based 'snapshot' version identifiers.
### Added
- `\keys_set_exclude_groups:nnn(nN)` to replace `\keys_set_filter:nnn(nN)`
- Flags with N-type names, like other variable types
+- Checking missing `\endgroup` at the end of `\DocInclude`
### Changed
- Set `l3doc` option `kernel` off as-standard (issue \#1403)
diff --git a/l3kernel/l3doc.dtx b/l3kernel/l3doc.dtx
index fde5ddd10..47b0eadbf 100644
--- a/l3kernel/l3doc.dtx
+++ b/l3kernel/l3doc.dtx
@@ -3727,10 +3727,22 @@ and all files in that bundle must be distributed together.
%
% \begin{macro}{\DocInclude}
% More or less exactly the same as \tn{include}, but uses
-% \tn{DocInput} on a \file{.dtx} file, not \tn{input} on a \file{.tex}
-% file.
+% \tn{DocInput} on a \file{.fdd} or \file{.dtx} file (without file
+% extension), not \tn{input} on a \file{.tex} file.
%
% \begin{macrocode}
+\msg_new:nnn { l3doc } { missing-endgroup }
+ {
+ \str_if_eq:VnTF \@currenvir { document }
+ {
+ There~are~\int_use:N \tex_currentgrouplevel:D
+ \c_space_tl unclosed~groups~in~#1.
+ }
+ {
+ The~\@currenvir \c_space_tl environment~on~line~\@currenvline
+ \c_space_tl doesn't~have~a~matching~\iow_char:N\\end{\@currenvir}.
+ }
+ }
\NewDocumentCommand \DocInclude { m }
{
\relax\clearpage
@@ -3741,6 +3753,13 @@ and all files in that bundle must be distributed together.
\int_compare:nNnTF \@auxout = \@partaux
{ \@latexerr{\string\include\space cannot~be~nested}\@eha }
{ \@docinclude {#1} }
+ % check missing \endgroup, e.g., missing "\end{macro}" in time
+ \int_compare:nNnF { \tex_currentgrouplevel:D } = { 0 }
+ {
+ \int_compare:nNnT { \tex_interactionmode:D } = { 0 }
+ { \int_set:Nn \tex_interactionmode:D { 1 } }
+ \msg_fatal:nnn { l3doc } { missing-endgroup } { \currentfile }
+ }
}
% \end{macrocode}
%
More information about the latex3-commits
mailing list.