texlive[65219] Master/texmf-dist: dtxdescribe (7dec22)

commits+karl at tug.org commits+karl at tug.org
Wed Dec 7 22:11:10 CET 2022


Revision: 65219
          http://tug.org/svn/texlive?view=revision&revision=65219
Author:   karl
Date:     2022-12-07 22:11:10 +0100 (Wed, 07 Dec 2022)
Log Message:
-----------
dtxdescribe (7dec22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/dtxdescribe/README.txt
    trunk/Master/texmf-dist/doc/latex/dtxdescribe/dtxdescribe.pdf
    trunk/Master/texmf-dist/source/latex/dtxdescribe/dtxdescribe.dtx
    trunk/Master/texmf-dist/tex/latex/dtxdescribe/dtxdescribe.sty

Modified: trunk/Master/texmf-dist/doc/latex/dtxdescribe/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/dtxdescribe/README.txt	2022-12-07 00:51:17 UTC (rev 65218)
+++ trunk/Master/texmf-dist/doc/latex/dtxdescribe/README.txt	2022-12-07 21:11:10 UTC (rev 65219)
@@ -1,7 +1,7 @@
 The LaTeX dtxdescribe package
 Describe additional object types in dtx source files.
 
-v1.05 — 2022/09/08
+v1.06 — 2022/12/07
 Copyright 2016–2022 Brian Dunn — www.BDTechConcepts.com
 
 LaTeX Project Public License, version 1.3

Modified: trunk/Master/texmf-dist/doc/latex/dtxdescribe/dtxdescribe.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/dtxdescribe/dtxdescribe.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/dtxdescribe/dtxdescribe.dtx	2022-12-07 00:51:17 UTC (rev 65218)
+++ trunk/Master/texmf-dist/source/latex/dtxdescribe/dtxdescribe.dtx	2022-12-07 21:11:10 UTC (rev 65219)
@@ -17,13 +17,13 @@
 % \iffalse
 %<package>\NeedsTeXFormat{LaTeX2e}
 %<package>\ProvidesPackage{dtxdescribe}
-%<package>    [2022/09/08 v1.05 Describe additional object types in source files.]
+%<package>    [2022/12/07 v1.06 Describe additional object types in source files.]
 %
 %<*driver>
 \documentclass{ltxdoc}
 
 \newcommand*{\mypackagename}{dtxdescribe}
-\newcommand{\quicksummary}{Describe additional object types in \texttt{dtx} source files.}
+\newcommand{\quicksummary}{Describe additional object types in \texttt{dtx} or \texttt{tex} source files.}
 
 
 \usepackage{iftex}
@@ -121,23 +121,28 @@
 
 \usepackage{\mypackagename}
 
-\usepackage[bookmarks=true,hidelinks,%
-colorlinks,linkcolor=mylinkcolor,urlcolor=myurlcolor,%
-pageanchor=true,hyperindex=true,
-]{hyperref}
-
+\AtBeginDocument{
 \hypersetup{%
 pdfinfo={%
 Title={The LaTeX \mypackagename\ package},%
 Author={Brian Dunn},%
 Subject={Describe additional object types in dtx source files.]},%
-Keywords={LaTeX, dtx, source, DescribeMacro}%
+Keywords={LaTeX, dtx, source, DescribeMacro},%
+colorlinks,%
+linkcolor=mylinkcolor,%
+urlcolor=myurlcolor,%
+pageanchor=true,
 }}
+}
 
 
+% \crefname here is required to compile the dtxdescribe documentation
+% using the doc class:
+\AddToHook{begindocument/before}{% Before .aux file is loaded.
 \usepackage{cleveref}
+\crefname{dtxexamplefloat}{example}{examples}
+}
 
-
 \renewenvironment{abstract}
     {
         \bigskip
@@ -170,8 +175,11 @@
 %<*package>
 % \fi
 %
-% \CheckSum{1211}
+% ^^A *88* remove:
+% \CheckSum{1704}
 %
+% ^^A *88* remove:
+%
 % \CharacterTable
 % {Upper-case     \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
 %   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -197,6 +205,7 @@
 % \changes{v1.04}{2022/02/01}{\ 2022/02/01}
 % \changes{v1.04}{2022/02/01}{\ Corrected copyright date.}
 % \changes{v1.05}{2022/09/08}{\ 2022/09/08}
+% \changes{v1.06}{2022/12/07}{\ 2022/12/07}
 
 
 
@@ -270,10 +279,19 @@
 %
 % \vfill
 %
+% \textcolor{red}{The \pkg{doc} package has changed, and
+% \pkg{dtxdescribe} is not yet fully compatible.
+% When \pkg{dtxdescribe} is used with \pkg{doc},
+% the optional object ``class'' is currently ignored for macros,
+% and not all classes are indexed.}
+%
+% \textcolor{red}{Also, see change in setup of \pkg{hyperref} and \pkg{cleveref}:
+%       \Cref{sec:usage} on \cpageref{sec:usage}.}
+%
 % \clearpage
 %
 % \tableofcontents
-% \listofdtxdexamples
+% \listofdtxexamplefloats
 % \listoffigures
 % ^^A \listoftables
 %
@@ -318,8 +336,9 @@
 
 % \clearpage
 % \section{Using \pkg{dtxdescribe}}
+% \label{sec:usage}
 
-% Place |\usepackage{dtxdescribe}| in the |.dtx| file's driver section:
+% To use \pkg{dtxdescribe} with the \pkg{ltxdoc} classa and \filenm{.dtx} files:
 % \begin{sourceverb}
 % %<*driver>
 % \documentclass{ltxdoc}
@@ -330,18 +349,50 @@
 % 	...
 % \usepackage{packagename} % the name of your new package
 % 	...
-% \usepackage[...]{hyperref}
-% \usepackage[...]{cleveref}
+%
+% % hyperref now automatically loaded by \pkg{ltxdoc}.
+%
+% \AtBeginDocument{
+%    \hypersetup{...}%                      If needed.
+%    \pdfstringdefDisableCommands{ ... }%   If needed.
+% }
+%
+% \AddToHook{begindocument/before}{% Before .aux file is loaded.
+%   \usepackage{cleveref}%                  If needed.
+%   \crefname{somename}{name}{names}%       If needed.
+% }
+%
 % 	...
 % %</driver>
 % \end{sourceverb}
 
-% Various objects inside the |dtx| file may be described with new
+% To use \pkg{dtxdescribe} with the regular classes, such as \pkg{article},
+% use:
+%
+% \begin{sourceverb}
+% \documentclass{article}
+%
+% \usepackage{dtxdescribe}
+% 
+% \usepackage{hyperref}%                    If needed.
+%    \hypersetup{...}%                      If needed.
+%    \pdfstringdefDisableCommands{ ... }%   If needed.
+% 
+% \usepackage{cleveref}%                    If needed.
+%   \crefname{somename}{name}{names}%       If needed.
+%
+% \begin{document}
+% ...
+% \end{document}
+% \end{sourceverb}
+
+
+% Various objects inside the |dtx| or |tex| file may be described with new
 % macros such as \cs{DescribeBoolean}, \cs{DescribeLength}, \cs{DescribeCounter},
 % similar to the already-familiar \cs{DescribeMacro} and \cs{DescribeEnv}.
 
-% Optional ``classes'' may be assigned to the objects being described, including the new versions
-% of \cs{DescribeMacro} and \cs{DescribeEnv}.
+% Optional ``classes'' may be assigned to the objects being described,
+% including the new versions of \cs{DescribeMacro} and \cs{DescribeEnv}.
 % These classes are printed in the margin tag and index entry for each item,
 % and also generate additional index entries sorted by class.  This is
 % especially useful for key/value sets, where several sets may appear in the same
@@ -720,7 +771,7 @@
 % code verbatim inside a frame.
 % A label may be included using the \optn{label} key.
 % Because this is a verbatim environment, it \emph{cannot} be used inside a macro.
-% See \cref{ex:fsourceverb} on page \cpageref{ex:fsourceverb}.
+% See \cref{ex:fsourceverb} on \cpageref{ex:fsourceverb}.
 % \bigskip
 %
 % \DescribeEnv{sourcedisplay} Display source code with manual formatting.
@@ -969,13 +1020,13 @@
 % \DescribeMacro{\mymacro} \oarg{optional} \marg{mandatory}
 % 	A typical macro definition.
 %
-% \DescribeMacro[photograph]{\DeclareFloatingEnvironment}
-%	Create a photograph float. \bigskip
+% \DescribeMacro[photograph]{\DeclareFloatingPhoto}
+%	Create a photograph float environment.
 
-% \DescribeMacro[photograph]{\captionsetup}
+% \DescribeMacro[c=photograph]{\photocaptionsetup}
 %	Caption settings for a photograph float.
 
-% \DescribeMacro[photograph]{\cnameref}
+% \DescribeMacro[photograph]{\cphotonameref}
 %	\pkg{cleveref} name for the photograph float.
 % \end{dtxexample}
 %
@@ -1102,7 +1153,7 @@
 % \DescribeArgument[figure]{[M]}
 % What happens when a figure is in the [M]argin.
 %
-% \DescribeArgument[\cs{mymacro}]{bold}
+% \DescribeArgument[\mymacro]{bold}
 % What happens when \cs{mymacro} is given the |bold| argument.
 % \end{dtxexample}
 %
@@ -1110,7 +1161,7 @@
 % identify their macro or environment, and group their entries
 % in the index.
 %
-% Note the need to use |\cs{mymacro}| for the macro's name.
+% Note you may need to use |\cs{mymacro}| for the macro's name.
 % \watchout[macro names]
 %
 %
@@ -1133,7 +1184,7 @@
 % \DescribeOther{license agreement}
 %	The following is the fictional license agreement:
 %
-% \DescribeOther{Before \env{myenvironment}}
+% \DescribeOther{Before myenvironment}
 % 	Actions to be done \cs{BeforeBeginEnvironment}.
 %
 % \DescribeOther[otherclass]{Other Item} About the other item.
@@ -1213,7 +1264,7 @@
 %
 % When the example was created:
 % \begin{enumerate}
-% \item The ``float'' of type |example| was created,
+% \item The ``float'' of type |dtxexamplefloat| was created,
 %	with the caption ``|dtxexample|''
 %	and the label |ex:dtxexample|, which points to \cref{ex:dtxexample}.
 % \item The code was displayed verbatim.
@@ -1349,14 +1400,12 @@
 
 
 
-
-
 % \clearpage
 
 % \StopEventually{\PrintChanges\PrintIndex}
  
 
-
+% ^^A *source
 % \section{Code}
 
 
@@ -1483,11 +1532,11 @@
             \def\LOF{LOF}%
             \def\LOT{LOT}%
         }
-    }
+    }% yes hyperref
 %    \end{macrocode}
 % If \pkg{hyperref} is not loaded, emulate \cs{hyperpage} here.
 %    \begin{macrocode}
-    {
+    {% no hyperref
         \newcommand*{\hyperpage}[1]{#1}
     }
 }
@@ -1518,7 +1567,12 @@
 \setlength{\unitlength}{1pt}
 %    \end{macrocode}
 
+
+
+% \subsection{Warning sign}
+
 % \begin{macro}{\warningsign} Prints an exclamation point inside a triangle.
+%   Displays as: \warningsign
 %
 % Creates a warning sign without relying on the presence of the fourier font.
 % During copy/paste, this shows up as a simple exclamation point.
@@ -1535,6 +1589,77 @@
 % \end{macro}
 
 
+% \subsection{Special character handling}
+
+% The literal backslash character:
+%    \begin{macrocode}
+\begingroup
+\catcode`\|=0
+\catcode`\\=12
+|gdef|DTXD at backslash{\}
+|endgroup
+%    \end{macrocode}
+
+
+
+% \subsection{Patching \pkg{hypdoc}}
+%
+% If \pkg{hyperref} is disabled (by \pkg{lwarp}) then define the
+% missing \cs{hdclindex}.
+% \changes{v1.06}{2022/12/06}{Fixed for updated \pkg{doc}.}
+%    \begin{macrocode}
+\@ifpackageloaded{doc}{
+\@ifpackageloaded{hypdoc}{
+\AddToHook{begindocument/before}[doc/hyperref]{%
+ \ifdoc at hyperref
+ \else
+  \def\hdclindex#1#2{%
+    \ifx\@nil#2\@nil\else\csname #2\expandafter\endcsname\fi%
+  }%
+ \fi
+}
+}{}% hypdoc loaded
+}{}% doc loaded
+%    \end{macrocode}
+
+% \pkg{splitidx} is modified to add \verb+|hdpindex{}+ to work with \pkg{hypdoc}.
+% \changes{v1.06}{2022/12/06}{Fixed for updated \pkg{doc}.}
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifpackageloaded{hypdoc}{
+\@ifpackageloaded{splitidx}{
+\renewcommand*{\@wrsindex}[2][]{%
+  \ifx\relax#1\relax
+    \if at splitidx
+      \@wrsindex[idx]{#2}%
+    \else
+      \def\@tempa{#2}%
+      \if at verbindex\@onelevel at sanitize\@tempa\fi
+      \@wrindex{\@tempa}%
+    \fi
+  \else
+%
+%    \def\@tempa{#2}%
+    \def\@tempa{#2\encapchar hdpindex{}}%       dtxdescribe
+%
+    \csname index@#1 at hook\endcsname
+    \expandafter\ifx\csname @@wrsindex\endcsname\relax
+      \@@@wrsindex{#1}{{\@tempa}{\thepage}}%
+    \else
+      \def\@tempb{\@@wrsindex{#1}}%
+      \expandafter\@tempb\@tempa||\\%
+    \fi
+    \endgroup
+    \@esphack
+  \fi
+}
+}{}% splitidx loaded
+}{}% hypdoc loaded
+}% AtBeginDocument
+%    \end{macrocode}
+
+
+
 % \subsection{Gobbling comment characters}
 %
 % \begin{macro}{DTXD at gobble}
@@ -1636,8 +1761,8 @@
             }\ensuremath\rangle
         }
         \def\meta at font@select{\itshape}
-    }
-}
+    }% doc loaded
+}% AtBeginDocument
 %    \end{macrocode}
 
 
@@ -1653,7 +1778,6 @@
 % \end{macro}
 
 
-
 %
 % \begin{macro}{\DTXD at printtype} \marg{text}
 %
@@ -1675,8 +1799,12 @@
 %
 % \changes{v1.02}{2019/07/14}{Fix if not \pkg{ltxdoc} class.}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{}{% not doc package
+
 \providecommand{\usage}{}
 \renewcommand{\usage}[1]{\textit{\hyperpage{#1}}}
+
+}% not doc package
 %    \end{macrocode}
 % \end{macro}
 
@@ -1693,7 +1821,7 @@
 %
 % Creates the margin tag for the object being described.
 %
-% The |class| is used to sub-categories keys into their key/value groups.
+% The |class| is used to sub-categorize keys into their key/value groups.
 %
 % \changes{v1.01}{2019/01/20}{Put margin tag class in brackets.}
 % \changes{v1.03}{2022/01/08}{Reduce hbox warnings.}
@@ -1753,6 +1881,7 @@
 \begingroup%
 \DTXD at origwrindex{%
 %    \end{macrocode}
+%
 % Index by name:
 %
 % Write the name, the formatted name, the index tag, and the class:
@@ -1759,9 +1888,10 @@
 %    \begin{macrocode}
 #2\actualchar{\protect\ttfamily#2} % name
 (#4)% index tag
-\ifblank{#1}{}{ [#1]}% class
+\ifblank{#1}{}{ [#1]}%
 \encapchar #5}%
 %    \end{macrocode}
+%
 % Index by tag and class:
 %
 % Write the tag and class as a group, under which is the name and the formatted name.
@@ -1770,10 +1900,11 @@
 \begingroup%
 \DTXD at origwrindex{%
 #4:\levelchar% index tag
-\ifblank{#1}{}{[#1]:\levelchar}% class
+\ifblank{#1}{}{[#1]:\levelchar}%
 #2\actualchar{\protect\ttfamily#2}% name
 \encapchar #5}%
 %    \end{macrocode}
+%
 % Possibly index by class and name:
 %    \begin{macrocode}
 \ifblank{#1}{}{% class given
@@ -1800,10 +1931,12 @@
 \newcommand*{\DTXD at margintagindex}[5]{%
 % \@bsphack%
 %    \end{macrocode}
+%
 % The margin tag and the name:
 %    \begin{macrocode}
 \DTXD at margintag{#1}{#2}{#3}%
 %    \end{macrocode}
+%
 % The index entries:
 %    \begin{macrocode}
 \DTXD at index{#1}{#2}{#3}{#4}{#5}%
@@ -1851,6 +1984,7 @@
 \newcommand*{\DTXD at cmdmargintagindex}[5]{%
 \@bsphack%
 %    \end{macrocode}
+%
 % Create a margin tag with the name of the macro:
 % \changes{v1.03}{2022/01/08}{Reduce hbox warnings.}
 %    \begin{macrocode}
@@ -1883,6 +2017,7 @@
 (#4)% index tag
 \encapchar #5}%
 %    \end{macrocode}
+%
 % Create an index entry grouped by the tag,
 %	then printed and sorted by the macro name with the backslash, and the tag.
 %
@@ -1903,6 +2038,267 @@
 %
 
 
+% \subsection{Key handling for object classes}
+
+% If using \pkg{doc}, the optional key \Slash value argument may also
+% include an object class.  This is supported by assigning any unknown
+% key to be the class.
+%
+% \changes{v1.06}{2022/12/06}{Fixed for updated \pkg{doc}.}
+%    \begin{macrocode}
+\ExplSyntaxOn
+\IfPackageLoadedTF{doc}{
+
+\newcommand*{\DTXD at category}{}
+
+\keys_define:nn {doc}
+{
+    c .cs_set:Np = \DTXD at category,
+    unknown .code:n = {%
+        \renewcommand*{\DTXD at category}{\l_keys_key_str}%
+    },
+}
+
+}{}% doc loaded
+\ExplSyntaxOff
+%    \end{macrocode}
+
+
+% \subsection{Handling \cs{marginpar} inside a float}
+
+% To avoid a floats lost error, do not print margin tags if inside a float.
+% \changes{v1.06}{2022/12/06}{Fixed for updated \pkg{doc}.}
+%    \begin{macrocode}
+\def\@doc at describe#1#2{%                    dtxdescribe
+    \ifdoc at noprint\else
+      \@ifundefined{@captype}{% not float?  dtxdescribe
+          \marginpar{\raggedleft
+                     \strut
+                     \doc at providetarget
+                     \@nameuse{PrintDescribe#1}{#2}%
+                \ifdefvoid{\DTXD at category}{}{%  dtxdescribe
+                    \space{\footnotesize[\mbox{\DTXD at category}]}%
+                }%
+          }
+      }{}%
+    \fi
+    \ifdoc at noindex\else
+      \@nameuse{Special#1Index}{#2}%
+    \fi
+  \@esphack
+  \endgroup
+  \ignorespaces}
+%    \end{macrocode}
+
+
+
+% \subsection{Handling glossary}
+
+% Fix for \cs{StopEventually} in some conditions:
+% \changes{v1.06}{2022/12/06}{Fixed for updated \pkg{doc}.}
+%    \begin{macrocode}
+\AtBeginDocument{
+\def\HD at guesstoclevel#1{1}
+}
+%    \end{macrocode}
+
+
+% \subsection{Catcode handling to support underscores}
+%
+% File names and such may include underscores, so they must be neutralized
+% before processing.
+%
+% \changes{v1.06}{2022/12/06}{Fixed for updated \pkg{doc}.}
+%    \begin{macrocode}
+\IfPackageLoadedTF{doc}{%
+
+\def\@NewDocElement#1#2#3{%
+  \doc at macrolikefalse
+  \doc at topleveltrue
+  \def\doc at idxtype{#3}%
+  \def\doc at idxgroup{#3s}%
+  \let\doc at printtype\@empty
+  \csname keys_set:nn\endcsname{doc}{#1}%
+  \ifx\doc at printtype\@empty
+    \@temptokena{}%
+  \else
+    \@temptokena\expandafter{\expandafter
+         \textnormal\expandafter{\expandafter
+         \space\expandafter
+         (\doc at printtype)}}%
+  \fi
+  \@nameedef{Print#2Name}##1{%
+     {\noexpand\MacroFont
+      \ifdoc at macrolike
+         \noexpand\string##1%                           dtxdescribe
+      \else
+         \noexpand\detokenize\expandafter{##1}%         dtxdescribe
+      \fi
+      \the\@temptokena
+     }}%
+  \expandafter\let\csname PrintDescribe#2\expandafter\endcsname
+                  \csname Print#2Name\endcsname
+  \edef\doc at expr{%
+     \ifdoc at macrolike
+       \noexpand\doc at createspecialmacrolikeindexes
+     \else
+       \noexpand\doc at createspecialindexes
+     \fi
+     {#2}%
+    }%
+   \expandafter\expandafter\expandafter
+   \doc at expr
+   \expandafter\expandafter\expandafter
+     {\expandafter\doc at idxtype\expandafter}\expandafter
+     {\doc at idxgroup}%
+  \doc at createdescribe{#2}%
+    \ifdoc at macrolike
+      \doc at createenv{TT}{#2}{#3}%
+    \else
+      \doc at createenv{TF}{#2}{#3}%
+    \fi
+}
+
+\newcommand*{\DTXD at maybecategory}{%
+    \ifdefvoid{\DTXD at category}%
+        {}%
+        {\space[%
+            \string\verb%
+            \verbatimchar\DTXD at category\verbatimchar%
+        ]}%
+}
+
+\newcommand*{\DTXD at macrotocsname}[1]{%
+  \ifcat\relax\noexpand#1%
+    \expandafter\expandafter\expandafter\@gobble\expandafter\string
+  \fi
+  #1%
+}
+
+\newcommand*{\DTXD at categorylevelname}
+
+\newcommand*{\DTXD at maybecategorylevel}[1]{%
+    \ifdefvoid{\DTXD at categorylevelname}%
+        {}
+        {%
+            \index{%
+                \DTXD at categorylevelname%
+                \noexpand\actualchar%
+                \string\verb*% %
+                \noexpand\verbatimchar
+                [\DTXD at category]:%
+                \verbatimchar%
+                \noexpand\levelchar%
+\@gtempa\noexpand\actualchar%
+\string\verb% % to fool emacs highlighting
+\noexpand\quotechar%
+%*
+\noexpand\verbatimchar%
+%\noexpand\bslash
+\@gtempa\noexpand\verbatimchar%
+    \ifx\@nil#1\@nil\else \the\@temptokena \fi
+           \noexpand\doc at handleencap{usage}                
+            }%
+        }%
+}
+
+
+\newcommand*{\DTXD at findcategorylevelname}{%
+    \edef\DTXD at categorylevelname{\DTXD at category}%
+    \edef\DTXD at categorylevelname{\detokenize\expandafter{\DTXD at categorylevelname}}%
+    \IfBeginWith{\DTXD at categorylevelname}{\DTXD at backslash}
+        {\StrGobbleLeft{\DTXD at categorylevelname}{1}[\DTXD at categorylevelname]}
+        {}
+}
+
+\def\doc at createspecialindexes#1#2#3{%
+  \@temptokena{\space (#2)}%
+  \@temptokenb{#3:}%
+  \@nameedef{SpecialMain#1Index}##1{%
+    \noexpand\@SpecialIndexHelper@##1\noexpand\@nil%        dtxdescribe
+    \noexpand\@bsphack
+    \noexpand\DTXD at findcategorylevelname%                   dtxdescribe
+  \ifdoc at toplevel
+%    \noexpand\special at index{##1\noexpand\actualchar
+%
+%
+    \noexpand\special at index{\noexpand\@gtempa\noexpand\actualchar%
+%    {\string\ttfamily\space##1}%
+\string\verb% % to fool emacs highlighting%                 dtxdescribe
+\noexpand\quotechar%
+%*
+\noexpand\verbatimchar%                                     dtxdescribe
+%\noexpand\bslash
+\noexpand\@gtempa\noexpand\verbatimchar%                    dtxdescribe
+    \ifx\@nil#2\@nil\else \the\@temptokena \fi
+    \noexpand\DTXD at maybecategory%                           dtxdescribe
+    \noexpand\encapchar main}%
+    \noexpand\DTXD at maybecategorylevel{#2}%                  dtxdescribe
+  \fi
+%
+%
+  \ifx\@nil#3\@nil\else
+    \noexpand\special at index{\the\@temptokenb\noexpand\levelchar%
+%      ##1\noexpand\actualchar{\string\ttfamily\space##1}%
+\noexpand\@gtempa\noexpand\actualchar%                      dtxdescribe
+\string\verb% % to fool emacs highlighting%                 dtxdescribe
+\noexpand\quotechar%
+%*
+\noexpand\verbatimchar%                                     dtxdescribe
+%\noexpand\bslash
+\noexpand\@gtempa\noexpand\verbatimchar%                    dtxdescribe
+    \noexpand\DTXD at maybecategory%                           dtxdescribe
+      \noexpand\encapchar main}%
+    \noexpand\DTXD at maybecategorylevel{#2}%                  dtxdescribe
+  \fi
+    \noexpand\@esphack}%
+%
+%
+  \@nameedef{Special#1Index}##1{%
+    \noexpand\@SpecialIndexHelper@##1\noexpand\@nil%        dtxdescribe
+    \noexpand\@bsphack
+    \noexpand\DTXD at findcategorylevelname%                   dtxdescribe
+%
+%
+  \ifdoc at toplevel
+    \noexpand\doc at providetarget
+%    \noexpand\index{##1\noexpand\actualchar{\string\ttfamily\space##1}%
+      \noexpand\index{\noexpand\@gtempa\noexpand\actualchar%    dtxdescribe
+\string\verb% % to fool emacs highlighting%                 dtxdescribe
+\noexpand\quotechar%
+%*
+\noexpand\verbatimchar%                                     dtxdescribe
+%\noexpand\bslash
+\noexpand\@gtempa\noexpand\verbatimchar%                    dtxdescribe
+    \ifx\@nil#2\@nil\else \the\@temptokena \fi
+    \noexpand\DTXD at maybecategory%                           dtxdescribe
+           \noexpand\doc at handleencap{usage}}%
+    \noexpand\DTXD at maybecategorylevel{#2}%                  dtxdescribe
+  \fi
+%
+%
+  \ifx\@nil#3\@nil\else
+    \noexpand\index{\the\@temptokenb\noexpand\levelchar%
+%       ##1\noexpand\actualchar{\string\ttfamily\space##1}
+\noexpand\@gtempa\noexpand\actualchar%                      dtxdescribe
+\string\verb% % to fool emacs highlighting%                 dtxdescribe
+\noexpand\quotechar
+%*
+\noexpand\verbatimchar%                                     dtxdescribe
+%\noexpand\bslash
+\noexpand\@gtempa\noexpand\verbatimchar%                    dtxdescribe    
+    \noexpand\DTXD at maybecategory%                           dtxdescribe
+           \noexpand\doc at handleencap{usage}}%
+    \noexpand\DTXD at maybecategorylevel{#2}%                  dtxdescribe
+  \fi
+%
+%
+    \noexpand\@esphack}}
+
+}{}% doc loaded
+%    \end{macrocode}
+
+
 % \subsection{\cs{DescribeMacro} and \cs{DescribeEnvironment}}
 
 % \begin{macro}{\DescribeMacro} \oarg{class} \marg{\cs{name}}
@@ -1914,6 +2310,9 @@
 % \changes{v1.02}{2019/07/14}{Fix if not \pkg{ltxdoc} class.}
 % \changes{v1.03}{2022/01/08}{Reduce hbox warnings.}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{
+}{% not doc
+
 \providecommand*{\DescribeMacro}{}
 \renewcommand*{\DescribeMacro}[2][]{%
 \@bsphack%
@@ -1965,6 +2364,8 @@
 \@esphack%
 \ignorespaces%
 }
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 
@@ -1975,9 +2376,13 @@
 % Redefined to allow hyperlinked index entries:
 % \changes{v1.02}{2019/07/14}{Fix if not \pkg{ltxdoc} class.}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{}{% not doc
+
 \providecommand*{\DescribeEnv}{}
 \renewcommand*{\DescribeEnv}[2][]
 	{\DTXD at margintagindex{#1}{#2}{Env}{environment}{usage}}
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 
@@ -2008,8 +2413,7 @@
 % \dots\ then replace any underscores with a detokenized |\_|,
 % which will print as an underscore when read back from the index file:
 %    \begin{macrocode}
-\StrSubstitute{\DTXD at filename}%
-{\detokenize{_}}{\detokenize{\_}}[\DTXD at filename]%
+\StrSubstitute{\DTXD at filename}{\detokenize{_}}{\detokenize{\_}}[\DTXD at filename]%
 %    \end{macrocode}
 % The original filename is printed in the margin.
 % Any underscore characters have already been disabled
@@ -2049,9 +2453,23 @@
 % The underscore character is temporarily disabled, then
 % the name is passed directly to \cs{DTXD at DescribeFile}.
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=file,
+    idxgroup=Files,
+    printtype=\textit{file}
+]{File}{file}
+
+}{% not doc
+
 \newcommand*{\DescribeFile}{%
-\begingroup\catcode`\_=12 \DTXD at DescribeFile%
+    \begingroup\catcode`\_=12 \DTXD at DescribeFile%
 }
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2072,9 +2490,23 @@
 % The underscore character is temporarily disabled, then
 % the name is passed directly to \cs{DTXD at DescribeProgram}.
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=program,
+    idxgroup=Programs,
+    printtype=\textit{Prog}
+]{Program}{program}
+
+}{% not doc
+
 \newcommand*{\DescribeProgram}{%
 \begingroup\catcode`\_=12 \DTXD at DescribeProgram%
 }
+}% not doc
+
 %    \end{macrocode}
 % \end{macro}
 
@@ -2095,9 +2527,23 @@
 % The underscore character is temporarily disabled, then
 % the name is passed directly to \cs{DTXD at DescribeCommand}.
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=command,
+    idxgroup=Commands,
+    printtype=\textit{Cmd}
+]{Command}{command}
+
+}{% not doc
+
 \newcommand*{\DescribeCommand}{%
 \begingroup\catcode`\_=12 \DTXD at DescribeCommand%
 }
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2120,9 +2566,24 @@
 %
 % \changes{v1.00}{2019/01/10}{Fix: Allow underscore.}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=package,
+    idxgroup=Packages,
+    printtype=\textit{Pkg}
+]{Package}{package}
+
+}{% not doc
+
 \newcommand*{\DescribePackage}{%
 \begingroup\catcode`\_=12 \DTXD at DescribePackage%
 }
+
+}% not doc
+
 %    \end{macrocode}
 % \end{macro}
 
@@ -2144,16 +2605,44 @@
 %
 % \changes{v1.00}{2019/01/10}{Fix: Allow underscore.}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=class,
+    idxgroup=Classes,
+    printtype=\textit{Cls}
+]{Class}{class}
+
+}{% not doc
+
 \newcommand*{\DescribeClass}{%
 \begingroup\catcode`\_=12 \DTXD at DescribeClass%
 }
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 
 % \begin{macro}{\DescribeOption} \oarg{class} \marg{name}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=option,
+    idxgroup=Options,
+    printtype=\textit{Opt}
+]{Option}{option}
+
+}{% not doc
+
 \newcommand*{\DescribeOption}[2][]
 	{\DTXD at margintagindex{#1}{#2}{Opt}{option}{usage}}
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2161,29 +2650,85 @@
 %
 % The |class| may be used to categorize arguments by their macro or environment name.
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=argument,
+    idxgroup=Arguments,
+    printtype=\textit{Arg}
+]{Argument}{argument}
+
+}{% not doc
+
 \newcommand*{\DescribeArgument}[2][]
 	{\DTXD at margintagindex{#1}{#2}{Arg}{argument}{usage}}
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\DescribeBoolean} \oarg{class} \marg{name}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=boolean,
+    idxgroup=Booleans,
+    printtype=\textit{bool}
+]{Boolean}{boolenv}
+
+}{% not doc
+
 \newcommand*{\DescribeBoolean}[2][]
 	{\DTXD at margintagindex{#1}{#2}{Bool}{boolean}{usage}}
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\DescribeLength} \oarg{class} \marg{name}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=true,
+    toplevel=false,
+    idxtype=length,
+    idxgroup=Lengths,
+    printtype=\textit{Len}
+]{Length}{length}
+
+}{% not doc
+
 \newcommand*{\DescribeLength}[2][]
 	{\DTXD at cmdmargintagindex{#1}{#2}{Len}{length}{usage}}
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\DescribeCounter} \oarg{class} \marg{name}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=counter,
+    idxgroup=Counters,
+    printtype=\textit{Ctr}
+]{Counter}{counter}
+
+}{% not doc
+
 \newcommand*{\DescribeCounter}[2][]
 	{\DTXD at margintagindex{#1}{#2}{Ctr}{counter}{usage}}
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2190,8 +2735,22 @@
 % \begin{macro}{\DescribeHook} \oarg{class} \marg{name}
 % \changes{v1.03}{2021/12/18}{Added.}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=hook,
+    idxgroup=Hooks,
+    printtype=\textit{Hook}
+]{Hook}{hook}
+
+}{% not doc
+
 \newcommand*{\DescribeHook}[2][]
     {\DTXD at margintagindex{#1}{#2}{Hook}{hook}{usage}}
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2200,8 +2759,22 @@
 %
 % The |class| may be used to categorize keys by their kev/value group.
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=key,
+    idxgroup=Keys,
+    printtype=\textit{Key}
+]{Key}{key}
+
+}{% not doc
+
 \newcommand*{\DescribeKey}[2][]
 	{\DTXD at margintagindex{#1}{#2}{Key}{key}{usage}}
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2216,6 +2789,18 @@
 % \changes{v1.02}{2019/07/16}{\cs{raggedleft} margin par.}
 % \changes{v1.03}{2022/01/08}{Reduce hbox warnings.}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=object,
+    idxgroup=Objects,
+    printtype=,
+]{Object}{object}
+
+}{% not doc
+
 \newcommand*{\DescribeObject}[2][]{%
 \@ifundefined{@captype}{% not float?
     \@bsphack%
@@ -2251,6 +2836,8 @@
 \@esphack%
 \ignorespaces%
 }
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2263,6 +2850,18 @@
 % \changes{v1.02}{2019/07/16}{\cs{raggedleft} margin par.}
 % \changes{v1.03}{2022/01/08}{Reduce hbox warnings.}
 %    \begin{macrocode}
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=other,
+    idxgroup=Other,
+    printtype=,
+]{Other}{other}
+
+}{% not doc
+
 \newcommand*{\DescribeOther}[2][]{%
 \@ifundefined{@captype}{% not float?
     \@bsphack%
@@ -2289,6 +2888,8 @@
 \@esphack%
 \ignorespaces%
 }
+
+}% not doc
 %    \end{macrocode}
 % \end{macro}
 
@@ -2625,9 +3226,9 @@
 
 % \subsection{The \env{dtxexample} environment}
 %
-% Also see \cref{ex:dtxexample} on page \cpageref{ex:dtxexample}.
+% Also see \cref{ex:dtxexample} on \cpageref{ex:dtxexample}.
 %
-% \DescribeFile{dtxexample_cut.tex} Used to store then \cs{input} example code.
+% \DescribeFile{dtxexample_cut.tex} Used to store the \cs{input} example code.
 % \changes{v1.00}{2019/01/11}{Cut file name changed to \filenm{dtxexample_cut.tex}}
 %
 % \DescribeObject[color]{DTXD at examplerulecolor} The color of the middle rule in the dtxexample.
@@ -2668,15 +3269,18 @@
 \NewDocumentEnvironment{dtxexample}{s +O{} m}
 {% start dtxexample
 %    \end{macrocode}
+%
 % Copy the environment's contents to the file |dtxexample_cut.tex|:
 %    \begin{macrocode}
 \VerbatimOut[gobble=\DTXD at gobble,tabsize=4]{dtxexample_cut.tex}%
 }% start dtxexample
 %    \end{macrocode}
+%
 % When the environment closes:
 %    \begin{macrocode}
 {% end dtxexample
 %    \end{macrocode}
+%
 % Finish the verbatim output:
 %    \begin{macrocode}
 \endVerbatimOut
@@ -2683,16 +3287,23 @@
 \par
 \addvspace{\bigskipamount}
 %    \end{macrocode}
-% If unstarred, typeset the example in a minipage:
+%
+% If unstarred, typeset the example in a minipage, else use a float:
 %    \begin{macrocode}
-\IfBooleanTF{#1}{\vspace{\bigskipamount}}{\minipage{\linewidth}}%
+\IfBooleanTF{#1}%
+    {% minipage
+        \minipage{\linewidth}%
+        \captionsetup{type=dtxexamplefloat}%
+    }%
+    {% float
+        \begin{dtxexamplefloat}%
+    }%
 %    \end{macrocode}
-% Emulated a float of type ``example'':
 %    \begin{macrocode}
-\captionsetup{type=dtxdexample}%
 \hrule\medskip
 \caption{#3}
 %    \end{macrocode}
+%
 % Typeset the contents as verbatim:
 %    \begin{macrocode}
 \textcolor{DTXD at examplerulecolor}{\smallskip\hrule}
@@ -2705,6 +3316,7 @@
 {\scriptsize\itshape\dtxexampleresultname}
 
 %    \end{macrocode}
+%
 % Possible add the optional cross-references or notes:
 %    \begin{macrocode}
 \ifstrempty{#2}
@@ -2711,9 +3323,12 @@
 {}
 {{\itshape\small #2}}
 %    \end{macrocode}
-% If unstarred, close the \cs{minipage}.
+%
+% If unstarred, close the float or \cs{minipage}.
 %    \begin{macrocode}
-\IfBooleanTF{#1}{}{\endminipage}%
+\IfBooleanTF{#1}%
+    {\endminipage}%
+    {\end{dtxexamplefloat}}%
 } % end dtxexample
 %    \end{macrocode}
 % \end{environment}
@@ -2725,10 +3340,12 @@
 \AfterEndEnvironment{dtxexample}
 {%
 %    \end{macrocode}
+%
 % Execute the code:
 %    \begin{macrocode}
 \par\unskip\input{dtxexample_cut.tex}%
 %    \end{macrocode}
+%
 % Closing rule::
 %    \begin{macrocode}
 \medskip\hrule%
@@ -2736,7 +3353,7 @@
 %    \end{macrocode}
 
 
-% \DescribeMacro[dtxexample]{\DeclareFloatingEnvironment} A new float type for the examples.
+% \DescribeMacro[dtxexamplefloat]{\DeclareFloatingEnvironment} A new float type for the examples.
 %    \begin{macrocode}
 \DeclareFloatingEnvironment[
 fileext=lox,
@@ -2743,13 +3360,13 @@
 listname={List of Examples},
 name=Example,
 placement=hbp
-]{dtxdexample}
+]{dtxexamplefloat}
 %    \end{macrocode}
 
 
-% \DescribeMacro[dtxexample]{\captionsetup} Caption setup for the examples.
+% \DescribeMacro[dtxexamplefloat]{\captionsetup} Caption setup for the examples.
 %    \begin{macrocode}
-\captionsetup*[dtxdexample]{
+\captionsetup*[dtxexamplefloat]{
 format=hang,
 font=bf,
 justification=raggedright,
@@ -2759,10 +3376,13 @@
 }
 %    \end{macrocode}
 
-% \DescribeMacro[dtxexample]{\crefname} Name for \pkg{cleveref}.
+% \DescribeMacro[dtxexamplefloat]{\crefname} Name for \pkg{cleveref}.
+% \cs{crefname} here is required for documents not using the doc class:
 %    \begin{macrocode}
-\AtBeginDocument{
-\@ifpackageloaded{cleveref}{\crefname{dtxdexample}{example}{examples}}{}
+\AddToHook{begindocument/before}{% Before .aux file is loaded.
+    \ifdef{\crefname}{
+        \crefname{dtxexamplefloat}{example}{examples}
+    }{}
 }
 %    \end{macrocode}
 

Modified: trunk/Master/texmf-dist/tex/latex/dtxdescribe/dtxdescribe.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/dtxdescribe/dtxdescribe.sty	2022-12-07 00:51:17 UTC (rev 65218)
+++ trunk/Master/texmf-dist/tex/latex/dtxdescribe/dtxdescribe.sty	2022-12-07 21:11:10 UTC (rev 65219)
@@ -18,7 +18,7 @@
 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{dtxdescribe}
-    [2022/09/08 v1.05 Describe additional object types in source files.]
+    [2022/12/07 v1.06 Describe additional object types in source files.]
 
 
 
@@ -100,6 +100,7 @@
 
 
 
+
 \AtBeginDocument{
     \@ifpackageloaded{makeidx}{}{
     \@ifpackageloaded{splitidx}{}{
@@ -178,8 +179,8 @@
             \def\LOF{LOF}%
             \def\LOT{LOT}%
         }
-    }
-    {
+    }% yes hyperref
+    {% no hyperref
         \newcommand*{\hyperpage}[1]{#1}
     }
 }
@@ -190,6 +191,7 @@
 \RequirePackage{pict2e}
 \setlength{\unitlength}{1pt}
 
+
 \newcommand*{\warningsign}{%
 \begin{picture}(10,9)
 \put(4,1){\scriptsize!}
@@ -199,7 +201,56 @@
 \end{picture}
 }
 
+
+\begingroup
+\catcode`\|=0
+\catcode`\\=12
+|gdef|DTXD at backslash{\}
+|endgroup
+
 \@ifpackageloaded{doc}{
+\@ifpackageloaded{hypdoc}{
+\AddToHook{begindocument/before}[doc/hyperref]{%
+ \ifdoc at hyperref
+ \else
+  \def\hdclindex#1#2{%
+    \ifx\@nil#2\@nil\else\csname #2\expandafter\endcsname\fi%
+  }%
+ \fi
+}
+}{}% hypdoc loaded
+}{}% doc loaded
+
+\AtBeginDocument{
+\@ifpackageloaded{hypdoc}{
+\@ifpackageloaded{splitidx}{
+\renewcommand*{\@wrsindex}[2][]{%
+  \ifx\relax#1\relax
+    \if at splitidx
+      \@wrsindex[idx]{#2}%
+    \else
+      \def\@tempa{#2}%
+      \if at verbindex\@onelevel at sanitize\@tempa\fi
+      \@wrindex{\@tempa}%
+    \fi
+  \else
+    \def\@tempa{#2\encapchar hdpindex{}}%       dtxdescribe
+    \csname index@#1 at hook\endcsname
+    \expandafter\ifx\csname @@wrsindex\endcsname\relax
+      \@@@wrsindex{#1}{{\@tempa}{\thepage}}%
+    \else
+      \def\@tempb{\@@wrsindex{#1}}%
+      \expandafter\@tempb\@tempa||\\%
+    \fi
+    \endgroup
+    \@esphack
+  \fi
+}
+}{}% splitidx loaded
+}{}% hypdoc loaded
+}% AtBeginDocument
+
+\@ifpackageloaded{doc}{
     \newcommand*{\DTXD at gobble}{2}
 }{
     \newcommand*{\DTXD at gobble}{0}
@@ -269,8 +320,8 @@
             }\ensuremath\rangle
         }
         \def\meta at font@select{\itshape}
-    }
-}
+    }% doc loaded
+}% AtBeginDocument
 
 
 \providecommand*{\PrintEnvName}{}
@@ -280,9 +331,13 @@
 \newcommand*{\DTXD at printtype}[1]
 {\raggedleft\strut{\scriptsize\sffamily#1}\quad\MacroFont}
 
+\IfPackageLoadedTF{doc}{}{% not doc package
+
 \providecommand{\usage}{}
 \renewcommand{\usage}[1]{\textit{\hyperpage{#1}}}
 
+}% not doc package
+
 \let\DTXD at origwrindex\@wrindex
 
 \newcommand*{\DTXD at margintag}[3]{%
@@ -308,12 +363,12 @@
 \DTXD at origwrindex{%
 #2\actualchar{\protect\ttfamily#2} % name
 (#4)% index tag
-\ifblank{#1}{}{ [#1]}% class
+\ifblank{#1}{}{ [#1]}%
 \encapchar #5}%
 \begingroup%
 \DTXD at origwrindex{%
 #4:\levelchar% index tag
-\ifblank{#1}{}{[#1]:\levelchar}% class
+\ifblank{#1}{}{[#1]:\levelchar}%
 #2\actualchar{\protect\ttfamily#2}% name
 \encapchar #5}%
 \ifblank{#1}{}{% class given
@@ -373,6 +428,211 @@
 }
 
 
+\ExplSyntaxOn
+\IfPackageLoadedTF{doc}{
+
+\newcommand*{\DTXD at category}{}
+
+\keys_define:nn {doc}
+{
+    c .cs_set:Np = \DTXD at category,
+    unknown .code:n = {%
+        \renewcommand*{\DTXD at category}{\l_keys_key_str}%
+    },
+}
+
+}{}% doc loaded
+\ExplSyntaxOff
+
+
+\def\@doc at describe#1#2{%                    dtxdescribe
+    \ifdoc at noprint\else
+      \@ifundefined{@captype}{% not float?  dtxdescribe
+          \marginpar{\raggedleft
+                     \strut
+                     \doc at providetarget
+                     \@nameuse{PrintDescribe#1}{#2}%
+                \ifdefvoid{\DTXD at category}{}{%  dtxdescribe
+                    \space{\footnotesize[\mbox{\DTXD at category}]}%
+                }%
+          }
+      }{}%
+    \fi
+    \ifdoc at noindex\else
+      \@nameuse{Special#1Index}{#2}%
+    \fi
+  \@esphack
+  \endgroup
+  \ignorespaces}
+
+
+\AtBeginDocument{
+\def\HD at guesstoclevel#1{1}
+}
+
+\IfPackageLoadedTF{doc}{%
+
+\def\@NewDocElement#1#2#3{%
+  \doc at macrolikefalse
+  \doc at topleveltrue
+  \def\doc at idxtype{#3}%
+  \def\doc at idxgroup{#3s}%
+  \let\doc at printtype\@empty
+  \csname keys_set:nn\endcsname{doc}{#1}%
+  \ifx\doc at printtype\@empty
+    \@temptokena{}%
+  \else
+    \@temptokena\expandafter{\expandafter
+         \textnormal\expandafter{\expandafter
+         \space\expandafter
+         (\doc at printtype)}}%
+  \fi
+  \@nameedef{Print#2Name}##1{%
+     {\noexpand\MacroFont
+      \ifdoc at macrolike
+         \noexpand\string##1%                           dtxdescribe
+      \else
+         \noexpand\detokenize\expandafter{##1}%         dtxdescribe
+      \fi
+      \the\@temptokena
+     }}%
+  \expandafter\let\csname PrintDescribe#2\expandafter\endcsname
+                  \csname Print#2Name\endcsname
+  \edef\doc at expr{%
+     \ifdoc at macrolike
+       \noexpand\doc at createspecialmacrolikeindexes
+     \else
+       \noexpand\doc at createspecialindexes
+     \fi
+     {#2}%
+    }%
+   \expandafter\expandafter\expandafter
+   \doc at expr
+   \expandafter\expandafter\expandafter
+     {\expandafter\doc at idxtype\expandafter}\expandafter
+     {\doc at idxgroup}%
+  \doc at createdescribe{#2}%
+    \ifdoc at macrolike
+      \doc at createenv{TT}{#2}{#3}%
+    \else
+      \doc at createenv{TF}{#2}{#3}%
+    \fi
+}
+
+\newcommand*{\DTXD at maybecategory}{%
+    \ifdefvoid{\DTXD at category}%
+        {}%
+        {\space[%
+            \string\verb%
+            \verbatimchar\DTXD at category\verbatimchar%
+        ]}%
+}
+
+\newcommand*{\DTXD at macrotocsname}[1]{%
+  \ifcat\relax\noexpand#1%
+    \expandafter\expandafter\expandafter\@gobble\expandafter\string
+  \fi
+  #1%
+}
+
+\newcommand*{\DTXD at categorylevelname}
+
+\newcommand*{\DTXD at maybecategorylevel}[1]{%
+    \ifdefvoid{\DTXD at categorylevelname}%
+        {}
+        {%
+            \index{%
+                \DTXD at categorylevelname%
+                \noexpand\actualchar%
+                \string\verb*% %
+                \noexpand\verbatimchar
+                [\DTXD at category]:%
+                \verbatimchar%
+                \noexpand\levelchar%
+\@gtempa\noexpand\actualchar%
+\string\verb% % to fool emacs highlighting
+\noexpand\quotechar%
+\noexpand\verbatimchar%
+\@gtempa\noexpand\verbatimchar%
+    \ifx\@nil#1\@nil\else \the\@temptokena \fi
+           \noexpand\doc at handleencap{usage}
+            }%
+        }%
+}
+
+\newcommand*{\DTXD at findcategorylevelname}{%
+    \edef\DTXD at categorylevelname{\DTXD at category}%
+    \edef\DTXD at categorylevelname{\detokenize\expandafter{\DTXD at categorylevelname}}%
+    \IfBeginWith{\DTXD at categorylevelname}{\DTXD at backslash}
+        {\StrGobbleLeft{\DTXD at categorylevelname}{1}[\DTXD at categorylevelname]}
+        {}
+}
+
+\def\doc at createspecialindexes#1#2#3{%
+  \@temptokena{\space (#2)}%
+  \@temptokenb{#3:}%
+  \@nameedef{SpecialMain#1Index}##1{%
+    \noexpand\@SpecialIndexHelper@##1\noexpand\@nil%        dtxdescribe
+    \noexpand\@bsphack
+    \noexpand\DTXD at findcategorylevelname%                   dtxdescribe
+  \ifdoc at toplevel
+    \noexpand\special at index{\noexpand\@gtempa\noexpand\actualchar%
+\string\verb% % to fool emacs highlighting%                 dtxdescribe
+\noexpand\quotechar%
+\noexpand\verbatimchar%                                     dtxdescribe
+\noexpand\@gtempa\noexpand\verbatimchar%                    dtxdescribe
+    \ifx\@nil#2\@nil\else \the\@temptokena \fi
+    \noexpand\DTXD at maybecategory%                           dtxdescribe
+    \noexpand\encapchar main}%
+    \noexpand\DTXD at maybecategorylevel{#2}%                  dtxdescribe
+  \fi
+  \ifx\@nil#3\@nil\else
+    \noexpand\special at index{\the\@temptokenb\noexpand\levelchar%
+\noexpand\@gtempa\noexpand\actualchar%                      dtxdescribe
+\string\verb% % to fool emacs highlighting%                 dtxdescribe
+\noexpand\quotechar%
+\noexpand\verbatimchar%                                     dtxdescribe
+\noexpand\@gtempa\noexpand\verbatimchar%                    dtxdescribe
+    \noexpand\DTXD at maybecategory%                           dtxdescribe
+      \noexpand\encapchar main}%
+    \noexpand\DTXD at maybecategorylevel{#2}%                  dtxdescribe
+  \fi
+    \noexpand\@esphack}%
+  \@nameedef{Special#1Index}##1{%
+    \noexpand\@SpecialIndexHelper@##1\noexpand\@nil%        dtxdescribe
+    \noexpand\@bsphack
+    \noexpand\DTXD at findcategorylevelname%                   dtxdescribe
+  \ifdoc at toplevel
+    \noexpand\doc at providetarget
+      \noexpand\index{\noexpand\@gtempa\noexpand\actualchar%    dtxdescribe
+\string\verb% % to fool emacs highlighting%                 dtxdescribe
+\noexpand\quotechar%
+\noexpand\verbatimchar%                                     dtxdescribe
+\noexpand\@gtempa\noexpand\verbatimchar%                    dtxdescribe
+    \ifx\@nil#2\@nil\else \the\@temptokena \fi
+    \noexpand\DTXD at maybecategory%                           dtxdescribe
+           \noexpand\doc at handleencap{usage}}%
+    \noexpand\DTXD at maybecategorylevel{#2}%                  dtxdescribe
+  \fi
+  \ifx\@nil#3\@nil\else
+    \noexpand\index{\the\@temptokenb\noexpand\levelchar%
+\noexpand\@gtempa\noexpand\actualchar%                      dtxdescribe
+\string\verb% % to fool emacs highlighting%                 dtxdescribe
+\noexpand\quotechar
+\noexpand\verbatimchar%                                     dtxdescribe
+\noexpand\@gtempa\noexpand\verbatimchar%                    dtxdescribe
+    \noexpand\DTXD at maybecategory%                           dtxdescribe
+           \noexpand\doc at handleencap{usage}}%
+    \noexpand\DTXD at maybecategorylevel{#2}%                  dtxdescribe
+  \fi
+    \noexpand\@esphack}}
+
+}{}% doc loaded
+
+
+\IfPackageLoadedTF{doc}{
+}{% not doc
+
 \providecommand*{\DescribeMacro}{}
 \renewcommand*{\DescribeMacro}[2][]{%
 \@bsphack%
@@ -407,17 +667,22 @@
 \ignorespaces%
 }
 
+}% not doc
+
+\IfPackageLoadedTF{doc}{}{% not doc
+
 \providecommand*{\DescribeEnv}{}
 \renewcommand*{\DescribeEnv}[2][]
 {\DTXD at margintagindex{#1}{#2}{Env}{environment}{usage}}
 
+}% not doc
 
+
 \newcommand*{\DTXD at filename}{}
 
 \newcommand*{\DTXD at filemarginparindex}[5]{%
 \renewcommand{\DTXD at filename}{\detokenize{#2}}%
-\StrSubstitute{\DTXD at filename}%
-{\detokenize{_}}{\detokenize{\_}}[\DTXD at filename]%
+\StrSubstitute{\DTXD at filename}{\detokenize{_}}{\detokenize{\_}}[\DTXD at filename]%
 \DTXD at margintag{#1}{#2}{#3}%
 \DTXD at index{#1}{\DTXD at filename}{#3}{#4}{#5}%
 \endgroup%
@@ -426,51 +691,232 @@
 \newcommand*{\DTXD at DescribeFile}[2][]{%
 \DTXD at filemarginparindex{#1}{#2}{File}{file}{usage}%
 }
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=file,
+    idxgroup=Files,
+    printtype=\textit{file}
+]{File}{file}
+
+}{% not doc
+
 \newcommand*{\DescribeFile}{%
-\begingroup\catcode`\_=12 \DTXD at DescribeFile%
+    \begingroup\catcode`\_=12 \DTXD at DescribeFile%
 }
+
+}% not doc
 \newcommand*{\DTXD at DescribeProgram}[2][]{%
 \DTXD at filemarginparindex{#1}{#2}{Prog}{program}{usage}%
 }
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=program,
+    idxgroup=Programs,
+    printtype=\textit{Prog}
+]{Program}{program}
+
+}{% not doc
+
 \newcommand*{\DescribeProgram}{%
 \begingroup\catcode`\_=12 \DTXD at DescribeProgram%
 }
+}% not doc
 
+
 \newcommand*{\DTXD at DescribeCommand}[2][]{%
 \DTXD at filemarginparindex{#1}{#2}{Cmd}{command}{usage}%
 }
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=command,
+    idxgroup=Commands,
+    printtype=\textit{Cmd}
+]{Command}{command}
+
+}{% not doc
+
 \newcommand*{\DescribeCommand}{%
 \begingroup\catcode`\_=12 \DTXD at DescribeCommand%
 }
 
+}% not doc
+
 \newcommand*{\DTXD at DescribePackage}[2][]{%
 \DTXD at filemarginparindex{#1}{#2}{Pkg}{package}{usage}%
 }
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=package,
+    idxgroup=Packages,
+    printtype=\textit{Pkg}
+]{Package}{package}
+
+}{% not doc
+
 \newcommand*{\DescribePackage}{%
 \begingroup\catcode`\_=12 \DTXD at DescribePackage%
 }
 
+}% not doc
+
+
 \newcommand*{\DTXD at DescribeClass}[2][]{%
 \DTXD at filemarginparindex{#1}{#2}{Cls}{class}{usage}%
 }
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=class,
+    idxgroup=Classes,
+    printtype=\textit{Cls}
+]{Class}{class}
+
+}{% not doc
+
 \newcommand*{\DescribeClass}{%
 \begingroup\catcode`\_=12 \DTXD at DescribeClass%
 }
 
+}% not doc
+
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=option,
+    idxgroup=Options,
+    printtype=\textit{Opt}
+]{Option}{option}
+
+}{% not doc
+
 \newcommand*{\DescribeOption}[2][]
 {\DTXD at margintagindex{#1}{#2}{Opt}{option}{usage}}
+
+}% not doc
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=argument,
+    idxgroup=Arguments,
+    printtype=\textit{Arg}
+]{Argument}{argument}
+
+}{% not doc
+
 \newcommand*{\DescribeArgument}[2][]
 {\DTXD at margintagindex{#1}{#2}{Arg}{argument}{usage}}
+
+}% not doc
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=boolean,
+    idxgroup=Booleans,
+    printtype=\textit{bool}
+]{Boolean}{boolenv}
+
+}{% not doc
+
 \newcommand*{\DescribeBoolean}[2][]
 {\DTXD at margintagindex{#1}{#2}{Bool}{boolean}{usage}}
+
+}% not doc
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=true,
+    toplevel=false,
+    idxtype=length,
+    idxgroup=Lengths,
+    printtype=\textit{Len}
+]{Length}{length}
+
+}{% not doc
+
 \newcommand*{\DescribeLength}[2][]
 {\DTXD at cmdmargintagindex{#1}{#2}{Len}{length}{usage}}
+
+}% not doc
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=counter,
+    idxgroup=Counters,
+    printtype=\textit{Ctr}
+]{Counter}{counter}
+
+}{% not doc
+
 \newcommand*{\DescribeCounter}[2][]
 {\DTXD at margintagindex{#1}{#2}{Ctr}{counter}{usage}}
+
+}% not doc
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=hook,
+    idxgroup=Hooks,
+    printtype=\textit{Hook}
+]{Hook}{hook}
+
+}{% not doc
+
 \newcommand*{\DescribeHook}[2][]
     {\DTXD at margintagindex{#1}{#2}{Hook}{hook}{usage}}
+
+}% not doc
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=key,
+    idxgroup=Keys,
+    printtype=\textit{Key}
+]{Key}{key}
+
+}{% not doc
+
 \newcommand*{\DescribeKey}[2][]
 {\DTXD at margintagindex{#1}{#2}{Key}{key}{usage}}
+
+}% not doc
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=object,
+    idxgroup=Objects,
+    printtype=,
+]{Object}{object}
+
+}{% not doc
+
 \newcommand*{\DescribeObject}[2][]{%
 \@ifundefined{@captype}{% not float?
     \@bsphack%
@@ -506,6 +952,20 @@
 \@esphack%
 \ignorespaces%
 }
+
+}% not doc
+\IfPackageLoadedTF{doc}{% doc
+
+\NewDocElement[
+    macrolike=false,
+    toplevel=false,
+    idxtype=other,
+    idxgroup=Other,
+    printtype=,
+]{Other}{other}
+
+}{% not doc
+
 \newcommand*{\DescribeOther}[2][]{%
 \@ifundefined{@captype}{% not float?
     \@bsphack%
@@ -533,7 +993,9 @@
 \ignorespaces%
 }
 
+}% not doc
 
+
 \newcommand*{\DescribeDefaultcolor}{green!50!black}
 
 \newcommand{\DescribeDefault}[1]{%
@@ -717,8 +1179,14 @@
 \endVerbatimOut
 \par
 \addvspace{\bigskipamount}
-\IfBooleanTF{#1}{\vspace{\bigskipamount}}{\minipage{\linewidth}}%
-\captionsetup{type=dtxdexample}%
+\IfBooleanTF{#1}%
+    {% minipage
+        \minipage{\linewidth}%
+        \captionsetup{type=dtxexamplefloat}%
+    }%
+    {% float
+        \begin{dtxexamplefloat}%
+    }%
 \hrule\medskip
 \caption{#3}
 \textcolor{DTXD at examplerulecolor}{\smallskip\hrule}
@@ -733,7 +1201,9 @@
 \ifstrempty{#2}
 {}
 {{\itshape\small #2}}
-\IfBooleanTF{#1}{}{\endminipage}%
+\IfBooleanTF{#1}%
+    {\endminipage}%
+    {\end{dtxexamplefloat}}%
 } % end dtxexample
 
 \AfterEndEnvironment{dtxexample}
@@ -747,9 +1217,9 @@
 listname={List of Examples},
 name=Example,
 placement=hbp
-]{dtxdexample}
+]{dtxexamplefloat}
 
-\captionsetup*[dtxdexample]{
+\captionsetup*[dtxexamplefloat]{
 format=hang,
 font=bf,
 justification=raggedright,
@@ -758,8 +1228,10 @@
 position=top,
 }
 
-\AtBeginDocument{
-\@ifpackageloaded{cleveref}{\crefname{dtxdexample}{example}{examples}}{}
+\AddToHook{begindocument/before}{% Before .aux file is loaded.
+    \ifdef{\crefname}{
+        \crefname{dtxexamplefloat}{example}{examples}
+    }{}
 }
 
 \newenvironment{noindmacro}[1]



More information about the tex-live-commits mailing list.