| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: latex-lab-l3doc-tagging.dtx |
| 4 |
% Copyright (C) 2022-2025 The LaTeX Project |
| 5 |
% |
| 6 |
% It may be distributed and/or modified under the conditions of the |
| 7 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 8 |
% license or (at your option) any later version. The latest version |
| 9 |
% of this license is in the file |
| 10 |
% |
| 11 |
% https://www.latex-project.org/lppl.txt |
| 12 |
% |
| 13 |
% |
| 14 |
% The development version of the bundle can be found below |
| 15 |
% |
| 16 |
% https://github.com/latex3/latex2e/required/latex-lab |
| 17 |
% |
| 18 |
% for those people who are interested or want to report an issue. |
| 19 |
% |
| 20 |
\def\ltlabdoctaggingdate{2025-06-09} |
| 21 |
\def\ltlabdoctaggingversion{0.80c} |
| 22 |
|
| 23 |
%<*driver> |
| 24 |
\DocumentMetadata |
| 25 |
{ |
| 26 |
lang=en, |
| 27 |
pdfstandard=ua-2, |
| 28 |
tagging=on |
| 29 |
} |
| 30 |
\tagpdfsetup{table/header-rows=1} |
| 31 |
\documentclass{l3doc} |
| 32 |
\usepackage{latex-lab-testphase-l3doc} |
| 33 |
\EnableCrossrefs |
| 34 |
\CodelineIndex |
| 35 |
\NewDocElement[envlike, idxtype=instance, idxgroup=instances, |
| 36 |
printtype=\textit{inst.}] {Instance}{instance} |
| 37 |
|
| 38 |
\begin{document} |
| 39 |
\DocInput{latex-lab-l3doc-tagging.dtx} |
| 40 |
\end{document} |
| 41 |
%</driver> |
| 42 |
% |
| 43 |
% \fi |
| 44 |
% |
| 45 |
% |
| 46 |
% \title{The \texttt{latex-lab-testphase-l3doc} package\thanks{}} |
| 47 |
% \author{Ulrike Fischer, \LaTeX{} Project} |
| 48 |
% |
| 49 |
% \maketitle |
| 50 |
% |
| 51 |
% \tableofcontents |
| 52 |
% |
| 53 |
% \begin{documentation} |
| 54 |
% \section{Introduction} |
| 55 |
% |
| 56 |
% This package provides tagging support for the l3doc class. |
| 57 |
% It is work in progress. It is neither garantied that every element |
| 58 |
% is correctly tagged nor that the output looks identical to the untagged version. |
| 59 |
% |
| 60 |
% If a documentation is tagged with this code, it is important to check the log-file |
| 61 |
% for warnings, the tag structure for missing parts and the output for deviations! |
| 62 |
% |
| 63 |
% Feedback at \url{https://github.com/latex3/tagging-project} is welcome! |
| 64 |
% |
| 65 |
% TODO: Index? |
| 66 |
% |
| 67 |
% TODO: update key names if block key names change |
| 68 |
% |
| 69 |
% \end{documentation} |
| 70 |
% |
| 71 |
% \begin{implementation} |
| 72 |
% \section{implementation} |
| 73 |
% |
| 74 |
% \begin{macrocode} |
| 75 |
%<*package> |
| 76 |
% \end{macrocode} |
| 77 |
% |
| 78 |
% \subsection{Declaration} |
| 79 |
% |
| 80 |
% \begin{macrocode} |
| 81 |
\ProvidesExplPackage {latex-lab-testphase-l3doc} {2025-05-07} {0.80b} |
| 82 |
{ Tagging Support for the l3doc class } |
| 83 |
% \end{macrocode} |
| 84 |
% some minimal error checking |
| 85 |
% \begin{macrocode} |
| 86 |
\IfClassLoadedF{l3doc} |
| 87 |
{\PackageError{latex-lab-testphase-l3doc}{This~package~requires~the~l3doc~class!}{}} |
| 88 |
% \end{macrocode} |
| 89 |
% |
| 90 |
% \begin{macrocode} |
| 91 |
\IfDocumentMetadataF |
| 92 |
{\PackageError{latex-lab-testphase-l3doc}{This~package~requires~the~PDF~management!}{}} |
| 93 |
% \end{macrocode} |
| 94 |
% |
| 95 |
% \subsection{Tag and roles} |
| 96 |
% |
| 97 |
% The exact tagging structure is not yet clear. Especially for verbatim and |
| 98 |
% code material. So we define roles that we can exchange when needed. |
| 99 |
|
| 100 |
% \begin{macrocode} |
| 101 |
\tagpdfsetup |
| 102 |
{ |
| 103 |
role/new-tag=function/Sect, |
| 104 |
role/new-tag=functionnames/Caption, |
| 105 |
role/new-tag=functionname/Code, |
| 106 |
role/new-tag=functionnamepart/Span, |
| 107 |
role/new-tag=syntax/Sect, |
| 108 |
role/new-tag=function-description/Div, |
| 109 |
role/new-tag=macro/Sect, |
| 110 |
role/new-tag=macronames/Caption, |
| 111 |
role/new-tag=macroname/Span, |
| 112 |
role/new-tag=variable/Sect, |
| 113 |
role/new-tag=variablenames/Caption, |
| 114 |
role/new-tag=variablename/Span, |
| 115 |
role/new-tag=codelinenum/Span, |
| 116 |
role/new-tag=part/H1 |
| 117 |
} |
| 118 |
% \end{macrocode} |
| 119 |
% |
| 120 |
% \subsection{Variables} |
| 121 |
% |
| 122 |
% |
| 123 |
% \begin{variable}{\l__codedoc_current_names_struct_tl} |
| 124 |
% The structure around the command names in the margin must be moved around. |
| 125 |
% For this we define a variable that will hold the relevant current structure. |
| 126 |
% \begin{macrocode} |
| 127 |
\tl_new:N\l__codedoc_current_names_struct_tl |
| 128 |
% \end{macrocode} |
| 129 |
% \end{variable} |
| 130 |
% |
| 131 |
% \begin{variable}{\g__codedoc_macroname_structnum_seq} |
| 132 |
% This holds the structure numbers of the |
| 133 |
% structure around every command name in a macro environment. As the |
| 134 |
% structures are created inside a box this is a global variable, which is cleared |
| 135 |
% at the end of the outer macro environment. |
| 136 |
% \begin{macrocode} |
| 137 |
\seq_new:N\g__codedoc_macroname_structnum_seq |
| 138 |
% \end{macrocode} |
| 139 |
% \end{variable} |
| 140 |
% |
| 141 |
% |
| 142 |
% \subsection{The \env{function} enviroment} |
| 143 |
% |
| 144 |
% \begin{macro}{\__codedoc_function_typeset_start:} |
| 145 |
% This command starts the typesetting and opens the structure. |
| 146 |
% \begin{macrocode} |
| 147 |
\cs_set_protected:Npn \__codedoc_function_typeset_start: |
| 148 |
{ |
| 149 |
\par \bigskip |
| 150 |
\tagstructbegin{tag=function} |
| 151 |
% \end{macrocode} |
| 152 |
% The paragraph structure should start after the building of the macronames. |
| 153 |
% TODO: check if we can simply move ... |
| 154 |
% \begin{macrocode} |
| 155 |
\tagpdfparaOff |
| 156 |
\noindent |
| 157 |
} |
| 158 |
% \end{macrocode} |
| 159 |
% \end{macro} |
| 160 |
% |
| 161 |
% |
| 162 |
% \begin{macro}{\__codedoc_typeset_functions:} |
| 163 |
% TODO: \cs{toprule} and \cs{bottomrule} should be artifacts with pdflatex |
| 164 |
% (they are already with lualatex). |
| 165 |
% \begin{macrocode} |
| 166 |
\cs_set_protected:Npn \__codedoc_typeset_functions: |
| 167 |
{ % |
| 168 |
\small\ttfamily |
| 169 |
\__codedoc_target: |
| 170 |
\Hy@MakeCurrentHref { HD. \int_use:N \c@HD@hypercount } |
| 171 |
% \end{macrocode} |
| 172 |
% The function names are typeset as a tabular. We use |
| 173 |
% the table code to add the tagging. |
| 174 |
% \begin{macrocode} |
| 175 |
\tagstructbegin{tag=functionnames} |
| 176 |
\tagmcbegin{} |
| 177 |
\tagpdfsetup{table/tagging=div} |
| 178 |
\tl_set:Nn\l__tbl_rowtag_tl {functionname} |
| 179 |
\tl_set:Nn\l__tbl_celltag_tl {functionnamepart} |
| 180 |
\begin{tabular} [t] { @{} l @{} >{\hspace{\tabcolsep}} r @{} } |
| 181 |
\toprule |
| 182 |
\__codedoc_function_extra_labels: |
| 183 |
\__codedoc_names_typeset: |
| 184 |
\__codedoc_typeset_dates: |
| 185 |
\bottomrule |
| 186 |
\end{tabular} |
| 187 |
\tagmcend |
| 188 |
\tagstructend |
| 189 |
\normalfont\normalsize\par |
| 190 |
} |
| 191 |
% \end{macrocode} |
| 192 |
% \end{macro} |
| 193 |
% |
| 194 |
% \begin{macro}{\__codedoc_function_descr_start:w} |
| 195 |
% The function enviroment is mainly a box. We store the structure |
| 196 |
% for the syntax environment. |
| 197 |
% \begin{macrocode} |
| 198 |
\cs_set_protected:Npn \__codedoc_function_descr_start:w |
| 199 |
{ |
| 200 |
\vcoffin_set:Nnw \l__codedoc_descr_coffin { \textwidth } |
| 201 |
\tagpdfparaOn |
| 202 |
\tagstructbegin{tag=function-description} |
| 203 |
\tl_set:Ne\l__codedoc_current_names_struct_tl{\tag_get:n{struct_num}} |
| 204 |
\noindent \ignorespaces |
| 205 |
} |
| 206 |
% \end{macrocode} |
| 207 |
% \end{macro} |
| 208 |
% |
| 209 |
% \begin{macro}{\__codedoc_function_typeset_stop:} |
| 210 |
% At the end we must close the two main structures. |
| 211 |
% \begin{macrocode} |
| 212 |
\cs_set_protected:Npn \__codedoc_function_typeset_stop: |
| 213 |
{ |
| 214 |
\par |
| 215 |
\tagstructend % function-description |
| 216 |
\tagstructend % function |
| 217 |
\dim_set:Nn \prevdepth { \coffin_dp:N \l__codedoc_descr_coffin } |
| 218 |
\allowbreak |
| 219 |
} |
| 220 |
% \end{macrocode} |
| 221 |
% \end{macro} |
| 222 |
% |
| 223 |
% \subsection{The \env{syntax} environment} |
| 224 |
% |
| 225 |
% These environments are full of boxes that are moved around. |
| 226 |
% Getting the mc-chunks right is not trivial. |
| 227 |
% |
| 228 |
% TODO: check if one should change/simplify the tagging of the inner minipage. |
| 229 |
% \begin{macro}{\__codedoc_syntax:w} |
| 230 |
% \begin{macrocode} |
| 231 |
\cs_set_protected:Npn \__codedoc_syntax:w |
| 232 |
{ |
| 233 |
\box_if_empty:NF \g__codedoc_syntax_box |
| 234 |
{ \msg_error:nn { l3doc } { multiple-syntax } } |
| 235 |
\dim_set:Nn \l__codedoc_syntax_dim |
| 236 |
{ |
| 237 |
\textwidth |
| 238 |
\bool_if:NT \l__codedoc_long_name_bool |
| 239 |
{ + \marginparwidth - \l__codedoc_trial_width_dim } |
| 240 |
} |
| 241 |
\tag_mc_end_push: |
| 242 |
\hbox_gset:Nw \g__codedoc_syntax_box |
| 243 |
\tl_if_empty:NTF\l__codedoc_current_names_struct_tl |
| 244 |
{ |
| 245 |
\tagstructbegin{tag=syntax} |
| 246 |
} |
| 247 |
{ |
| 248 |
% \end{macrocode} |
| 249 |
% TODO: check if firstkid is the right thing. |
| 250 |
% \begin{macrocode} |
| 251 |
\tagstructbegin{tag=syntax,firstkid,parent=\l__codedoc_current_names_struct_tl} |
| 252 |
} |
| 253 |
\small \ttfamily |
| 254 |
\tagpdfsetup{table/tagging=false} |
| 255 |
\tagpdfparaOff |
| 256 |
\arrayrulecolor{white} |
| 257 |
\begin{tabular} { @{} p{\l__codedoc_syntax_dim} @{} } |
| 258 |
\toprule |
| 259 |
\begin{minipage}[t]{\l__codedoc_syntax_dim} |
| 260 |
\raggedright |
| 261 |
\obeyspaces |
| 262 |
\obeylines |
| 263 |
} |
| 264 |
% \end{macrocode} |
| 265 |
% \end{macro} |
| 266 |
% |
| 267 |
% |
| 268 |
% \begin{macro}{\__codedoc_syntax_end:} |
| 269 |
% \begin{macrocode} |
| 270 |
\cs_set_protected:Npn \__codedoc_syntax_end: |
| 271 |
{ |
| 272 |
\end{minipage} |
| 273 |
\end{tabular} |
| 274 |
\arrayrulecolor{black} |
| 275 |
\tagstructend |
| 276 |
\hbox_gset_end: |
| 277 |
\tag_mc_begin_pop:n{} |
| 278 |
\bool_if:NF \l__codedoc_in_function_bool |
| 279 |
{ |
| 280 |
\begin{quote} |
| 281 |
\mode_leave_vertical: |
| 282 |
\box_use_drop:N \g__codedoc_syntax_box |
| 283 |
\end{quote} |
| 284 |
} |
| 285 |
} |
| 286 |
% \end{macrocode} |
| 287 |
% \end{macro} |
| 288 |
% |
| 289 |
% \subsection{The \env{macro} environment} |
| 290 |
% The macro environment is difficult: It collects various content |
| 291 |
% in boxes and outputs everything at the end in \cs{__codedoc_macro_dump:}, |
| 292 |
% including the command names in the argument which are output in the margin. |
| 293 |
% A macro environment can have more than one name in |
| 294 |
% the argument and the environment be nested and the respective command names |
| 295 |
% are then combined with the outer names. |
| 296 |
% A command name can link to a \env{function} environment, |
| 297 |
% which mean that it isn't simple text but contains a structure. |
| 298 |
% This means that one has to collect structure numbers to insert them when needed. |
| 299 |
% |
| 300 |
% |
| 301 |
% \begin{macro}{\__codedoc_macro_dump:} |
| 302 |
% Here we have larger changes as we need also to replace the trivlist by a displayblock. |
| 303 |
% \begin{macrocode} |
| 304 |
\cs_set_protected:Npn \__codedoc_macro_dump: |
| 305 |
{ |
| 306 |
\int_compare:nNnF{\l__codedoc_nested_macro_int}>{1} |
| 307 |
{ |
| 308 |
\begin{displayblock} [tag-name=macro,beginsep=\MacroTopsep] |
| 309 |
% \end{macrocode} |
| 310 |
% we add here a container for the macronames which are built later and use |
| 311 |
% the structures from the list. |
| 312 |
% \begin{macrocode} |
| 313 |
\tagstructbegin{tag=macronames} |
| 314 |
\tl_set:Ne \l__codedoc_current_names_struct_tl {\tag_get:n{struct_num}} |
| 315 |
\seq_map_inline:Nn \g__codedoc_macroname_structnum_seq |
| 316 |
{\tag_struct_use_num:n {##1}} |
| 317 |
\seq_gclear:N \g__codedoc_macroname_structnum_seq |
| 318 |
\tagstructend |
| 319 |
} |
| 320 |
\noindent\llap |
| 321 |
{ \tagmcend |
| 322 |
\hbox_unpack_drop:N \l__codedoc_macro_index_box |
| 323 |
\vtop to \baselineskip |
| 324 |
{ |
| 325 |
\vbox_unpack_drop:N \l__codedoc_macro_box |
| 326 |
\vss |
| 327 |
} |
| 328 |
\hspace{\labelsep} |
| 329 |
\tagmcbegin{} |
| 330 |
} |
| 331 |
} |
| 332 |
% \end{macrocode} |
| 333 |
% \end{macro} |
| 334 |
% |
| 335 |
% \begin{macro}{\__codedoc_macro_typeset_one:nN} |
| 336 |
% The \cs{__codedoc_macro_typeset_one:nN} command appends one macro name |
| 337 |
% to the \cs{l__codedoc_macro_box}. We have to add a structure. |
| 338 |
% If we are on the outer level we have to record the structure number. |
| 339 |
% In the inner level we can use the existing structure. |
| 340 |
% As the structures are used in another place, we have to push/pop the mc. |
| 341 |
% \begin{macrocode} |
| 342 |
\cs_set_protected:Npn \__codedoc_macro_typeset_one:nN #1#2 |
| 343 |
{ |
| 344 |
\tag_mc_end_push: |
| 345 |
\vbox_set:Nn \l__codedoc_macro_box |
| 346 |
{ |
| 347 |
\vbox_unpack_drop:N \l__codedoc_macro_box |
| 348 |
\int_compare:nNnTF { \l__codedoc_nested_macro_int } = { 1 } |
| 349 |
{ |
| 350 |
\tagstructbegin{tag=macroname,stash} |
| 351 |
\seq_gput_right:Ne |
| 352 |
\g__codedoc_macroname_structnum_seq{\tag_get:n{struct_num}} |
| 353 |
} |
| 354 |
{ |
| 355 |
\tagstructbegin{tag=macroname,parent=\l__codedoc_current_names_struct_tl} |
| 356 |
} |
| 357 |
\tagmcbegin{} |
| 358 |
\hbox { \llap { \__codedoc_print_macroname:nN {#1} #2 |
| 359 |
\MacroFont \ |
| 360 |
} } |
| 361 |
\tagmcend |
| 362 |
\tagstructend |
| 363 |
} |
| 364 |
\tag_mc_begin_pop:n{} |
| 365 |
\int_incr:N \l__codedoc_macro_int |
| 366 |
} |
| 367 |
% \end{macrocode} |
| 368 |
% \end{macro} |
| 369 |
% |
| 370 |
% \begin{macro}{\__codedoc_macro_reset:} |
| 371 |
% As we have no nested lists, we need to ignore spaces explicitly |
| 372 |
% \begin{macrocode} |
| 373 |
\cs_set_protected:Npn \__codedoc_macro_reset: |
| 374 |
{ |
| 375 |
\tl_set:Nn \l__codedoc_override_module_tl { \q_no_value } |
| 376 |
\ignorespaces |
| 377 |
} |
| 378 |
% \end{macrocode} |
| 379 |
% \end{macro} |
| 380 |
% |
| 381 |
% \begin{macro}{\__codedoc_macro_end:} |
| 382 |
% \begin{macrocode} |
| 383 |
\cs_set_protected:Npn \__codedoc_macro_end: |
| 384 |
{ |
| 385 |
\__codedoc_macro_end_check_tested: |
| 386 |
\int_compare:nNnT \l__codedoc_nested_macro_int = 1 |
| 387 |
{ |
| 388 |
\par \__codedoc_macro_end_style:n { \__codedoc_print_end_definition: } |
| 389 |
\end{displayblock} |
| 390 |
} |
| 391 |
} |
| 392 |
% \end{macrocode} |
| 393 |
% \end{macro} |
| 394 |
% |
| 395 |
% \subsection{The \env{macrocode} environment} |
| 396 |
% |
| 397 |
% |
| 398 |
% \begin{macro}[no-user-doc]{\legacymacrocodesetup} |
| 399 |
% We want to base the environment on the new template code. |
| 400 |
% This is a counterpart to the \cs{legacyverbatimsetup} |
| 401 |
% command in the latex-lab-block code. |
| 402 |
% \begin{macrocode} |
| 403 |
\def\legacymacrocodesetup{% |
| 404 |
\macro@font |
| 405 |
\blank@linefalse \def\par{\ifblank@line |
| 406 |
\leavevmode \else \fi |
| 407 |
% \end{macrocode} |
| 408 |
% Similar to the case for verbatim we must group the |
| 409 |
% \cs{@@par} so that we do not loose indentation on the first |
| 410 |
% line |
| 411 |
% \begin{macrocode} |
| 412 |
\blank@linetrue{\@@par} |
| 413 |
\penalty\interlinepenalty} |
| 414 |
\obeylines |
| 415 |
\@noligs |
| 416 |
\let\do\@makeother \dospecials |
| 417 |
\global\@newlistfalse |
| 418 |
\global\@minipagefalse |
| 419 |
\ifcodeline@index |
| 420 |
|
| 421 |
\everypar{\global\advance\c@CodelineNo\@ne |
| 422 |
\llap{\tagmcend\tagstructbegin{tag=codelinenum} |
| 423 |
\tagmcbegin{} |
| 424 |
\theCodelineNo\pdffakespace |
| 425 |
\tagmcend\tagstructend |
| 426 |
\tagmcbegin{}% |
| 427 |
\ }% |
| 428 |
\check@module}% |
| 429 |
\else \everypar{\check@module}% |
| 430 |
\fi |
| 431 |
\tagtool{paratag=codeline}% check tagging |
| 432 |
} |
| 433 |
% \end{macrocode} |
| 434 |
% \end{macro} |
| 435 |
% \begin{instance}{blockenv macrocode} |
| 436 |
% \begin{macrocode} |
| 437 |
\DeclareInstance{blockenv}{macrocode}{display} |
| 438 |
{ |
| 439 |
name = macrocode, |
| 440 |
tag-name = verbatim, |
| 441 |
tag-attr-class = , |
| 442 |
tagging-recipe = standard, |
| 443 |
inner-level-counter = , |
| 444 |
increment-level = false, |
| 445 |
setup-code = , |
| 446 |
block-instance = verbatimblock , |
| 447 |
inner-instance = , |
| 448 |
final-code = \legacymacrocodesetup , |
| 449 |
para-instance = justify, |
| 450 |
tagging-suppress-paras= true |
| 451 |
} |
| 452 |
% \end{macrocode} |
| 453 |
% \end{instance} |
| 454 |
% |
| 455 |
% \begin{environment}{macrocode} |
| 456 |
% \begin{macrocode} |
| 457 |
\RenewDocumentEnvironment{macrocode}{!O{}} |
| 458 |
{\UseInstance{blockenv}{macrocode} |
| 459 |
{beginpenalty=\predisplaypenalty, |
| 460 |
begin-skip=\MacrocodeTopsep, |
| 461 |
leftmargin=\MacroIndent, |
| 462 |
parindent=0pt,#1}% |
| 463 |
\@setupverbinvisiblespace |
| 464 |
\init@crossref |
| 465 |
\frenchspacing \@vobeyspaces |
| 466 |
\xmacro@code |
| 467 |
} |
| 468 |
{ |
| 469 |
\ifpm@module \endgroup \pm@modulefalse \fi |
| 470 |
\everypar{} |
| 471 |
\endblockenv |
| 472 |
\close@crossref |
| 473 |
} |
| 474 |
% \end{macrocode} |
| 475 |
% \end{environment} |
| 476 |
% |
| 477 |
% \subsection{New doc elements} |
| 478 |
% Various documentation elements are declare with the \cs{NewDocElement} |
| 479 |
% command. Here we patch the relevant commands to get tagged versions. |
| 480 |
% |
| 481 |
% \begin{macro}[no-user-doc]{\@doc@env@} |
| 482 |
% \begin{macrocode} |
| 483 |
\long\def\@doc@env@#1#2#3{% |
| 484 |
% \end{macrocode} |
| 485 |
% we setup a new role: |
| 486 |
% \begin{macrocode} |
| 487 |
\tagpdfsetup{role/new-tag=#2/Sect} |
| 488 |
\int_incr:N\l__codedoc_nested_macro_int |
| 489 |
\int_compare:nNnF{\l__codedoc_nested_macro_int}>{1} |
| 490 |
{\UseInstance{blockenv}{displayblock} |
| 491 |
{level-increase=false,tag-name=#2,beginsep=\MacroTopsep} |
| 492 |
% \end{macrocode} |
| 493 |
% A container for the function names. |
| 494 |
% \begin{macrocode} |
| 495 |
\tagstructbegin{tag=macronames} |
| 496 |
\tl_set:Ne \l__codedoc_current_names_struct_tl {\tag_get:n{struct_num}} |
| 497 |
\tagstructend |
| 498 |
} |
| 499 |
\edef\saved@macroname{\string#3}% |
| 500 |
\if #1% |
| 501 |
\edef\saved@indexname{\expandafter\@gobble\saved@macroname}% |
| 502 |
\expandafter\ifx |
| 503 |
\csname Code#2Index\endcsname |
| 504 |
\CodeMacroIndex |
| 505 |
\else |
| 506 |
\record@index@type@save |
| 507 |
{\saved@indexname}{#2}% |
| 508 |
\fi |
| 509 |
\else |
| 510 |
\let\saved@indexname\saved@macroname |
| 511 |
\fi |
| 512 |
\def\makelabel##1{\noindent\llap{ |
| 513 |
\tagmcend |
| 514 |
\tagstructbegin{tag=macroname,parent=\l__codedoc_current_names_struct_tl} |
| 515 |
\tagmcbegin{} |
| 516 |
##1\hspace{\itemsep} |
| 517 |
\tagmcend |
| 518 |
\tagstructend |
| 519 |
\tagmcbegin{} |
| 520 |
}}% |
| 521 |
\int_compare:nNnTF{\l__codedoc_nested_macro_int}>{1} |
| 522 |
{ |
| 523 |
\let\@tempa\@empty |
| 524 |
\count@\macro@cnt |
| 525 |
\loop\ifnum\count@>\z@ |
| 526 |
\edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne |
| 527 |
\repeat |
| 528 |
\edef\makelabel##1{\noindent\llap{ |
| 529 |
\tagmcend |
| 530 |
\tagstructbegin{tag=macroname,parent=\l__codedoc_current_names_struct_tl} |
| 531 |
\tagmcbegin{} |
| 532 |
\vtop to\baselineskip{\@tempa\hbox{##1\kern\labelsep}\vss} |
| 533 |
\tagmcend |
| 534 |
\tagstructend |
| 535 |
\tagmcbegin{} |
| 536 |
}}% |
| 537 |
\advance\macro@cnt\@ne |
| 538 |
} |
| 539 |
{ \macro@cnt\@ne } |
| 540 |
\ifdoc@noprint |
| 541 |
\else |
| 542 |
\edef\@tempa{% |
| 543 |
\noexpand\makelabel{ |
| 544 |
\noexpand\doc@providetarget |
| 545 |
\noexpand\strut |
| 546 |
\noexpand\@nameuse{Print#2Name}{\saved@macroname}}}% |
| 547 |
\@tempa |
| 548 |
\fi |
| 549 |
\ifdoc@noindex\else |
| 550 |
\global\advance\c@CodelineNo\@ne |
| 551 |
\csname SpecialMain#2Index\expandafter\endcsname |
| 552 |
\expandafter{\saved@macroname}\nobreak |
| 553 |
\global\advance\c@CodelineNo\m@ne |
| 554 |
\fi |
| 555 |
\if#1\expandafter\DoNotIndex \expandafter {\saved@macroname}\fi |
| 556 |
\ignorespaces} |
| 557 |
% \end{macrocode} |
| 558 |
% \end{macro} |
| 559 |
% |
| 560 |
% \begin{macro}[no-user-doc]{\doc@createenv} |
| 561 |
% We must use \cs{endblockenv}. |
| 562 |
% \begin{macrocode} |
| 563 |
\def\doc@createenv#1#2#3{% |
| 564 |
\@namedef{#3}{% |
| 565 |
\@ifnextchar[%] |
| 566 |
{\doc@env{#1}{#2}}{\doc@env{#1}{#2}[]}}% |
| 567 |
\@namedef{end#3}{\endblockenv}% |
| 568 |
} |
| 569 |
% \end{macrocode} |
| 570 |
% \end{macro} |
| 571 |
% |
| 572 |
% We must renew the environment doc element so that is uses the new code: |
| 573 |
% \begin{macrocode} |
| 574 |
\RenewDocElement[macrolike = false , |
| 575 |
idxtype = env. , |
| 576 |
idxgroup = environments , |
| 577 |
printtype = \textit{env.} |
| 578 |
]{Env}{environment} |
| 579 |
% \end{macrocode} |
| 580 |
% |
| 581 |
% \subsection{\cs{maketitle}} |
| 582 |
% The \pkg{doc} package redefines \cs{maketitle}. So we have to reinstate the |
| 583 |
% version from the title module. |
| 584 |
% |
| 585 |
% \begin{macrocode} |
| 586 |
\cs_if_exist:NT \__tag_patch_maketitle: |
| 587 |
{ |
| 588 |
\cs_set_eq:NN \maketitle \__tag_patch_maketitle: |
| 589 |
} |
| 590 |
% \end{macrocode} |
| 591 |
% |
| 592 |
% \subsection{Sectioning commands and table of contents} |
| 593 |
% |
| 594 |
% \cs{l@section} must get the hooks: |
| 595 |
|
| 596 |
% \begin{macro}[no-user-doc]{\l@section} |
| 597 |
% \begin{macrocode} |
| 598 |
\cs_gset:Npn \l@section #1#2 |
| 599 |
{ |
| 600 |
\ifnum \c@tocdepth >\z@ |
| 601 |
\addpenalty\@secpenalty |
| 602 |
\addvspace{1.0em \@plus\p@} |
| 603 |
\setlength\@tempdima{2.5em} % was 1.5em |
| 604 |
\begingroup |
| 605 |
\parindent \z@ \rightskip \@pnumwidth |
| 606 |
\parfillskip -\@pnumwidth |
| 607 |
\leavevmode \bfseries |
| 608 |
\advance\leftskip\@tempdima |
| 609 |
\hskip -\leftskip |
| 610 |
\UseHookWithArguments{contentsline/text/before}{4} |
| 611 |
{\toclevel@section}{#1}{#2}{\@contentsline@destination}% |
| 612 |
\csname contentsline@text@1@format\endcsname{#1} |
| 613 |
\UseHookWithArguments{contentsline/text/after}{4} |
| 614 |
{\toclevel@chapter}{#1}{#2}{\@contentsline@destination}% |
| 615 |
\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss |
| 616 |
\UseHookWithArguments{contentsline/page/before}{4} |
| 617 |
{\toclevel@section}{#1}{#2}{\@contentsline@destination}% |
| 618 |
#2 |
| 619 |
\UseHookWithArguments{contentsline/page/after}{4} |
| 620 |
{\toclevel@section}{#1}{#2}{\@contentsline@destination}% |
| 621 |
}\par |
| 622 |
\endgroup |
| 623 |
\fi |
| 624 |
} |
| 625 |
% \end{macrocode} |
| 626 |
% \end{macro} |
| 627 |
% |
| 628 |
% \subsection{Support \pkg{fancyvrb}} |
| 629 |
% l3doc uses \pkg{fancyvrb}. |
| 630 |
% As the block code redefines \env{verbatim} at begin document, |
| 631 |
% we have to overwrite that again: |
| 632 |
% \begin{macrocode} |
| 633 |
\AtBeginDocument |
| 634 |
{ |
| 635 |
\cs_gset_eq:NN \verbatim \Verbatim |
| 636 |
\cs_gset_eq:NN \endverbatim \endVerbatim |
| 637 |
} |
| 638 |
% \end{macrocode} |
| 639 |
% |
| 640 |
% \begin{macrocode} |
| 641 |
%</package> |
| 642 |
% \end{macrocode} |
| 643 |
% \end{implementation} |
| 644 |
\endinput |