%%
%% This is file `l3doc.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3doc.dtx  (with options: `class,cfg')
%% 
%% 
%% EXPERIMENTAL CODE
%% 
%% Do not distribute this file without also distributing the
%% source files specified above.
%% 
%% Do not distribute a modified version of this file.
%% 
%% 
%% File: l3doc.dtx Copyright (C) 1990-2014 The LaTeX3 project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
%% license or (at your option) any later version.  The latest version
%% of this license is in the file
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the "l3kernel bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
%% -----------------------------------------------------------------------
%%
%% The development version of the bundle can be found at
%%
%%    http://www.latex-project.org/svnroot/experimental/trunk/
%%
%% for those people who are interested.
%%
%%%%%%%%%%%
%% NOTE: %%
%%%%%%%%%%%
%%
%%   Snapshots taken from the repository represent work in progress and may
%%   not work or may contain conflicting material!  We therefore ask
%%   people _not_ to put them into distributions, archives, etc. without
%%   prior consultation with the LaTeX3 Project.
%%
%% -----------------------------------------------------------------------
\let        \filenameOld        \ExplFileName
\let        \filedateOld        \ExplFileDate
\let     \fileversionOld        \ExplFileVersion
\let \filedescriptionOld        \ExplFileDescription
\RequirePackage{expl3,xparse,calc}
\GetIdInfo$Id: l3doc.dtx 4728 2014-05-04 13:25:37Z joseph $
          {L3 Experimental documentation class}
\ProvidesExplClass
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\let        \ExplFileName        \filenameOld
\let        \ExplFileDate        \filedateOld
\let        \ExplFileVersion     \fileversionOld
\let        \ExplFileDescription \filedescriptionOld
\coffin_new:N \l__codedoc_output_box
\coffin_new:N \l__codedoc_names_coffin
\coffin_new:N \l__codedoc_descr_coffin
\coffin_new:N \l__codedoc_syntax_coffin
\box_new:N \g__codedoc_syntax_box
\bool_new:N \l__codedoc_long_name_bool
\bool_new:N \g__codedoc_implementation_bool
\dim_new:N \l__codedoc_trial_width_dim
\tl_new:N \l__codedoc_macro_tl
\int_new:N \l__codedoc_macro_int
\int_new:N \g__codedoc_nested_macro_int
\prop_new:N \g__codedoc_missing_tests_prop
\clist_new:N \g_docinput_clist
\tl_new:N \l__codedoc_at_replaced_macro_tl
\seq_new:N \g__codedoc_testfiles_seq
\seq_new:N \g_doc_functions_seq
\seq_new:N \g_doc_macros_seq
\seq_new:N \g__codedoc_not_tested_seq
\bool_new:N \l__codedoc_meta_TF_bool
\bool_new:N \l__codedoc_meta_pTF_bool
\bool_new:N \l__codedoc_meta_EXP_bool
\bool_new:N \l__codedoc_meta_rEXP_bool
\bool_new:N \l__codedoc_macro_internal_bool
\bool_new:N \l__codedoc_macro_aux_bool
\bool_new:N \l__codedoc_macro_TF_bool
\bool_new:N \l__codedoc_macro_pTF_bool
\bool_new:N \l__codedoc_macro_var_bool
\bool_new:N \g__codedoc_full_bool
\bool_new:N \g__codedoc_lmodern_bool
\bool_new:N \g__codedoc_checkfunc_bool
\bool_new:N \g__codedoc_checktest_bool
\seq_new:N \g__codedoc_tmpa_seq
\tl_new:N \l__codedoc_tmpa_tl
\tl_new:N \l__codedoc_tmpb_tl
\int_new:N \l__codedoc_tmpa_int
\bool_new:N \l__codedoc_tested_bool
\DeclareOption{a5paper}{\@latexerr{Option not supported}{}}
\DeclareOption{full}{ \bool_set_true:N \g__codedoc_full_bool }
\DeclareOption{onlydoc}{ \bool_set_false:N \g__codedoc_full_bool }
\DeclareOption{check}{ \bool_set_true:N \g__codedoc_checkfunc_bool }
\DeclareOption{nocheck}{ \bool_set_false:N \g__codedoc_checkfunc_bool }
\DeclareOption{checktest}{ \bool_set_true:N \g__codedoc_checktest_bool }
\DeclareOption{nochecktest}{ \bool_set_false:N \g__codedoc_checktest_bool }
\DeclareOption{cm-default}{ \bool_set_false:N \g__codedoc_lmodern_bool }
\DeclareOption{lm-default}{ \bool_set_true:N \g__codedoc_lmodern_bool }
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ExecuteOptions{full,a4paper,nocheck,nochecktest,lm-default}
\msg_new:nnn {l3doc} {input-cfg}
 {
  Local~config~file~l3doc.cfg~loaded.
 }
\file_if_exist:nT {l3doc.cfg}
 {
  \file_input:n {l3doc.cfg}
  \msg_info:nn {l3doc} {input-cfg}
 }
\ProcessOptions
\LoadClass{article}
\RequirePackage{doc}
\RequirePackage
  {
    array,
    alphalph,
    amsmath,
    amssymb,
    booktabs,
    color,
    colortbl,
    fixltx2e,
    hologo,
    enumitem,
    pifont,
    textcomp,
    trace,
    underscore,
    csquotes,
    fancyvrb,
    verbatim
  }
\raggedbottom
\fvset{gobble=2}
\cs_set_eq:NN \verbatim \Verbatim
\cs_set_eq:NN \endverbatim \endVerbatim
\bool_if:NT \g__codedoc_lmodern_bool
 {
  \RequirePackage[T1]{fontenc}
  \RequirePackage{lmodern}
  \group_begin:
    \ttfamily
    \DeclareFontShape{T1}{lmtt}{m}{it}{<->ec-lmtto10}{}
  \group_end:
 }
\RequirePackage{hypdoc}
\cs_set_nopar:Npn \MakePrivateLetters
 {
  \char_set_catcode_letter:N \@
  \char_set_catcode_letter:N \_
  \char_set_catcode_letter:N \:
 }
\setcounter{StandardModuleDepth}{1}
\@addtoreset{CodelineNo}{part}
\tl_replace_once:Nnn \theCodelineNo
 { \HDorg@theCodelineNo }
 { \textcolor[gray]{0.5} { \sffamily\tiny\arabic{CodelineNo} } }
\setlength   \textwidth      { 385pt }
\addtolength \marginparwidth {  30pt }
\addtolength \oddsidemargin  {  20pt }
\addtolength \evensidemargin {  20pt }
\cs_set_eq:NN \__codedoc_oldlist:nn \list
\cs_set_nopar:Npn \list #1 #2 { \__codedoc_oldlist:nn {#1} { #2 \listparindent\z@ } }
\setlength \parindent  { 2em }
\setlength \itemindent { 0pt }
\setlength \parskip    { 0pt plus 3pt minus 0pt }
\@addtoreset{section}{part}
\cs_set_nopar:Npn \l@section #1#2
 {
  \ifnum \c@tocdepth >\z@
    \addpenalty\@secpenalty
    \addvspace{1.0em \@plus\p@}
    \setlength\@tempdima{2.5em}  % was 1.5em
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
    \endgroup
  \fi
 }
\cs_set_nopar:Npn\l@subsection{\@dottedtocline{2}{2.5em}{2.3em}}  % #2 = 1.5em
\AtBeginDocument
 {
  \MakeShortVerb \"
  \MakeShortVerb \|
 }
\providecommand*\eTeX{\hologo{eTeX}}
\providecommand*\IniTeX{\hologo{iniTeX}}
\providecommand*\Lua{Lua}
\providecommand*\LuaTeX{\hologo{LuaTeX}}
\providecommand*\pdfTeX{\hologo{pdfTeX}}
\providecommand*\XeTeX{\hologo{XeTeX}}
\DeclareDocumentCommand \cmd {m} { \__codedoc_cmd:n { #1 } }
\DeclareDocumentCommand \cs  {m} { \__codedoc_cs:n  { #1 } }
\cs_new:Npn \__codedoc_cmd:n #1 { \cs{ \expandafter \__codedoc_cmd_to_cs:w \string#1 } }
\cs_set_nopar:Npn \__codedoc_cmd_to_cs:w #1#2 { \char\number`#2\relax }
\cs_new:Npn \__codedoc_cs:n #1
 {
  \tl_set_rescan:Nnn \l__codedoc_tmpb_tl { } { _ }
  \tl_set:Nn \l__codedoc_tmpa_tl {#1}
  \tl_replace_all:NVn \l__codedoc_tmpa_tl \l__codedoc_tmpb_tl { _ }
  \__codedoc_replace_at_at:N \l__codedoc_tmpa_tl
  \tl_replace_all:NnV \l__codedoc_tmpa_tl { _ } \l__codedoc_tmpb_tl
  \texttt { \char`\\ \tl_use:N \l__codedoc_tmpa_tl}
 }
\cs_generate_variant:Nn \tl_replace_all:Nnn { NV , NnV }
\providecommand\marg[1]{ \texttt{\char`\{} \meta{#1} \texttt{\char`\}} }
\providecommand\oarg[1]{ \texttt[ \meta{#1} \texttt] }
\providecommand\parg[1]{ \texttt( \meta{#1} \texttt) }
\cs_set_eq:NN \file \nolinkurl
\DeclareRobustCommand \env {\texttt}
\DeclareRobustCommand \pkg {\textsf}
\DeclareRobustCommand \cls {\textsf}
\newenvironment{texnote}
 {
  \endgraf
  \vspace{3mm}
  \small\textbf{\TeX~hackers~note:}
 }
 {
  \vspace{3mm}
 }
\DeclareDocumentCommand \tn {m}
 {
  \texttt { \char`\\ #1 }
  \index
   {
    TeX~and~LaTeX2e~commands\actualchar
    \string\TeX{}~and~\string\LaTeXe{}~commands:\levelchar
    #1\actualchar{\string\ttfamily\string\bslash{}#1}
   }
 }
\cs_new:Npn \__codedoc_implementation:
 {
  \DeclareDocumentCommand {\variable} { O{} } { \__codedoc_macro:n { var , ##1 } }
  \cs_set_eq:NN \endvariable \endmacro
 }
\cs_new:Npn \__codedoc_docu:
 {
  \cs_set_eq:NN \variable \variabledoc
  \cs_set_eq:NN \endvariable \endvariabledoc
 }
\AtEndOfPackage{\__codedoc_docu:}
\newenvironment{documentation}{\__codedoc_docu:}{}
\newenvironment{implementation}{\__codedoc_implementation:}{}
\NewDocumentCommand \EnableDocumentation {}
 {
  \renewenvironment{documentation}{\__codedoc_docu:}{}
 }
\NewDocumentCommand \EnableImplementation {}
 {
  \renewenvironment{implementation}{\__codedoc_implementation:}{}
 }
\NewDocumentCommand \DisableDocumentation {}
 {
  \cs_set_eq:NN \documentation \comment
  \cs_set_eq:NN \enddocumentation \endcomment
 }
\NewDocumentCommand \DisableImplementation {}
 {
  \cs_set_eq:NN \implementation \comment
  \cs_set_eq:NN \endimplementation \endcomment
 }
\newenvironment{arguments}
 {
  \enumerate[
    nolistsep,
    label=\texttt{\#\arabic*}~:,
    labelsep=*,
  ]
 }
 {
  \endenumerate
 }
\keys_define:nn { l3doc/function }
 {
  TF .code:n =
   {
    \bool_gset_true:N \l__codedoc_meta_TF_bool
   } ,
  EXP .code:n =
   {
    \bool_gset_true:N \l__codedoc_meta_EXP_bool
    \bool_gset_false:N \l__codedoc_meta_rEXP_bool
   } ,
  rEXP .code:n =
   {
    \bool_gset_false:N \l__codedoc_meta_EXP_bool
    \bool_gset_true:N \l__codedoc_meta_rEXP_bool
   } ,
  pTF .code:n =
   {
    \bool_gset_true:N \l__codedoc_meta_pTF_bool
    \bool_gset_true:N \l__codedoc_meta_TF_bool
    \bool_gset_true:N \l__codedoc_meta_EXP_bool
   } ,
   added .tl_set:N = \l__codedoc_date_added_tl ,
   updated .tl_set:N = \l__codedoc_date_updated_tl ,
   tested .code:n = { } ,
 }
\char_set_catcode_active:N \<
\DeclareDocumentEnvironment {function} { O{} }
 {

  \par\bigskip\noindent
  \phantomsection

  \coffin_clear:N \l__codedoc_descr_coffin
  \box_gclear:N \g__codedoc_syntax_box
  \coffin_clear:N \l__codedoc_syntax_coffin
  \coffin_clear:N \l__codedoc_names_coffin

  \bool_set_false:N \l__codedoc_meta_TF_bool
  \bool_set_false:N \l__codedoc_meta_pTF_bool
  \bool_set_false:N \l__codedoc_meta_EXP_bool
  \bool_set_false:N \l__codedoc_meta_rEXP_bool

  \keys_set:nn { l3doc/function } {#1}

  \char_set_active_eq:NN < \__codedoc_open_meta:w

  \group_begin:
    \MakePrivateLetters
    \char_set_catcode_other:N \|
    \char_set_catcode_space:N \~
    \char_set_catcode_ignore:N \ % space
    \char_set_catcode_ignore:N \^^M
    \char_set_catcode_ignore:N \^^I
    \exp_after:wN
  \group_end:
  \__codedoc_function:n
 }
 {
  \vcoffin_set_end:
  \hcoffin_set:Nn  \l__codedoc_syntax_coffin { \box_use:N \g__codedoc_syntax_box }
  \bool_if:NTF \l__codedoc_long_name_bool
   {
    \coffin_join:NnnNnnnn
      \l__codedoc_output_box {hc} {vc}
      \l__codedoc_syntax_coffin {l} {T}
      {0pt} {0pt}
    \coffin_join:NnnNnnnn
      \l__codedoc_output_box {l} {t}
      \l__codedoc_names_coffin  {r} {t}
      {-\marginparsep} {0pt}
    \coffin_join:NnnNnnnn
      \l__codedoc_output_box {l} {b}
      \l__codedoc_descr_coffin  {l} {t}
      {0.75\marginparwidth + \marginparsep} {-\medskipamount}

    \coffin_typeset:Nnnnn \l__codedoc_output_box {\l__codedoc_descr_coffin-l} {\l__codedoc_descr_coffin-t} {0pt} {0pt}
   }
   {
    \coffin_join:NnnNnnnn
      \l__codedoc_output_box {hc} {vc}
      \l__codedoc_syntax_coffin {l} {t}
      {0pt} {0pt}
    \coffin_join:NnnNnnnn
      \l__codedoc_output_box {l} {b}
      \l__codedoc_descr_coffin  {l} {t}
      {0pt} {-\medskipamount}
    \coffin_join:NnnNnnnn
      \l__codedoc_output_box {l} {t}
      \l__codedoc_names_coffin  {r} {t}
      {-\marginparsep} {0pt}

    \coffin_typeset:Nnnnn
      \l__codedoc_output_box {\l__codedoc_syntax_coffin-l} {\l__codedoc_syntax_coffin-T}
      {0pt} {0pt}
   }
  \par
  \allowbreak
 }
\char_set_catcode_other:N \<
\cs_set_eq:NN \variabledoc \function
\cs_set_eq:NN \endvariabledoc \endfunction
\cs_set_nopar:Npn \__codedoc_function:n #1
 {

  \tl_set:Nn \l__codedoc_function_input_tl {#1}

  \dim_zero:N \l__codedoc_trial_width_dim
  \hcoffin_set:Nn \l__codedoc_names_coffin { \function_typeset:n {#1} }
  \dim_set:Nn \l__codedoc_trial_width_dim { \box_wd:N \l__codedoc_names_coffin }

  \bool_set:Nn \l__codedoc_long_name_bool
    { \dim_compare_p:nNn \l__codedoc_trial_width_dim > \marginparwidth }

  \vcoffin_set:Nnw \l__codedoc_descr_coffin {\textwidth}
    \noindent\ignorespaces
 }
\cs_gset_nopar:Npn \function_typeset:n #1 %^^A todo: use "\cs_new:Npn" here
 {
  \tl_gclear:N \g__codedoc_macro_tl

  % populate "\l__codedoc_functions_block_prop" with info on the functions present:
  % with a hack as we don't currently read verbatim and that means that
  % \q_recursion_tail is an issue!
  \str_if_eq:nnTF {#1} { \q_recursion_tail }
    {
      \prop_put:Nxx \l__codedoc_functions_block_prop
        { \cs_to_str:N \q_recursion_tail }
        { { -1 } { } }
    }
    { \clist_map_function:nN {#1} \__codedoc_parse_functions:n }

  \small\ttfamily
  \begin{tabular}{ @{} l @{} r @{} }
    \toprule
    \prop_map_function:NN \l__codedoc_functions_block_prop \__codedoc_typeset_functions:nn
    \__codedoc_typeset_dates:
    \bottomrule
  \end{tabular}
  \normalfont\normalsize
 }
\prop_new:N \l__codedoc_functions_block_prop
\cs_generate_variant:Nn \prop_put:Nnn {Nxx}
\cs_new:Nn \__codedoc_parse_functions:n
 {
  \exp_args:Nxx \tl_if_head_eq_charcode:nNTF { \token_to_str:N #1 } {\cs_to_str:N \\}
   {
    \tl_gset_eq:NN \l__codedoc_function_name_prefix_tl \@backslashchar
    % for the weird functions named "\::N" and so on:
    \exp_args:Nx \tl_if_head_eq_charcode:nNTF { \cs_to_str:N #1 } { : }
     {
      % again, no variants:
      \prop_put:Nxx \l__codedoc_functions_block_prop  { \cs_to_str:N #1 } { {-1} {} }
     }
     {
      % finally, for regular old csnames:
      \exp_args:NNf \prop_get:NnNTF
        \l__codedoc_functions_block_prop
        { \__cs_get_function_name:N #1 } \l__codedoc_tmpb_tl
       {
        \prop_put:Nxx \l__codedoc_functions_block_prop
         { \__cs_get_function_name:N #1 }
         {
           \l__codedoc_tmpb_tl ,
           {\__cs_count_signature:N #1}
           {\__cs_get_function_signature:N #1}
         }
       }
       {
        \prop_put:Nxx \l__codedoc_functions_block_prop
          { \__cs_get_function_name:N #1 }
          {
            {\__cs_count_signature:N #1}
            {\__cs_get_function_signature:N #1}
          }
       }
     }
   }
   {
    % for now don't bother splitting into variants:
    \tl_gclear:N \l__codedoc_function_name_prefix_tl
    \prop_put:Nxx \l__codedoc_functions_block_prop  { \tl_to_str:n {#1} } { {-1} {} }
   }
 }
\cs_new:Nn \__codedoc_typeset_functions:nn
 {
  \clist_gset:Nn \l__codedoc_variants_clist {#2}
  \clist_gpop:NN \l__codedoc_variants_clist \l__codedoc_tmpb_tl
  \exp_args:Nc \__codedoc_typeset_functions_aux:N
   {
    #1
    \int_compare:nT { \exp_after:wN \use_i:nn \l__codedoc_tmpb_tl > -1 } {:}
    \int_compare:nT { \exp_after:wN \use_i:nn \l__codedoc_tmpb_tl >  0 }
      { \exp_after:wN \use_ii:nn \l__codedoc_tmpb_tl }
   }
  \\
 }

\cs_new_nopar:Nn \__codedoc_typeset_functions_aux:N
 {
  \bool_if:NT \l__codedoc_meta_pTF_bool
   {
    \tl_set:Nx \l__codedoc_pTF_name_tl
      { \l__codedoc_function_name_prefix_tl \__codedoc_predicate_from_base:N #1 }
    \__codedoc_special_main_index:o { \l__codedoc_pTF_name_tl }
    \seq_gput_right:Nx \g_doc_functions_seq
      { \tl_to_str:N \l__codedoc_pTF_name_tl }
    \tl_set:Nx \l__codedoc_pTF_name_tl { \__codedoc_predicate_from_base:N #1 }
   }

  \tl_set:Nx \l__codedoc_tmpa_tl
   {
    \l__codedoc_function_name_prefix_tl
    \cs_to_str:N #1
    \bool_if:NT \l__codedoc_meta_TF_bool { \tl_to_str:n {TF} }
   }
  \__codedoc_special_main_index:o { \l__codedoc_tmpa_tl }
  \seq_gput_right:No \g_doc_functions_seq { \l__codedoc_tmpa_tl }

  \bool_if:NTF \l__codedoc_meta_pTF_bool
   {
    \bool_gset_false:N \l__codedoc_meta_TF_bool
    \exp_args:Nc \__codedoc_typeset_function_block:N { \l__codedoc_pTF_name_tl }
    \bool_gset_true:N \l__codedoc_meta_TF_bool

    \\
    \__codedoc_typeset_function_block:N #1
   }
   {
    \exp_args:Nx \tl_if_head_eq_charcode:nNTF { \exp_after:wN \use_none:n \token_to_str:N #1 } {:}
      { \__codedoc_show_macro_unusual:N #1 }
      { \__codedoc_typeset_function_block:N #1 }
   }
}
\cs_set_nopar:Nn \__codedoc_typeset_function_block:N
 {
  \tl_gset:Nx \l__codedoc_function_name_tl { \__cs_get_function_name:N #1 }
  \tl_gset:Nx \l__codedoc_function_sig_tl { \__cs_get_function_signature:N #1 }
  \tl_gset:Nx \g__codedoc_macro_tl { \l__codedoc_function_name_prefix_tl \l__codedoc_function_name_tl }

  \__codedoc_typeset_function_basename:N #1
  \bool_if:NT \l__codedoc_meta_TF_bool { \__codedoc_typeset_TF: }
  \__codedoc_typeset_expandability:
  \clist_if_empty:NF \l__codedoc_variants_clist { \__codedoc_typeset_variants: }
  \bool_if:NT \g__codedoc_full_bool { \__codedoc_label_function:N #1 }
 }
\cs_set:Nn \__codedoc_typeset_function_basename:N
 { \l__codedoc_function_name_prefix_tl \cs_to_str:N #1 }
\cs_set:Nn \__codedoc_typeset_expandability:
 {
  &
  \bool_if:NT \l__codedoc_meta_EXP_bool
   {
    \hspace{\tabcolsep}
    \hyperlink{expstar} {$\star$}
   }
   \bool_if:NT \l__codedoc_meta_rEXP_bool
    {
     \hspace{\tabcolsep}
     \hyperlink{rexpstar} {\ding{73}} % hollow star
    }
 }
\cs_set:Nn \__codedoc_typeset_variants:
 {
  \\
  \__codedoc_typeset_aux:n \g__codedoc_macro_tl :
  \int_compare:nTF { \clist_count:N \l__codedoc_variants_clist == 1 }
   { \exp_after:wN \use_ii:nn \l__codedoc_variants_clist }
   {
     \textrm(
       \clist_pop:NN \l__codedoc_variants_clist \l__codedoc_tmpb_tl
       \exp_after:wN \use_ii:nn \l__codedoc_tmpb_tl
       \clist_map_inline:Nn \l__codedoc_variants_clist {\textrm| \use_ii:nn ##1}
     \textrm)
   }
  \bool_if:NT \l__codedoc_meta_TF_bool { \__codedoc_typeset_TF: }
  &
  \bool_if:NT \l__codedoc_meta_EXP_bool
   {
    \hspace{\tabcolsep}
    \hyperlink{expstar} {$\star$}
   }
  \bool_if:NT \l__codedoc_meta_rEXP_bool
   {
    \hspace{\tabcolsep}
    \hyperlink{rexpstar} {\ding{73}} % hollow star
   }
 }
\cs_set:Nn \__codedoc_label_function:N
 {
  \tl_set:Nx \l__codedoc_tmpa_tl { \l__codedoc_function_name_prefix_tl \cs_to_str:N #1 }
  \exp_args:NNf \tl_replace_all:Nnn \l__codedoc_tmpa_tl {\token_to_str:N _} {/}
  \exp_args:NNf \tl_remove_all:Nn \l__codedoc_tmpa_tl {\@backslashchar}
  \exp_args:Nx \label {doc/function//\l__codedoc_tmpa_tl}
 }
\cs_set_nopar:Nn \__codedoc_show_macro_unusual:N
 {
  \tl_gset:Nx \g__codedoc_macro_tl { \token_to_str:N #1}
  \token_to_str:N #1 &

  \exp_args:NNf \tl_replace_all:Nnn \g__codedoc_macro_tl {\token_to_str:N _} {/}
  \exp_args:NNf \tl_replace_all:Nnn \g__codedoc_macro_tl {\@backslashchar} {}
  \bool_if:NT \g__codedoc_full_bool
   {
    \exp_args:Nx \label { doc/function//\g__codedoc_macro_tl }
   }
 }
\cs_set:Nn \__codedoc_typeset_dates:
 {
  \bool_if:nF { \tl_if_empty_p:N \l__codedoc_date_added_tl &&
                \tl_if_empty_p:N \l__codedoc_date_updated_tl }
   { \midrule }

  \tl_if_empty:NF \l__codedoc_date_added_tl
   {
    \multicolumn{2}{@{}r@{}}
      { \scriptsize New:\,\l__codedoc_date_added_tl } \\
   }

  \tl_if_empty:NF \l__codedoc_date_updated_tl
   {
    \multicolumn{2}{@{}r@{}}
      { \scriptsize Updated:\,\l__codedoc_date_updated_tl } \\
   }
 }
\newenvironment{syntax}
 {
  \small\ttfamily
  \bool_if:NTF \l__codedoc_long_name_bool
    {
     \hbox_gset:Nw \g__codedoc_syntax_box
     \arrayrulecolor{white}
     \begin{tabular}{@{}l@{}}
     \toprule
     \begin{minipage}
       { \textwidth+0.75\marginparwidth-\l__codedoc_trial_width_dim }
    }
    {
     \hbox_gset:Nw \g__codedoc_syntax_box
     \arrayrulecolor{white}
     \begin{tabular}{@{}l@{}}
     \toprule
     \begin{minipage}{ \textwidth }
    }
  \raggedright
  \obeyspaces\obeylines
 }
 {
  \end{minipage}
  \end{tabular}
  \arrayrulecolor{black}
  \hbox_set_end:
  \ignorespacesafterend
 }
\cs_new:Npn \__codedoc_ensuremath_sb:n #1
 {
  \ensuremath{\sb{#1}}
 }
\cs_set_eq:NN \__codedoc_meta:n \meta
\cs_set:Npn \meta
 {
  \group_begin:
    \char_set_active_eq:NN _ \__codedoc_ensuremath_sb:n
    \__codedoc_close_meta:n
 }
\cs_new:Npn \__codedoc_open_meta:w
 {
  \group_begin:
    \char_set_active_eq:NN _ \__codedoc_ensuremath_sb:n
    \__codedoc_close_meta:w
 }
\cs_new:Npn \Arg
 {
  \texttt{ \char`\{ }
  \group_begin:
    \char_set_active_eq:NN _ \__codedoc_ensuremath_sb:n
    \__codedoc_close_Arg:n
 }
\cs_new_nopar:Npn \__codedoc_close_meta:n #1  { \__codedoc_meta:n {#1} \group_end: }
\cs_new_nopar:Npn \__codedoc_close_meta:w #1> { \__codedoc_meta:n {#1} \group_end: }
\cs_new_nopar:Npn \__codedoc_close_Arg:n #1
 {
  \__codedoc_meta:n {#1}
  \group_end:
  \texttt{ \char`\} }
 }
\keys_define:nn { l3doc/macro }
 {
  aux .code:n =
    { \bool_set_true:N \l__codedoc_macro_aux_bool } ,
  internal .code:n =
    { \bool_set_true:N \l__codedoc_macro_internal_bool } ,
  int .code:n =
    { \bool_set_true:N \l__codedoc_macro_internal_bool } ,
  var .code:n =
    { \bool_set_true:N \l__codedoc_macro_var_bool } ,
  TF .code:n =
    { \bool_set_true:N \l__codedoc_macro_TF_bool } ,
  pTF .code:n =
    { \bool_set_true:N \l__codedoc_macro_pTF_bool } ,
  tested .code:n =
    { } ,
  EXP .code:n = {} , % TODO
  rEXP .code:n = {} , % TODO
  added .code:n = {} , % TODO
  updated .code:n = {} , % TODO
 }
\RenewDocumentCommand { \macro } { O{} } { \__codedoc_macro:n {#1} }
\cs_new_protected:Npn \__codedoc_macro:n #1
 {

  \int_compare:nNnTF \currentgrouplevel=2
   { \int_gzero:N \g__codedoc_nested_macro_int }
   { \int_incr:N  \g__codedoc_nested_macro_int }

  \bool_set_false:N \l__codedoc_macro_aux_bool
  \bool_set_false:N \l__codedoc_macro_internal_bool
  \bool_set_false:N \l__codedoc_macro_TF_bool
  \bool_set_false:N \l__codedoc_macro_pTF_bool
  \bool_set_false:N \l__codedoc_macro_var_bool
  \bool_set_false:N \l__codedoc_tested_bool

  \cs_set_eq:NN \__codedoc_macroname_prefix:n \use:n
  \cs_set_eq:NN \__codedoc_macroname_suffix: \c_empty_tl

  \keys_set:nn { l3doc/macro } {#1}

  \cs_set_eq:NN \testfile \__codedoc_print_testfile:n

  \peek_meaning_ignore_spaces:NTF \c_group_begin_token
   {
    \group_begin:
      \MakePrivateLetters
      \char_set_catcode_letter:N \\
      \char_set_catcode_ignore:N \ % space
      \char_set_catcode_ignore:N \^^M
      \char_set_catcode_ignore:N \^^I
      \__codedoc_macro_aux:n
   }
   {
    \__codedoc_macro_verbatim:w
   }
 }
\NewDocumentCommand {\__codedoc_macro_verbatim:w} {v}
 {
  \group_begin: % pretty useless
  \__codedoc_macro_aux:n {#1}
 }
\clist_new:N \l__codedoc_macro_input_clist
\cs_new_nopar:Npn \__codedoc_macro_aux:n #1
 {
  \group_end:
  \clist_set:Nn \l__codedoc_macro_input_clist {#1}
  \bool_if:NTF \l__codedoc_macro_pTF_bool
   {
    \clist_map_inline:Nn \l__codedoc_macro_input_clist
      {
        \exp_args:Nx \__codedoc_macro_single:n { \__codedoc_predicate_from_base:w ##1 \q_nil }
      }
    \bool_set_true:N \l__codedoc_macro_TF_bool
    \clist_map_function:NN \l__codedoc_macro_input_clist \__codedoc_macro_single:n
    \bool_set_false:N \l__codedoc_macro_TF_bool
   }
   { \clist_map_function:NN \l__codedoc_macro_input_clist \__codedoc_macro_single:n }
 }
\cs_set:Nn \__codedoc_predicate_from_base:N
 {
  \__cs_get_function_name:N #1 _p: \__cs_get_function_signature:N #1
 }
\cs_set:Npn \__codedoc_predicate_from_base:w #1 : #2 \q_nil
 {
  #1 _p: #2
 }
\cs_set_nopar:Npn \__codedoc_macro_single:n #1
 {
  \int_incr:N \l__codedoc_macro_int

  \tl_set:Nx \l__codedoc_at_replaced_macro_tl { \token_to_str:N #1 }
  \__codedoc_replace_at_at:N \l__codedoc_at_replaced_macro_tl
  \tl_set_eq:NN \saved@macroname \l__codedoc_at_replaced_macro_tl

  \topsep\MacroTopsep
  \trivlist
  \cs_set_nopar:Npn \makelabel ##1 { \llap{##1} }
  \if@inlabel
    \cs_set_eq:NN \@tempa \@empty
    \count@ \macro@cnt
    \loop \ifnum\count@>\z@
      \cs_set_nopar:Npx \@tempa{\@tempa\hbox{\strut}}
      \advance\count@\m@ne
    \repeat
    \cs_set_nopar:Npx \makelabel ##1
     {
      \llap{\vtop to\baselineskip {\@tempa\hbox{##1}\vss}}
     }
    \advance \macro@cnt \@ne
  \else
    \macro@cnt \@ne
  \fi

  \bool_if:NT \l__codedoc_macro_aux_bool
   {
    \cs_set_eq:NN \__codedoc_macroname_prefix:n \__codedoc_typeset_aux:n
   }
  \bool_if:NT \l__codedoc_macro_TF_bool
   {
    \cs_set_eq:NN \__codedoc_macroname_suffix: \__codedoc_typeset_TF:
   }

  \bool_if:NF \l__codedoc_macro_aux_bool
   {
    \tl_gset:Nx \l__codedoc_macro_tl { \tl_to_str:N \l__codedoc_at_replaced_macro_tl }
    \exp_args:NNf \tl_greplace_all:Nnn \l__codedoc_macro_tl {\token_to_str:N _} {/}
    \exp_args:NNf \tl_greplace_all:Nnn \l__codedoc_macro_tl {\@backslashchar} {}
   }

  \use:x
   {
    \exp_not:N \item [ \exp_not:N \__codedoc_print_macroname:n {
      \tl_to_str:N \l__codedoc_at_replaced_macro_tl
    }]
   }
  \int_gincr:N \c@CodelineNo

  \bool_if:NF \l__codedoc_macro_aux_bool
   {
    \bool_if:NTF \l__codedoc_macro_TF_bool
     {
      \seq_gput_right:Nx \g_doc_macros_seq { \tl_to_str:N \l__codedoc_at_replaced_macro_tl \tl_to_str:n {TF} }
      \seq_gput_right:Nx \g_doc_macros_seq { \tl_to_str:N \l__codedoc_at_replaced_macro_tl \tl_to_str:n {T } }
      \seq_gput_right:Nx \g_doc_macros_seq { \tl_to_str:N \l__codedoc_at_replaced_macro_tl \tl_to_str:n { F} }
     }
     {
      \seq_gput_right:Nx \g_doc_macros_seq { \tl_to_str:N \l__codedoc_at_replaced_macro_tl }
     }
   }
  \bool_if:NTF \l__codedoc_macro_TF_bool
   {
    \exp_args:Nx \SpecialMainIndex{ \tl_to_str:N \l__codedoc_at_replaced_macro_tl TF}\nobreak
    \exp_args:Nx \DoNotIndex{ \tl_to_str:N \l__codedoc_at_replaced_macro_tl TF}
   }
   {
    \exp_args:Nx \SpecialMainIndex{ \tl_to_str:N \l__codedoc_at_replaced_macro_tl }\nobreak
    \exp_args:Nx \DoNotIndex{ \tl_to_str:N \l__codedoc_at_replaced_macro_tl }
   }

  \int_gdecr:N \c@CodelineNo
  \ignorespaces
 }
\tl_clear:N \l__codedoc_macro_tl
\cs_set_nopar:Npn \__codedoc_print_macroname:n #1
 {
  \strut
  \HD@target
  \int_compare:nTF { \tl_count:n {#1} <= 28 }
    { \MacroFont } { \MacroLongFont }

  % INEFFICIENT: (!)
  \exp_args:NNx \seq_if_in:NnTF \g_doc_functions_seq
   { #1 \bool_if:NT \l__codedoc_macro_TF_bool { \tl_to_str:n {TF} } }
   {
    \hyperref [doc/function//\l__codedoc_macro_tl]
   }
   { \use:n }
   {
    \__codedoc_macroname_prefix:n {#1} \__codedoc_macroname_suffix: \ % space!
   }
 }
\providecommand \MacroLongFont
 {
  \fontfamily{lmtt}\fontseries{lc}\small
 }
\cs_set_nopar:Npn \__codedoc_typeset_TF:
 {
  \hyperlink{explTF}
   {
    \color{black}
    \itshape TF
    \makebox[0pt][r]
     {
      \color{red}
      \underline { \phantom{\itshape TF} \kern-0.1em }
     }
   }
 }
\cs_set_nopar:Npn \__codedoc_typeset_aux:n #1
 {
  { \color[gray]{0.7} #1 }
 }
\DeclareDocumentCommand \__codedoc_print_testfile:n {m}
 {
  \bool_set_true:N \l__codedoc_tested_bool
  \tl_if_eq:nnF {#1} {*}
   {
    \seq_if_in:NnF \g__codedoc_testfiles_seq {#1}
     {
      \seq_gput_right:Nn \g__codedoc_testfiles_seq {#1}
      \par
      \__codedoc_print_testfile_aux:n {#1}
     }
   }
 }
\cs_new_protected:Npn \__codedoc_print_testfile_aux:n #1
 {
  \footnotesize
  (
   \textit{
     The~ test~ suite~ for~ this~ command,~
     and~ others~ in~ this~ file,~ is~ \textsf{#1}
   }.
  )\par
 }
\DeclareDocumentCommand \TestFiles {m}
 {
  \par
  {\itshape
    The~ following~ test~ files~ are~ used~ for~ this~ code:~ \textsf{#1}.
  }
  \par\ignorespaces
 }
\DeclareDocumentCommand \UnitTested {} { \testfile* }
\cs_generate_variant:Nn \prop_gput:Nnn {NVx}
\DeclareDocumentCommand \TestMissing {m}
 {
  \prop_if_in:NVTF \g__codedoc_missing_tests_prop \l__codedoc_macro_input_clist
   {
    \prop_get:NVN \g__codedoc_missing_tests_prop \l__codedoc_macro_input_clist \l__codedoc_tmpa_tl
    \prop_gput:NVx \g__codedoc_missing_tests_prop \l__codedoc_macro_input_clist
     {
      *~ \l__codedoc_tmpa_tl
      ^^J \exp_not:n {\space\space\space\space\space\space}
      *~ #1
     }
   }
   { \prop_gput:NVn \g__codedoc_missing_tests_prop \l__codedoc_macro_input_clist {#1} }
 }
\tl_new:N \g__codedoc_module_name_tl
\cs_new_protected:Npn \__codedoc_replace_at_at:N #1
 {
  \tl_if_empty:NF \g__codedoc_module_name_tl
   {
    \tl_replace_all:Non #1 { \token_to_str:N @ } { @ }
    \tl_replace_all:Non #1 { \token_to_str:N _ } { _ }
    \tl_replace_all:Nox #1 { _@ @ } { __ \g__codedoc_module_name_tl }
    \tl_replace_all:Nox #1 { @ @ } { __ \g__codedoc_module_name_tl }
   }
 }
\cs_generate_variant:Nn \tl_replace_all:Nnn { Non, Nox }
\cs_new_protected:Nn \__codedoc_endmacro_build_seq:N
 {
  \seq_gclear:N #1
  \clist_map_inline:Nn \l__codedoc_macro_input_clist
   {
    \tl_set:Nn \l__codedoc_tmpa_tl {##1}
    \__codedoc_replace_at_at:N \l__codedoc_tmpa_tl
    \seq_gput_right:No #1 { \l__codedoc_tmpa_tl }
   }
 }
\cs_set_protected:Nn \__codedoc_endmacro_wrap_each:N
 {
  \bool_if:NTF \l__codedoc_macro_TF_bool
   { \seq_gset_map:NNn #1 #1 { \exp_not:N \texttt { ##1 TF } } }
   { \seq_gset_map:NNn #1 #1 { \exp_not:N \texttt { ##1 } } }
 }
\cs_set:Nn \__codedoc_texttt_comma:n {\,,~\texttt{#1}}
\cs_set:Npn \endmacro
 {
  \int_compare:nT { \g__codedoc_nested_macro_int < 1 }
   {
    \par\nobreak\noindent{\footnotesize(\emph{
    End~ definition~ for~
    \__codedoc_endmacro_build_seq:N \g__codedoc_tmpa_seq
    \__codedoc_endmacro_wrap_each:N \g__codedoc_tmpa_seq
    \int_compare:nTF { \seq_count:N \g__codedoc_tmpa_seq <= 3 }
      {
        \seq_use:Nnnn \g__codedoc_tmpa_seq
          { \,~and~ } { \,,~ } { \,,~and~ }
        \@.
      }
      { \seq_item:Nn \g__codedoc_tmpa_seq {1}\,~and~others. }

    \bool_if:nT
     {
      !\l__codedoc_macro_aux_bool &&
      !\l__codedoc_macro_internal_bool &&
      \int_compare_p:n {\g__codedoc_nested_macro_int<1}
     }
     {
      \int_compare:nNnTF \l__codedoc_macro_int=1 {~This~} {~These~}
      \bool_if:NTF \l__codedoc_macro_var_bool{variable}{function}
      \int_compare:nNnTF \l__codedoc_macro_int=1 {~is~}{s~are~}
      documented~on~page~
      \exp_args:Nx\pageref{doc/function//\l__codedoc_macro_tl}.
     }
    })\par}
   }

  \bool_if:nT
   {
    \g__codedoc_checktest_bool &&
    !( \l__codedoc_macro_aux_bool || \l__codedoc_macro_var_bool ) &&
    !\l__codedoc_tested_bool
   }
   {
    \seq_gput_right:Nx \g__codedoc_not_tested_seq
     {
      \seq_use:Nnnn \g__codedoc_tmpa_seq { , } { , } { , }
      \bool_if:NT \l__codedoc_macro_pTF_bool {~(pTF)}
      \bool_if:NT \l__codedoc_macro_TF_bool {~(TF)}
     }
   }
 }
\group_begin:
  \char_set_catcode_escape:N \/
  \char_set_catcode_other:N \^^A
  \char_set_catcode_active:N \^^S
  \char_set_catcode_active:N \^^B
  \char_set_catcode_other:N \^^L
  \char_set_catcode_other:N \^^R
  \char_set_lccode:nn { `\^^A } { `\% }
  \char_set_lccode:nn { `\^^S } { `\  }
  \char_set_lccode:nn { `\^^B } { `\\ }
  \char_set_lccode:nn { `\^^L } { `\{ }
  \char_set_lccode:nn { `\^^R } { `\} }
  \tl_to_lowercase:n
   {
    \group_end:
    \cs_set_protected:Npn \xmacro@code
        #1 ^^A ^^S^^S^^S^^S ^^Bend ^^Lmacrocode^^R
      { \__codedoc_xmacro_code:n {#1} /end{macrocode} }
   }
\group_begin:
  \char_set_catcode_active:N \<
  \char_set_catcode_active:N \>
  \cs_new_protected:Npn \__codedoc_xmacro_code:n #1
   {
    \tl_if_in:nnTF {#1} { < @ @ = }
     { \__codedoc_xmacro_code:w #1 \q_stop }
     {
      \tl_set:Nn \l__codedoc_tmpa_tl {#1}
      \__codedoc_replace_at_at:N \l__codedoc_tmpa_tl
      \tl_use:N \l__codedoc_tmpa_tl
     }
   }
  \cs_new_protected:Npn \__codedoc_xmacro_code:w #1 < @ @ = #2 > #3 \q_stop
   {
    \tl_set:Nn \l__codedoc_tmpa_tl {#1}
    \__codedoc_replace_at_at:N \l__codedoc_tmpa_tl

    \tl_gset:Nn \g__codedoc_module_name_tl {#2}
    \tl_put_right:Nn \l__codedoc_tmpa_tl { < @ @ = #2 > }

    \tl_set:Nn \l__codedoc_tmpb_tl {#3}
    \__codedoc_replace_at_at:N \l__codedoc_tmpb_tl
    \tl_put_right:No \l__codedoc_tmpa_tl { \l__codedoc_tmpb_tl }

    \tl_use:N \l__codedoc_tmpa_tl
   }
\group_end:
\newcommand*{\DescribeOption}
 {
  \leavevmode
  \@bsphack
  \begingroup
    \MakePrivateLetters
    \Describe@Option
 }
\newcommand*{\Describe@Option}[1]
 {
  \endgroup
  \marginpar{
    \raggedleft
    \PrintDescribeEnv{#1}
  }
  \SpecialOptionIndex{#1}
  \@esphack
  \ignorespaces
 }
\newcommand*{\SpecialOptionIndex}[1]
 {
  \@bsphack
  \begingroup
    \HD@target
    \let\HDorg@encapchar\encapchar
    \edef\encapchar usage
     {
      \HDorg@encapchar hdclindex{\the\c@HD@hypercount}{usage}
     }
    \index
     {
      #1\actualchar{\protect\ttfamily#1}~(option)
      \encapchar usage
     }
    \index
     {
      options:\levelchar#1\actualchar{\protect\ttfamily#1}
      \encapchar usage
     }
  \endgroup
  \@esphack
 }
\font\manual=manfnt
\cs_set_nopar:Npn \dbend { {\manual\char127} }
\newenvironment {danger}
 {
  \begin{trivlist}\item[]\noindent
  \begingroup\hangindent=2pc\hangafter=-2
  \cs_set_nopar:Npn \par{\endgraf\endgroup}
  \hbox to0pt{\hskip-\hangindent\dbend\hfill}\ignorespaces
 }
 {
  \par\end{trivlist}
 }
\newenvironment {ddanger}
 {
  \begin{trivlist}\item[]\noindent
  \begingroup\hangindent=3.5pc\hangafter=-2
  \cs_set_nopar:Npn \par{\endgraf\endgroup}
  \hbox to0pt{\hskip-\hangindent\dbend\kern2pt\dbend\hfill}\ignorespaces
 }{
  \par\end{trivlist}
 }
\newenvironment{TemplateInterfaceDescription}[1]
 {
  \subsection{The~object~type~`#1'}
  \begingroup
  \@beginparpenalty\@M
  \description
  \def\TemplateArgument##1##2{\item[Arg:~##1]##2\par}
  \def\TemplateSemantics
   {
    \enddescription\endgroup
    \subsubsection*{Semantics:}
   }
 }
 {
  \par\bigskip
 }
\newenvironment{TemplateDescription}[2]
  {
   \subsection{The~template~`#2'~(object~type~#1)}
   \subsubsection*{Attributes:}
   \begingroup
   \@beginparpenalty\@M
   \description
   \def\TemplateKey##1##2##3##4
    {
     \item[##1~(##2)]##3%
     \ifx\TemplateKey##4\TemplateKey\else
         \hfill\penalty500\hbox{}\hfill Default:~##4%
         \nobreak\hskip-\parfillskip\hskip0pt\relax
     \fi
     \par
    }
   \def\TemplateSemantics
    {
     \enddescription\endgroup
     \subsubsection*{Semantics~\&~Comments:}
    }
  }
  {\par\bigskip}
\newenvironment{InstanceDescription}[4][xxxxxxxxxxxxxxx]
  {
   \subsubsection{The~instance~`#3'~(template~#2/#4)}
   \subsubsection*{Attribute~values:}
   \begingroup
   \@beginparpenalty\@M
   \def\InstanceKey##1##2{\>\textbf{##1}\>##2\\}
   \def\InstanceSemantics{\endtabbing\endgroup
       \vskip-30pt\vskip0pt
       \subsubsection*{Layout~description~\&~Comments:}}
   \tabbing
   xxxx\=#1\=\kill
  }
  {\par\bigskip}
\cs_set_nopar:Npn \AlsoImplementation
 {
  \bool_set_true:N \g__codedoc_implementation_bool
  \cs_set:Npn \StopEventually ##1
   {
    \@bsphack
    \cs_gset_nopar:Npn \Finale { ##1 \check@checksum }
    \init@checksum
    \@esphack
   }
 }
\AlsoImplementation
\cs_set_nopar:Npn \OnlyDescription
 {
  \@bsphack
  \bool_set_false:N \g__codedoc_implementation_bool
  \cs_set:Npn \StopEventually ##1 { ##1 \endinput }
  \@esphack
 }
\cs_set_eq:NN \Finale \relax
\cs_set_nopar:Npn \partname{File}
\cs_set:Npn \DocInput #1
 {
  \clist_map_inline:nn {#1}
   {
    \clist_put_right:Nn \g_docinput_clist {##1}
    \tl_gclear:N \g__codedoc_module_name_tl
    \MakePercentIgnore
    \input{##1}
    \MakePercentComment
   }
 }
\cs_set:Npn \DocInputAgain
 {
  \clist_map_inline:Nn \g_docinput_clist
   {
    \MakePercentIgnore
    \tl_gclear:N \g__codedoc_module_name_tl
    \input{##1}
    \MakePercentComment
   }
 }
\cs_set_nopar:Npn \partname{File}
\newcommand*{\DocInclude}[1]
 {
  \relax\clearpage
  \docincludeaux
  \IfFileExists{#1.fdd}
   { \cs_set_nopar:Npn \currentfile{#1.fdd} }
   { \cs_set_nopar:Npn \currentfile{#1.dtx} }
  \ifnum\@auxout=\@partaux
    \@latexerr{\string\include\space cannot~be~nested}\@eha
  \else
    \@docinclude #1
  \fi
 }
\cs_set_nopar:Npn \@docinclude #1
 {
  \clearpage
  \immediate\write\@mainaux{\string\@input{#1.aux}}
  \@tempswatrue
  \if@partsw
    \@tempswafalse
    \cs_set_nopar:Npx \@tempb{#1}
    \@for\@tempa:=\@partlist\do
     {
      \ifx\@tempa\@tempb\@tempswatrue\fi
     }
  \fi
  \if@tempswa
    \cs_set_eq:NN \@auxout\@partaux
    \immediate\openout\@partaux #1.aux
    \immediate\write\@partaux{\relax}
    \cs_set_eq:NN \@ltxdoc@PrintIndex\PrintIndex
    \cs_set_eq:NN \PrintIndex\relax
    \cs_set_eq:NN \@ltxdoc@PrintChanges\PrintChanges
    \cs_set_eq:NN \PrintChanges\relax
    \cs_set_eq:NN \@ltxdoc@theglossary\theglossary
    \cs_set_eq:NN \@ltxdoc@endtheglossary\endtheglossary
    \part{\currentfile}
    {
      \cs_set_eq:NN \ttfamily\relax
      \cs_gset_nopar:Npx \filekey{\filekey, \thepart={\ttfamily\currentfile}}
    }
    \DocInput{\currentfile}
    \cs_set_eq:NN \PrintIndex\@ltxdoc@PrintIndex
    \cs_set_eq:NN \PrintChanges\@ltxdoc@PrintChanges
    \cs_set_eq:NN \theglossary\@ltxdoc@theglossary
    \cs_set_eq:NN \endtheglossary\@ltxdoc@endtheglossary
    \clearpage
    \@writeckpt{#1}
    \immediate\closeout\@partaux
  \else
    \@nameuse{cp@#1}
  \fi
  \cs_set_eq:NN \@auxout\@mainaux
 }
\cs_gset_nopar:Npn \codeline@wrindex #1
 {
  \immediate\write\@indexfile
   {
    \string\indexentry{#1}
    { \filesep \int_use:N \c@CodelineNo }
   }
 }
\cs_set_eq:NN \filesep \@empty
\cs_set_nopar:Npn \docincludeaux
 {
  \cs_set_nopar:Npn \thepart {\alphalph{part}}
  \cs_set_nopar:Npn \filesep {\thepart-}
  \cs_set_eq:NN \filekey\@gobble
  \g@addto@macro\index@prologue
   {
    \cs_gset_nopar:Npn\@oddfoot
     {
      \parbox{\textwidth}
       {
        \strut\footnotesize
        \raggedright{\bfseries File~Key:}~\filekey
       }
     }
    \cs_set_eq:NN \@evenfoot\@oddfoot
   }
  \cs_gset_eq:NN \docincludeaux\relax
  \cs_gset_nopar:Npn\@oddfoot
   {
    \expandafter\ifx\csname ver@\currentfile\endcsname\relax
      File~\thepart :~{\ttfamily\currentfile}~
    \else
      \GetFileInfo{\currentfile}
      File~\thepart :~{\ttfamily\filename}~
      Date:~\ExplFileDate\ % space
      Version~\ExplFileVersion
    \fi
    \hfill\thepage
   }
  \cs_set_eq:NN \@evenfoot \@oddfoot
 }
\iow_new:N \g__codedoc_func_iow
\cs_new_nopar:Npn \__codedoc_show_functions_defined:
 {
  \bool_if:nT { \g__codedoc_implementation_bool && \g__codedoc_checkfunc_bool }
   {
    \typeout{ ======================================== ^^J }
    \iow_open:Nn \g__codedoc_func_iow { \c_job_name_tl .cmds }

    \tl_clear:N \l__codedoc_tmpa_tl
    \seq_map_inline:Nn \g_doc_functions_seq
     {
      \seq_if_in:NnT \g_doc_macros_seq {##1}
       {
        \tl_put_right:Nn \l__codedoc_tmpa_tl { ##1 ^^J }
        \iow_now:Nn \g__codedoc_func_iow { > ~ ##1 }
       }
     }

    \__codedoc_functions_typeout:n
     {
      Functions~both~documented~and~defined:^^J
      (In~order~of~being~documented)
     }

    \seq_map_inline:Nn \g_doc_functions_seq
     {
      \seq_if_in:NnF \g_doc_macros_seq {##1}
       {
        \tl_put_right:Nn \l__codedoc_tmpa_tl { ##1 ^^J }
        \iow_now:Nn \g__codedoc_func_iow { ! ~ ##1}
       }
     }
    \__codedoc_functions_typeout:n { Functions~documented~but~not~defined: }

    \seq_map_inline:Nn \g_doc_macros_seq
     {
      \seq_if_in:NnF \g_doc_functions_seq {##1}
       {
        \tl_put_right:Nn \l__codedoc_tmpa_tl { ##1 ^^J }
        \iow_now:Nn \g__codedoc_func_iow { ? ~ ##1}
       }
     }
    \__codedoc_functions_typeout:n { Functions~defined~but~not~documented: }

    \iow_close:N \g__codedoc_func_iow
    \typeout{ ======================================== }
  }
}
\AtEndDocument{ \__codedoc_show_functions_defined: }
\cs_set_nopar:Npn \__codedoc_functions_typeout:n #1
 {
  \tl_if_empty:NF \l__codedoc_tmpa_tl
   {
    \typeout
     {
      -------------------------------------- ^^J #1 ^^J
      -------------------------------------- ^^J \l__codedoc_tmpa_tl
     }
    \tl_clear:N \l__codedoc_tmpa_tl
   }
 }
\cs_new:Npn \__codedoc_show_not_tested:
 {
  \bool_if:NT \g__codedoc_checktest_bool
   {
    \bool_if:nT { !(\seq_if_empty_p:N  \g__codedoc_not_tested_seq) ||
                  !(\prop_if_empty_p:N \g__codedoc_missing_tests_prop) }
     {
      \tl_clear:N \l__codedoc_tmpa_tl
      \prop_if_empty:NF \g__codedoc_missing_tests_prop
       {
        \tl_put_right:Nn \l__codedoc_tmpa_tl
         {
          ^^J^^JThe~ following~ macro(s)~ have~ incomplete~ tests:^^J
         }
        \prop_map_inline:Nn \g__codedoc_missing_tests_prop
         {
          \tl_put_right:Nn \l__codedoc_tmpa_tl
          {^^J\space\space\space\space ##1
           ^^J\space\space\space\space\space\space ##2}
         }
       }
      \seq_if_empty:NF \g__codedoc_not_tested_seq
       {
        \tl_put_right:Nn \l__codedoc_tmpa_tl
         {
          ^^J^^J
          The~ following~ macro(s)~ do~ not~ have~ any~ tests:^^J
         }
        \seq_map_inline:Nn \g__codedoc_not_tested_seq
         {
          \clist_map_inline:nn {##1}
           {
            \tl_put_right:Nn \l__codedoc_tmpa_tl {^^J\space\space\space\space ####1}
           }
         }
        \int_set:Nn \l_tmpa_int {\etex_interactionmode:D}
        \errorstopmode
        \ClassError{l3doc}{\l__codedoc_tmpa_tl}{}
        \int_set:Nn \etex_interactionmode:D {\l_tmpa_int}
       }
     }
   }
 }
\AtEndDocument{ \__codedoc_show_not_tested: }
\g@addto@macro\theindex{\MakePrivateLetters}
\cs_set:Npn \verbatimchar {&}
\setcounter{IndexColumns}{2}
\IndexPrologue
 {
  \part*{Index}
  \markboth{Index}{Index}
  \addcontentsline{toc}{part}{Index}
  The~italic~numbers~denote~the~pages~where~the~
  corresponding~entry~is~described,~
  numbers~underlined~point~to~the~definition,~
  all~others~indicate~the~places~where~it~is~used.
 }

\cs_set_nopar:Npn \__codedoc_special_main_index:n #1
 {
  \HD@target
  \index
   {
    \@gobble#1
    \actualchar
    \string\verb\quotechar*\verbatimchar#1\verbatimchar
    \encapchar
    hdclindex{\the\c@HD@hypercount}{usage}
   }
 }
\cs_generate_variant:Nn \__codedoc_special_main_index:n { o , x }
\msg_new:nnn {l3doc} {print-index-howto}
 {
  Generate~the~index~by~executing\\
  \iow_indent:n { makeindex~-s~l3doc.ist~-o~\c_job_name_tl .ind~\c_job_name_tl .idx }
 }
\tl_gput_right:Nn \PrintIndex { \AtEndDocument{ \msg_info:nn {l3doc} {print-index-howto} } }
\GlossaryPrologue
 {
  \part*{Change~History}
  {\GlossaryParms\ttfamily\hyphenchar\font=`\-}
  \markboth{Change~History}{Change~History}
  \addcontentsline{toc}{part}{Change~History}
 }
\msg_new:nnn {l3doc} {print-changes-howto}
 {
  Generate~the~change~list~by~executing\\
  \iow_indent:n { makeindex~-s~gglo.ist~-o~\c_job_name_tl .gls~\c_job_name_tl .glo }
 }
\tl_gput_right:Nn \PrintChanges { \AtEndDocument{ \msg_info:nn {l3doc} {print-changes-howto} } }
\bool_if:NTF \g__codedoc_full_bool
 {
  \RecordChanges
  \CodelineIndex
  \EnableCrossrefs
  \AlsoImplementation
 }
 {
  \CodelineNumbered
  \DisableCrossrefs
  \OnlyDescription
 }
\tl_new:N \Team
\tl_set:Nn \Team
 {
  The~\LaTeX3~Project\thanks
   {
    Frank~Mittelbach,~Denys~Duchier,~Chris~Rowley,~
    Rainer~Sch\"opf,~Johannes~Braams,~Michael~Downes,~
    David~Carlisle,~Alan~Jeffrey,~Morten~H\o{}gholm,~Thomas~Lotze,~
    Javier~Bezos,~Will~Robertson,~Joseph~Wright,~Bruno~Le~Floch
   }
 }
\NewDocumentCommand{\ExplMakeTitle}{mm}
 {
  \title
   {
    The~\pkg{#1}~package \\ #2
    \thanks
     {
      This~file~describes~v\ExplFileVersion,~
      last~revised~\ExplFileDate.
     }
   }
   \author
    {
     The~\LaTeX3~Project\thanks{E-mail:~
     \href{mailto:latex-l@listserv.uni-heidelberg.de}
          {latex-l@listserv.uni-heidelberg.de}}
    }
   \date{Released~\ExplFileDate}
   \maketitle
 }
\DeclareDocumentCommand\ie{}{\emph{i.e.}}
\DeclareDocumentCommand\eg{}{\emph{e.g.}}
\DeclareDocumentCommand\Ie{}{\emph{I.e.}}
\DeclareDocumentCommand\Eg{}{\emph{E.g.}}
\AtBeginDocument
 {
  \clist_map_inline:nn
   {
    asin, acos, atan, acot,
    asinh, acosh, atanh, acoth, round, floor, ceil
   }
   { \exp_args:Nc \DeclareMathOperator{#1}{#1} }
 }
\NewDocumentCommand { \nan } { } { \text { \texttt { nan } } }
%% 
%%
%% End of file `l3doc.cls'.
