[latex3-commits] [git/LaTeX3-latex3-latex2e] doc-v3beta: getting rid of kvoptions (thanks ulrike) -- need some code cleanup, but for starters it looks fine (623a3773)
Frank Mittelbach
frank.mittelbach at latex-project.org
Tue Nov 16 22:18:36 CET 2021
Repository : https://github.com/latex3/latex2e
On branch : doc-v3beta
Link : https://github.com/latex3/latex2e/commit/623a37739f2edb9ac72d3a7df6002c2002870248
>---------------------------------------------------------------
commit 623a37739f2edb9ac72d3a7df6002c2002870248
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Tue Nov 16 22:18:36 2021 +0100
getting rid of kvoptions (thanks ulrike) -- need some code cleanup, but for starters it looks fine
>---------------------------------------------------------------
623a37739f2edb9ac72d3a7df6002c2002870248
base/changes.txt | 2 +-
base/doc.dtx | 141 +++++++++++++++++++++++++++++++++++++++----------------
2 files changed, 102 insertions(+), 41 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 55ef8920..6191e1db 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -12,7 +12,7 @@ are not part of the distribution.
The old doc can be reactivated with \usepackage{doc}[=v2].
Hyperref usage (on by default) can be turned off with
\usepackage[hyperref=false]{doc}.
- New options etc are documented: use texdoc doc-doc
+ New options etc are documented: use texdoc doc
(code documentation only partly done).
2021-11-12 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
diff --git a/base/doc.dtx b/base/doc.dtx
index ee48e779..3c4cea3b 100644
--- a/base/doc.dtx
+++ b/base/doc.dtx
@@ -224,10 +224,10 @@
%
%\NewDocElement[macrolike = false ,
% toplevel = false,
-% idxtype = key ,
-% idxgroup = Package keys ,
-% printtype = \textit{key}
-% ]{Key}{key}
+% idxtype = option ,
+% idxgroup = Package options ,
+% printtype = \textit{option}
+% ]{Option}{option}
%
% \renewcommand\code[1]{\mbox{$\ell$-#1}}
% \renewcommand\main[1]{\underline{\mbox{$\ell$-#1}}}
@@ -420,11 +420,11 @@
% \NewIn{v3}
% Starting with version~3 the \DOC package now offers a small number
% of package options to modify its overall behavior. These are:
-% \DescribeKey[noprint]{multicol}
-% \DescribeKey[noprint]{hyperref}
-% \DescribeKey[noprint]{debugshow}
-% \DescribeKey[noprint]{noindex}
-% \DescribeKey[noprint]{noprint}
+% \DescribeOption[noprint]{multicol}
+% \DescribeOption[noprint]{hyperref}
+% \DescribeOption[noprint]{debugshow}
+% \DescribeOption[noprint]{noindex}
+% \DescribeOption[noprint]{noprint}
% \begin{description}
% \item[\opt{hyperref}] Boolean (default \texttt{true}). Load the
% \pkg{hyperref} package and make index references to code lines
@@ -698,13 +698,13 @@
% |\NewDocElement{Env}{environment}|
% though that's not quite what has been done, as we will see later.
%
-% \DescribeKey[noprint]{macrolike}
-% \DescribeKey[noprint]{envlike}
-% \DescribeKey[noprint]{toplevel}
-% \DescribeKey[noprint]{notoplevel}
-% \DescribeKey[noprint]{idxtype}
-% \DescribeKey[noprint]{printtype}
-% \DescribeKey[noprint]{idxgroup}
+% \DescribeOption[noprint]{macrolike}
+% \DescribeOption[noprint]{envlike}
+% \DescribeOption[noprint]{toplevel}
+% \DescribeOption[noprint]{notoplevel}
+% \DescribeOption[noprint]{idxtype}
+% \DescribeOption[noprint]{printtype}
+% \DescribeOption[noprint]{idxgroup}
% The \meta{options} are keyword/value and define further details on
% how that \DOC element should behave. They are:
% \begin{description}
@@ -1907,48 +1907,106 @@
%
% \subsection{Keys supported by \DOC{}}
%
-% For historical reasons this uses \pkg{kvoptions} but this will be
+% In the past this used \pkg{kvoptions} but this will be
% replaced by using \texttt{l3keys} at some point in the future.
-% \fmi{replace kvoptions}
+% Right now this is only a lightweight shift---the code could and
+% should be altered further.
+% \fmi{cleanup replacement of kvoptions}
%
% \begin{macrocode}
-\RequirePackage{kvoptions}
-\SetupKeyvalOptions{family=doc,prefix=doc@}
+\RequirePackage{l3keys2e}
+\ExplSyntaxOn
% \end{macrocode}
% These two options are available for use in \cs{usepackage} or in the
% generated item \api's:
-% \begin{macrocode}
-\DeclareBoolOption{noprint}
-\DeclareBoolOption{noindex}
-\DeclareBoolOption[true]{hyperref}
-\DeclareBoolOption[true]{multicol}
-\DeclareBoolOption[false]{debugshow}
+% \fmi{cleanup documentation (and perhaps code)}
+% \begin{macrocode}
+\newif \ifdoc at noprint
+\newif \ifdoc at noindex
+\newif \ifdoc at hyperref \doc at hyperreftrue
+\newif \ifdoc at multicol \doc at multicoltrue
+\newif \ifdoc at debugshow
+\keys_define:nn {doc}
+ {
+ noprint .choice:,
+ noprint / true .code:n = { \legacy_if_set_true:n { doc at noprint } },
+ noprint / false .code:n = { \legacy_if_set_false:n { doc at noprint } },
+ noprint .default:n = { true },
+ noindex .choice:,
+ noindex / true .code:n = { \legacy_if_set_true:n { doc at noindex } },
+ noindex / false .code:n = { \legacy_if_set_false:n { doc at noindex } },
+ noindex .default:n = { true },
+ hyperref .choice:,
+ hyperref / true .code:n = { \legacy_if_set_true:n { doc at hyperref } },
+ hyperref / false .code:n = { \legacy_if_set_false:n { doc at hyperref } },
+ hyperref .default:n = { true },
+ multicol .choice:,
+ multicol / true .code:n = { \legacy_if_set_true:n { doc at multicol } },
+ multicol / false .code:n = { \legacy_if_set_false:n { doc at multicol } },
+ multicol .default:n = { true },
+ debugshow .choice:,
+ debugshow / true .code:n = { \legacy_if_set_true:n { doc at debugshow } },
+ debugshow / false .code:n = { \legacy_if_set_false:n { doc at debugshow } },
+ debugshow .default:n = { true },
+ }
% \end{macrocode}
% This one is for \cs{usepackage} and \cs{NewDocElement}:
% \begin{macrocode}
-\DeclareBoolOption[true]{toplevel}
-\DeclareComplementaryOption{notoplevel}{toplevel}
+\newif \ifdoc at toplevel \doc at topleveltrue
+\keys_define:nn {doc}
+ {
+ toplevel .choice:,
+ toplevel / true .code:n = { \legacy_if_set_true:n { doc at toplevel } },
+ toplevel / false .code:n = { \legacy_if_set_false:n { doc at toplevel } },
+ toplevel .default:n = { true },
+ notoplevel .choice:,
+ notoplevel / true .code:n = { \legacy_if_set_false:n { doc at toplevel } },
+ notoplevel / false .code:n = { \legacy_if_set_true:n { doc at toplevel } },
+ notoplevel .default:n = { true }
+ }
% \end{macrocode}
% These are for \cs{NewDocElement}:
% \begin{macrocode}
-\DeclareBoolOption{macrolike}
-\DeclareComplementaryOption{envlike}{macrolike}
-\DeclareStringOption{idxtype}
-\DeclareStringOption{idxgroup}
-\DeclareStringOption{printtype}
+\newif \ifdoc at macrolike
+\keys_define:nn {doc}
+ {
+ macrolike .choice:,
+ macrolike / true .code:n = { \legacy_if_set_true:n { doc at macrolike } },
+ macrolike / false .code:n = { \legacy_if_set_false:n { doc at macrolike } },
+ macrolike .default:n = { true },
+ envlike .choice:,
+ envlike / true .code:n = { \legacy_if_set_false:n { doc at macrolike } },
+ envlike / false .code:n = { \legacy_if_set_true:n { doc at macrolike } },
+ envlike .default:n = { true }
+ }
+
+\keys_define:nn { doc }
+ {
+ idxtype .tl_set:N = \doc at idxtype,
+ idxgroup .tl_set:N = \doc at idxgroup,
+ printtype .tl_set:N = \doc at printtype
+ }
% \end{macrocode}
% And this one only for instances of doc elements in the document, it
% covers the case where you want to document a macro which is
% declared to be \cs{outer}. This is not a concept officially
% supported by \LaTeX{} but there are cases when it gets used.
% \begin{macrocode}
-\DeclareBoolOption[false]{outer}
+\newif\ifdoc at outer
+\keys_define:nn {doc}
+ {
+ outer .choice:,
+ outer / true .code:n = { \legacy_if_set_true:n { doc at outer } },
+ outer / false .code:n = { \legacy_if_set_false:n { doc at outer } },
+ outer .default:n = { true },
+ }
+\ExplSyntaxOff
% \end{macrocode}
%
% \subsection{Processing the package keys}
%
% \begin{macrocode}
-\ProcessKeyvalOptions*
+\ProcessKeysOptions {doc}
% \end{macrocode}
%
%
@@ -1971,7 +2029,8 @@
% can locally set them.
% \begin{macrocode}
\def\SetupDoc#1{%
- \setkeys{doc}{#1}%
+% missing 2e interface
+ \csname keys_set:nn\endcsname{doc}{#1}%
\edef\doc at noprintdefault{\ifdoc at noprint true\else false\fi}%
\ifdoc at noindex
% \end{macrocode}
@@ -5689,7 +5748,8 @@
\def\doc at env#1#2[#3]{%
\@nameuse{doc at noprint\doc at noprintdefault}%
\@nameuse{doc at noindex\doc at noindexdefault}%
- \setkeys{doc}{#3}%
+% missing 2e interface
+ \csname keys_set:nn\endcsname{doc}{#3}%
\begingroup
\ifdoc at outer
\catcode`\\12
@@ -5732,7 +5792,8 @@
% \begin{macrocode}
\def\doc at describe#1[#2]{%
\leavevmode\@bsphack
- \setkeys{doc}{#2}%
+% missing 2e interface
+ \csname keys_set:nn\endcsname{doc}{#2}%
\@doc at describe{#1}}
% \end{macrocode}
% \end{macro}
@@ -6029,7 +6090,8 @@
\def\doc at idxtype{#3}%
\def\doc at idxgroup{#3s}%
\let\doc at printtype\@empty
- \setkeys{doc}{#1}%
+% missing 2e interface
+ \csname keys_set:nn\endcsname{doc}{#1}%
% \end{macrocode}
% \begin{imacro}{\Print...Name}
% \marg{name}
@@ -6212,4 +6274,3 @@
%
%
\endinput
-
More information about the latex3-commits
mailing list.