%%
%% This is file `skdoc.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% skdoc.dtx  (with options: `class')
%% 
%% skdoc documentation class
%%
%% Copyright (C) 2012-2013 by Simon Sigurdhsson <sigurdhsson@gmail.com>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Simon Sigurdhsson.
%%
%% This work consists of the files skdoc.dtx
%% and the derived filebase skdoc.cls.
\RequirePackage{expl3}
\ProvidesExplClass{skdoc}
    {2013/11/28}{1.4a}{skdoc documentation class}
\PassOptionsToPackage{log-declarations=false}{xparse}
\LoadClass[ DIV7,
            headings=big,
            numbers=noenddot,
            abstracton,
            bibliography=totocnumbered,
            index=totoc
        ]{scrartcl}
\RequirePackage{etoolbox,xstring,xparse,atbegshi,kvoptions,pdftexcmds,everyhook}
\RequirePackage{verbatim,needspace,marginnote,calc,hyperref,multicol,hologo}
\RequirePackage[nomain,xindy,numberedsection,order=letter,
                sanitizesort=false]{glossaries}
\RequirePackage{ydoc-code,ydoc-desc}
\RequirePackage{scrpage2}
\AtEndOfClass{%
    \RequirePackage[\skdoc@babel]{babel}
    \RequirePackage[english=british]{csquotes}
    \RequirePackage[font=small,labelfont=bf,textfont=it]{caption}
    \RequirePackage{PTSerif,sourcecodepro}
    \RequirePackage[defaultsans,osfigures,scale=0.95]{opensans}
    \RequirePackage[babel]{microtype}
}
\msg_new:nnn{skdoc}{key-exists}{File~key~"#1"~already~declared!}
\msg_new:nnn{skdoc}{key-nexists}{File~key~"#1"~hasn't~been~declared!}
\msg_new:nnn{skdoc}{wrote-file}{Writing~things~to~file~"#1".}
\msg_new:nnn{skdoc}{read-preamble}{Reading~preamble~from~file~"#1".}
\msg_new:nnn{skdoc}{no-lppl}{Could~not~include~LPPL:~lppl.tex~does~not~exist!}
\msg_new:nnn{skdoc}{no-minted}{Syntax~highlighting~disabled:~couldn't~find~minted.sty!}
\msg_new:nnn{skdoc}{no-shell-escape}{Syntax~highlighting~disabled:~running~without~unrestricted~\string\write18.}
\msg_new:nnn{skdoc}{no-pygments}{Syntax~highlighting~disabled:~couldn't~find~"pygmentize".}
\msg_new:nnnn{skdoc}{bibtex-unsupported}{The `bibtex` package is unsupported: continue at own risk!}{Use a more modern bibliography system (i.e. `biblatex`) instead.}
\bool_new:N\g__skdoc_use_minted_bool
\bool_gset_false:N\g__skdoc_use_minted_bool
\bool_new:N\g__skdoc_no_index_bool
\bool_gset_false:N\g__skdoc_no_index_bool
\bool_new:N\g__skdoc_in_example_bool
\bool_gset_false:N\g__skdoc_in_example_bool
\bool_new:N\g__skdoc_with_implementation_bool
\bool_gset_true:N\g__skdoc_with_implementation_bool
\bool_new:N\g__skdoc_in_implementation_bool
\bool_gset_false:N\g__skdoc_in_implementation_bool
\bool_new:N\g__skdoc_negative_space_bool
\bool_gset_false:N\g__skdoc_negative_space_bool
\prg_new_conditional:Nnn\__skdoc_if_print_code:{p,T,F,TF}{
    \bool_if:nTF{
        \g__skdoc_in_implementation_bool &&
        !\g__skdoc_with_implementation_bool
    }{
        \prg_return_false:
    }{
        \prg_return_true:
    }
}
\SetupKeyvalOptions{
    family=skdoc,
    prefix=skdoc@
}
\DeclareStringOption{load}[\jobname]
\DeclareStringOption[british]{babel}
\DeclareBoolOption[true]{highlight}
\ProcessKeyvalOptions*
\IfStrEq{\skdoc@load}{}{}{%
    \IfFileExists{\skdoc@load.sty}{%
        \RequirePackage{\skdoc@load}
    }{}
}
\prg_new_conditional:Nnn\__skdoc_if_shellescape:{T,F,TF}{
    \if_cs_exist:N\pdf@shellescape
        \if_int_compare:w\pdf@shellescape=\c_one
            \prg_return_true:
        \else:
            \prg_return_false:
        \fi:
    \else:
        \prg_return_true:
    \fi:
}
\cs_new:Npn\__skdoc_rm:n#1{
    \immediate\write18{rm~#1}
}
\prg_new_conditional:Nnn\__skdoc_if_pygmentize:{T,F,TF}{
    \immediate\write18{which~pygmentize~&&~touch~\jobname.aex}
    \bool_set:Nn\l_tmpa_bool{\c_false_bool}
    \file_if_exist:nT{\jobname.aex}{
        \__skdoc_rm:n{\jobname.aex}
        \bool_set:Nn\l_tmpa_bool{\c_true_bool}
    }
    \if_bool:N\l_tmpa_bool
        \prg_return_true:
    \else:
        \prg_return_false:
    \fi:
}
\ifskdoc@highlight
    \IfFileExists{\skdoc@load.sty}{
        \__skdoc_if_shellescape:TF{
            \__skdoc_if_pygmentize:TF{
                \bool_gset_true:N\g__skdoc_use_minted_bool
                \RequirePackage{minted}
                \renewcommand{\theFancyVerbLine}{
                    \sffamily\tiny\textcolor{lightgray}{
                    \oldstylenums{\arabic{FancyVerbLine}}}
                }
                \renewcommand\minted@usedefaultstyle{}
                \def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%
                    \let\PY@ul=\relax \let\PY@tc=\relax%
                    \let\PY@bc=\relax \let\PY@ff=\relax}
                \def\PY@tok##1{\csname PY@tok@##1\endcsname}
                \def\PY@toks##1+{\ifx\relax##1\empty\else%
                    \PY@tok{##1}\expandafter\PY@toks\fi}
                \def\PY@do##1{\PY@bc{\PY@tc{\PY@ul{%
                    \PY@it{\PY@bf{\PY@ff{##1}}}}}}}
                \def\PY##1##2{\PY@reset\PY@toks##1+\relax+\PY@do{##2}}
                \expandafter\def\csname PY@tok@gd\endcsname{%
                    \def\PY@tc####1{\textcolor{scriptcolor}{####1}}}
                \expandafter\def\csname PY@tok@gu\endcsname{%
                    \let\PY@bf=\textbf%
                    \def\PY@tc####1{\textcolor{optioncolor}{####1}}}
                \expandafter\def\csname PY@tok@gt\endcsname{%
                    \def\PY@tc####1{\textcolor{scriptcolor}{####1}}}
                \expandafter\def\csname PY@tok@gs\endcsname{%
                    \let\PY@bf=\textbf}
                \expandafter\def\csname PY@tok@gr\endcsname{%
                    \def\PY@tc####1{\textcolor{scriptcolor}{####1}}}
                \expandafter\def\csname PY@tok@cm\endcsname{%
                    \let\PY@it=\textit%
                    \def\PY@tc####1{\textcolor{lightgray}{####1}}}
                \expandafter\def\csname PY@tok@vg\endcsname{%
                    \def\PY@tc####1{\textcolor{scriptcolor}{####1}}}
                \expandafter\def\csname PY@tok@m\endcsname{%
                    \def\PY@tc####1{\textcolor{meta}{####1}}}
                \expandafter\def\csname PY@tok@mh\endcsname{%
                    \def\PY@tc####1{\textcolor{meta}{####1}}}
                \expandafter\def\csname PY@tok@cs\endcsname{%
                    \let\PY@it=\textit%
                    \def\PY@tc####1{\textcolor{macroimpl}{####1}}}
                \expandafter\def\csname PY@tok@ge\endcsname{%
                    \let\PY@it=\textit}
                \expandafter\def\csname PY@tok@vc\endcsname{%
                    \def\PY@tc####1{\textcolor{scriptcolor}{####1}}}
                \expandafter\def\csname PY@tok@il\endcsname{%
                    \def\PY@tc####1{\textcolor{meta}{####1}}}
                \expandafter\def\csname PY@tok@go\endcsname{%
                    \def\PY@tc####1{\textcolor{gray}{####1}}}
                \expandafter\def\csname PY@tok@cp\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp!75}{####1}}}
                \expandafter\def\csname PY@tok@gi\endcsname{%
                    \def\PY@tc####1{\textcolor{bright}{####1}}}
                \expandafter\def\csname PY@tok@gh\endcsname{%
                    \let\PY@bf=\textbf%
                    \def\PY@tc####1{\textcolor{section}{####1}}}
                \expandafter\def\csname PY@tok@ni\endcsname{%
                    \let\PY@bf=\textbf%
                    \def\PY@tc####1{\textcolor{keydesc}{####1}}}
                \expandafter\def\csname PY@tok@nn\endcsname{%
                    \let\PY@ul=\underline%
                    \def\PY@tc####1{\textcolor{black}{####1}}}
                \expandafter\def\csname PY@tok@no\endcsname{%
                    \def\PY@tc####1{\textcolor{scriptcolor}{####1}}}
                \expandafter\def\csname PY@tok@na\endcsname{%
                    \def\PY@tc####1{\textcolor{meta!50}{####1}}}
                \expandafter\def\csname PY@tok@nb\endcsname{%
                    \def\PY@tc####1{\textcolor{black}{####1}}}
                \expandafter\def\csname PY@tok@nc\endcsname{%
                    \let\PY@ul=\underline%
                    \def\PY@tc####1{\textcolor{bright}{####1}}}
                \expandafter\def\csname PY@tok@nd\endcsname{%
                    \def\PY@tc####1{\textcolor{gray}{####1}}}
                \expandafter\def\csname PY@tok@si\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp}{####1}}}
                \expandafter\def\csname PY@tok@nf\endcsname{%
                    \def\PY@tc####1{\textcolor{bright}{####1}}}
                \expandafter\def\csname PY@tok@s2\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp}{####1}}}
                \expandafter\def\csname PY@tok@vi\endcsname{%
                    \def\PY@tc####1{\textcolor{scriptcolor}{####1}}}
                \expandafter\def\csname PY@tok@nt\endcsname{%
                    \let\PY@bf=\textbf%
                    \def\PY@tc####1{\textcolor{meta!50}{####1}}}
                \expandafter\def\csname PY@tok@nv\endcsname{%
                    \def\PY@tc####1{\textcolor{scriptcolor}{####1}}}
                \expandafter\def\csname PY@tok@s1\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp}{####1}}}
                \expandafter\def\csname PY@tok@gp\endcsname{%
                    \def\PY@tc####1{\textcolor{gray}{####1}}}
                \expandafter\def\csname PY@tok@sh\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp}{####1}}}
                \expandafter\def\csname PY@tok@ow\endcsname{%
                    \def\PY@tc####1{\textcolor{macroimpl}{####1}}}
                \expandafter\def\csname PY@tok@sx\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp}{####1}}}
                \expandafter\def\csname PY@tok@bp\endcsname{%
                    \def\PY@tc####1{\textcolor{black}{####1}}}
                \expandafter\def\csname PY@tok@c1\endcsname{%
                    \let\PY@it=\textit%
                    \def\PY@tc####1{\textcolor{lightgray}{####1}}}
                \expandafter\def\csname PY@tok@kc\endcsname{%
                    \def\PY@tc####1{\textcolor{macroimpl}{####1}}}
                \expandafter\def\csname PY@tok@c\endcsname{%
                    \let\PY@it=\textit%
                    \def\PY@tc####1{\textcolor{lightgray}{####1}}}
                \expandafter\def\csname PY@tok@mf\endcsname{%
                    \def\PY@tc####1{\textcolor{meta}{####1}}}
                \expandafter\def\csname PY@tok@err\endcsname{%
                    \def\PY@tc####1{\textcolor{intlink}{####1}}%
                    \def\PY@bc####1{\setlength{\fboxsep}{0pt}%
                    \colorbox{bright}{\strut ####1}}}
                \expandafter\def\csname PY@tok@kd\endcsname{%
                    \def\PY@tc####1{\textcolor{macroimpl}{####1}}}
                \expandafter\def\csname PY@tok@ss\endcsname{%
                    \def\PY@tc####1{\textcolor{macroimpl}{####1}}}
                \expandafter\def\csname PY@tok@sr\endcsname{%
                    \def\PY@tc####1{\textcolor{meta}{####1}}}
                \expandafter\def\csname PY@tok@mo\endcsname{%
                    \def\PY@tc####1{\textcolor{meta}{####1}}}
                \expandafter\def\csname PY@tok@mi\endcsname{%
                    \def\PY@tc####1{\textcolor{meta}{####1}}}
                \expandafter\def\csname PY@tok@kn\endcsname{%
                    \def\PY@tc####1{\textcolor{macroimpl}{####1}}}
                \expandafter\def\csname PY@tok@kr\endcsname{%
                    \def\PY@tc####1{\textcolor{macroimpl}{####1}}}
                \expandafter\def\csname PY@tok@s\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp}{####1}}}
                \expandafter\def\csname PY@tok@kp\endcsname{%
                    \def\PY@tc####1{\textcolor{macroimpl}{####1}}}
                \expandafter\def\csname PY@tok@w\endcsname{%
                    \def\PY@tc####1{\textcolor{lightgray}{####1}}}
                \expandafter\def\csname PY@tok@kt\endcsname{%
                    \def\PY@tc####1{\textcolor{black}{####1}}}
                \expandafter\def\csname PY@tok@sc\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp}{####1}}}
                \expandafter\def\csname PY@tok@sb\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp}{####1}}}
                \expandafter\def\csname PY@tok@k\endcsname{%
                    \def\PY@tc####1{\textcolor{macroimpl}{####1}}}
                \expandafter\def\csname PY@tok@se\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp}{####1}}}
                \expandafter\def\csname PY@tok@sd\endcsname{%
                    \def\PY@tc####1{\textcolor{sharp}{####1}}}
                \expandafter\def\csname PY@tok@nl\endcsname{%
                    \def\PY@tc####1{\textcolor{bright}{####1}}}
                \expandafter\def\csname PY@tok@ne\endcsname{%
                    \def\PY@tc####1{\textcolor{bright}{####1}}}
                \expandafter\def\csname PY@tok@o\endcsname{%
                    \def\PY@tc####1{\textcolor{macroimpl}{####1}}}
                \def\PYZbs{\char`\\}
                \def\PYZus{\char`\_}
                \def\PYZob{\char`\{}
                \def\PYZcb{\char`\}}
                \def\PYZca{\char`\^}
                \def\PYZam{\char`\&}
                \def\PYZlt{\char`\<}
                \def\PYZgt{\char`\>}
                \def\PYZsh{\char`\#}
                \def\PYZpc{\char`\%}
                \def\PYZdl{\char`\$}
                \def\PYZhy{\char`\-}
                \def\PYZsq{\char`\'}
                \def\PYZdq{\char`\"}
                \def\PYZti{\char`\~}
                \def\PYZat{@}
                \def\PYZlb{[}
                \def\PYZrb{]}
            }{
                \msg_warning:nn{skdoc}{no-pygments}
            }
        }{
            \msg_warning:nn{skdoc}{no-shell-escape}
        }
    }{
        \msg_warning:nn{skdoc}{no-minted}
    }
\fi
\tl_new:N\skdoc@temptl
\ior_new:N\skdoc@input
\iow_new:N\skdoc@output
\DeclareDocumentCommand\DeclareFile{om}{
    \group_begin:
    \keys_define:nn{skdoc@declarefile}{%
        preamble .value_required:,
        preamble .code:n = \edef\skdoc@preamble{##1},
        key .value_required:,
        key .code:n = \def\skdoc@key{##1}
    }%
    \def\skdoc@preamble{}%
    \def\skdoc@key{#2}%
    \IfNoValueTF{#1}{}{\keys_set:nn{skdoc@declarefile}{#1}}
    \int_if_exist:cTF{skdoc@output@\skdoc@key @line}{
        \msg_critical:nnx{skdoc}{key-exists}{\skdoc@key}
    }{
        \int_zero_new:c{skdoc@output@\skdoc@key @line}
    }
    \tl_new:c{skdoc@output@\skdoc@key}
    \IfStrEq{\skdoc@preamble}{}{
        \def\skdoc@preamble@extra{}
    }{
        \tl_set:Nx\l_tmpa_tl{\skdoc@preamble}
        \edef\skdoc@temp{\tl_head:N\l_tmpa_tl}
        \def\skdoc@preamble@extra{
            \skdoc@temp\skdoc@temp\space~This~is~file~`#2',~generated~from~`\c_job_name_tl.tex'~(key~`\skdoc@key').
        }
    }
    \expandafter\xdef\csname skdoc@write@#2\endcsname{%
        \noexpand\msg_log:nnn{skdoc}{wrote-file}{#2}
        \noexpand\iow_open:Nn\noexpand\skdoc@output{#2}
        \noexpand\IfStrEq{\skdoc@preamble}{}{}{
            \noexpand\iow_now:Nx\noexpand\skdoc@output{\skdoc@preamble@extra}
            \noexpand\iow_now:Nx\noexpand\skdoc@output{\skdoc@preamble}
        }
        \noexpand\iow_now:Nx\noexpand\skdoc@output{\noexpand\tl_to_str:c{skdoc@output@\skdoc@key}}
        \noexpand\iow_close:N\noexpand\skdoc@output
    }
    \AfterEndDocument{\csname skdoc@write@#2\endcsname}
    \group_end:
}
\clist_new:N\l__skdoc_keys
\DeclareDocumentEnvironment{skdoc@verbatim}{m}{%
    \clist_set:Nn\l__skdoc_keys{#1}
    \clist_map_inline:Nn\l__skdoc_keys{
        \int_if_exist:cTF{skdoc@output@##1@line}{}{
            \msg_critical:nnn{skdoc}{key-nexists}{##1}
        }%
        \int_compare:nNnT{\int_use:c{skdoc@output@##1@line}}=\c_zero%
            {\int_gincr:c{skdoc@output@##1@line}}%
    }
    \__skdoc_if_print_code:T{
        \bool_if:NTF\g__skdoc_use_minted_bool{
            \minted@resetoptions%
            \exp_args:Nnx\setkeys{minted@opt}{
                \int_compare:nNnF{\clist_count:N\l__skdoc_keys}>\c_one{
                    \bool_if:NF\g__skdoc_in_example_bool{linenos,}
                    firstnumber=\int_use:c{skdoc@output@#1@line}
                }
            }%
            \iow_open:Nn\minted@code{\jobname.pyg}%
            \Needspace*{2\baselineskip}%
        }{
            \bool_if:NF\g__skdoc_in_example_bool{\@bsphack}%
        }
        \bool_if:NF\g__skdoc_in_example_bool{
            \marginnote{
                \leavevmode
                \llap{
                    \scriptsize\color{gray}
                    $\langle$#1$\rangle$
                    \makebox[2ex]{\strut}
                }
            }
        }
    }
    \def\verbatim@processline{%
        \clist_map_inline:Nn\l__skdoc_keys{
            \tl_gput_right:cx{skdoc@output@####1}{\the\verbatim@line\iow_newline:}%
        }
        \__skdoc_if_print_code:T{
            \bool_if:NTF\g__skdoc_use_minted_bool{
                \iow_now:Nx\minted@code{\the\verbatim@line}%
            }{
                \noindent\leavevmode%
                \bool_if:NF\g__skdoc_in_example_bool{\hspace*{-5ex}}
                \begin{minipage}[c][1ex]{\textwidth}
                    \bool_if:nF{
                        \g__skdoc_in_example_bool &&
                        !\int_compare_p:nNn{\clist_count:N\l__skdoc_keys}>\c_one
                    }{
                        \makebox[4ex]{%
                            \leavevmode
                            \sffamily\tiny\color{lightgray}\hfill%
                            \clist_map_inline:Nn\l__skdoc_keys{
                                \oldstylenums{\int_use:c{skdoc@output@####1@line}}%
                            }
                        }%
                        \hspace*{1ex}%
                    }
                    {
                        \verbatim@font
                        \the\verbatim@line
                    }
                \end{minipage}
                \par
            }
        }
        \clist_map_inline:Nn\l__skdoc_keys{
            \int_gincr:c{skdoc@output@####1@line}%
        }
    }%
    \group_begin:
    \let\do\@makeother\dospecials\catcode`\^^M\active%
    \bool_if:nT{
        \__skdoc_if_print_code_p: &&
        !\g__skdoc_use_minted_bool
    }{
        \frenchspacing\@vobeyspaces
    }
    \verbatim@start%
}{%
    \group_end:
    \__skdoc_if_print_code:T{
        \bool_if:NTF\g__skdoc_use_minted_bool{
            \iow_close:N\minted@code%
            \bool_if:NF\g__skdoc_in_example_bool{
                \vspace*{-\topsep}
                \vspace*{-\partopsep}
                \vspace*{-\parskip}
            }
            \minted@pygmentize{latex}%
            \DeleteFile{\jobname.pyg}%
            \vspace*{-\topsep}
            \vspace*{-\partopsep}
        }{
            \bool_if:NF\g__skdoc_in_example_bool{\@esphack}%
        }
    }%
}
\DeclareDocumentEnvironment{MacroCode}{m}{
    \__skdoc_if_print_code:T{
        \bool_if:NT\g__skdoc_negative_space_bool{\vspace{\baselineskip}}
        \vspace{.2\baselineskip}
        \bool_if:NF\g__skdoc_use_minted_bool{\par\noindent}
    }
    \skdoc@verbatim{#1}
}{
    \endskdoc@verbatim
    \__skdoc_if_print_code:T{
        \vspace{.5\baselineskip}
    }
}
\DeclareDocumentCommand\PreambleTo{mm}{%
    \group_begin:
    \msg_info:nnn{skdoc}{read-preamble}{#2}
    \ior_open:Nn\skdoc@input{#2}
    \bool_until_do:nn{\ior_if_eof_p:N\skdoc@input}{%
        \tl_if_empty:NTF\skdoc@temptl{}{%
            \tl_put_right:Nx\skdoc@temptl{\iow_newline:}
        }
        \tl_clear:N\l_tmpb_tl
        \ior_get_str:NN\skdoc@input\l_tmpa_tl
        \tl_put_right:Nx\l_tmpb_tl{\tl_head:N\l_tmpa_tl}
        \IfStrEq{\tl_to_str:N\l_tmpb_tl}{\@percentchar}{%
            \tl_set_eq:NN\l_tmpb_tl\skdoc@temptl
            \tl_concat:NNN\skdoc@temptl\l_tmpb_tl\l_tmpa_tl
        }{%
            \ior_close:N\skdoc@input
        }
    }
    \xdef#1{\tl_to_str:N\skdoc@temptl}
    \group_end:
}
\DeclareDocumentCommand\SelfPreambleTo{m}{%
    \PreambleTo{#1}{\c_job_name_tl}%
}
\definecolorset{RGB}{}{}{
    section,11,72,107;
    extlink,73,10,61;
    intlink,140,35,24;
    sharp,250,105,0;
    bright,198,229,217;
    macrodesc,73,10,61;
    keydesc,140,35,24;
    macroimpl,73,10,61;
    meta,11,72,107;
    scriptcolor,140,35,24;
    optioncolor,73,10,61;
    opt,73,10,61
}
\RenewDocumentCommand\descfont{}{\sffamily\fontseries{sb}}
\RenewDocumentCommand\sectfont{}{\sffamily\fontseries{sb}}
\addtokomafont{minisec}{\bfseries}
\addtokomafont{paragraph}{\color{section}}
\addtokomafont{section}{\color{section}}
\addtokomafont{subsection}{\color{section}}
\addtokomafont{subsubsection}{\color{section}}
\addtokomafont{descriptionlabel}{\color{section}}
\addtokomafont{sectionentry}{\rmfamily\bfseries}
\addtokomafont{sectionentrypagenumber}{\rmfamily\bfseries}
\hypersetup{
    colorlinks=true,
    linkcolor=intlink,
    anchorcolor=intlink,
    citecolor=black,
    urlcolor=extlink
}
\DeclareDocumentCommand\cs{sm}{
    \texttt{\char`\\#2}
    \bool_if:NF\g__skdoc_no_index_bool{
        \IfBooleanTF{#1}{}{\index@macro{#2}}
    }
}
\DeclareDocumentCommand\env{sm}{
    \texttt{#2}
    \bool_if:NF\g__skdoc_no_index_bool{
        \IfBooleanTF{#1}{}{\index@environment{#2}}
    }
}
\DeclareDocumentCommand\pkg{sm}{
    \textsf{#2}
    \bool_if:NF\g__skdoc_no_index_bool{
        \IfBooleanTF{#1}{}{\index@package{#2}}
    }
}
\DeclareDocumentCommand\opt{sm}{
    \texttt{#2}
    \bool_if:NF\g__skdoc_no_index_bool{
        \IfBooleanTF{#1}{}{\index@option{#2}}
    }
}
\DeclareDocumentCommand\bib{sm}{
    \texttt{@#2}
    \bool_if:NF\g__skdoc_no_index_bool{
        \IfBooleanTF{#1}{}{\index@bibentry{#2}}
    }
}
\DeclareDocumentCommand\thm{sm}{
    \textrm{#2}
    \bool_if:NF\g__skdoc_no_index_bool{
        \IfBooleanTF{#1}{}{\index@theme{#2}}
    }
}
\DeclareDocumentCommand\file{sm}{
    \texttt{#2}
    \bool_if:NF\g__skdoc_no_index_bool{
        \IfBooleanTF{#1}{}{\index@file{#2}}
    }
}
\def\Describe@Macro#1{%
    \endgroup
    \edef\name{\expandafter\@gobble\string#1}%
    \global\@namedef{href@desc@\name}{}%
    \immediate\write\@mainaux{%
        \global\noexpand\@namedef{href@desc@\name}{}%
    }%
    \hbox\y@bgroup
    \@ifundefined{href@impl@\name}{}{\hyperlink{impl:\name}}%
    {%
        \hbox{
            \vbox to 0pt{
                \vss\hbox{
                    \raisebox{4ex}{\hypertarget{desc:\name}{}
                }
            }
        }%
        \marginnote{\llap{\PrintMacroName{#1}}}
        }%
    }%
    \ydoc@macrocatcodes
    \macroargsstyle
    \read@Macro@arg
}
\def\descframe#1{%
    \mbox{\hspace*{1.5\descsep}#1\hspace*{2\descsep}}%
}
\let\old@PrintMacroName\PrintMacroName
\DeclareDocumentCommand\PrintMacroName{m}{%
    \index@macro*{\expandafter\@gobble\string#1}
    \old@PrintMacroName{#1}
}
\let\old@PrintEnvName\PrintEnvName
\def\PrintEnvName#1#2{
    \ifx#1\begin
        \edef\skdoc@temp{\noexpand\index@environment*{#2}}
        \skdoc@temp
    \fi
    \old@PrintEnvName{#1}{#2}
}
\DeclareDocumentCommand\DescribeEnv{om}{
    \medskip\par\noindent
    \marginnote{
        \envcodestyle
        \hfill\llap{\PrintEnvName{\begin}{#2}}\mbox{}\\
        \IfNoValueTF{#1}{}{\hfill\llap{\MacroArgs#1}\mbox{}\\}
        \hfill\llap{\PrintEnvName{\end}{#2}}\mbox{}\\
    }
    \begingroup
    \def\after@Macro@args{\endDescribeEnv}
    \y@bgroup
    \ydoc@macrocatcodes
    \macroargsstyle
    \read@Macro@arg
}
\DeclareDocumentCommand\endDescribeEnv{}{
    \endgroup
    \smallskip\par\noindent
}
\let\optpar\relax
\DeclareDocumentCommand\Options{m}{
    \clist_set:Nn\l_tmpa_clist{#1}
    \marginnote{
        \clist_map_inline:Nn\l_tmpa_clist{
            \index@option*{####1}
            \hfill
            \llap{\textcolor{opt}{\opt{####1}}}
            \mbox{}\\
        }
    }
    \nobreak
}
\DeclareDocumentCommand\Option{m}{
    \Options{#1}
}
\def\skdoc@WithValues@peek{
    \ifx\@let@token\AndDefault\else\par\noindent\nobreak\ignorespaces\fi
}
\DeclareDocumentCommand\WithValues{m}{
    \noindent\makebox[\linewidth][l]{\texttt{#1}}
    \futurelet\@let@token\skdoc@WithValues@peek
}
\DeclareDocumentCommand\AndDefault{m}{
    \llap{\textcolor{gray}{\texttt{(#1)}}}\par\noindent\nobreak\ignorespaces
}
\DeclareDocumentCommand\BibEntry{m}{
    \marginnote{
        \index@bibentry*{#1}
        \hfill\llap{\textcolor{macrodesc}{\bib{#1}}}
    }
    \nobreak
}
\DeclareDocumentCommand\WithFields{om}{
    \noindent\makebox[\linewidth]{
        \texttt{#2}
        \IfNoValueTF{#1}{}{
            \textcolor{gray}{\texttt{,#2}}
        }
    }
    \par\noindent\nobreak\ignorespaces
}
\DeclareDocumentCommand\Theme{m}{
    \marginnote{
        \index@theme*{#1}
        \hfill\llap{\textcolor{macrodesc}{\thm{#1}}}
    }
    \nobreak\par\noindent\nobreak\ignorespaces
}
\DeclareDocumentCommand\DescribeFile{m}{
    \marginnote{
        \index@file*{#1}
        \hfill\llap{\textcolor{macrodesc}{\file{#1}}}
    }
    \nobreak\par\noindent\nobreak\ignorespaces
}
\dim_const:Nn\c__skdoc_example_margin_dim{0.5\baselineskip}
\dim_const:Nn\c__skdoc_example_linewidth_dim{1pt}
\coffin_new:N\l__skdoc_example_code_coffin
\coffin_new:N\l__skdoc_example_divider_coffin
\coffin_new:N\l__skdoc_example_result_coffin
\DeclareDocumentEnvironment{example}{}{
    \bool_gset_true:N\g__skdoc_in_example_bool%
    \minisec{Example:}%
    \int_zero_new:c{skdoc@output@skdoc@private@example@line}%
    \tl_if_exist:cTF{skdoc@output@skdoc@private@example}{
        \tl_clear:c{skdoc@output@skdoc@private@example}
    }{
        \tl_new:c{skdoc@output@skdoc@private@example}
    }
    \dim_set:Nn\l_tmpa_dim{ \textwidth/2
                           -\c__skdoc_example_margin_dim
                           -\c__skdoc_example_linewidth_dim/2}
    \coffin_clear:N\l__skdoc_example_code_coffin
    \vcoffin_set:Nnw\l__skdoc_example_code_coffin{\l_tmpa_dim}
    \skdoc@verbatim{skdoc@private@example}
}{
    \endskdoc@verbatim
    \vcoffin_set_end:
    \coffin_clear:N\l__skdoc_example_result_coffin
    \vcoffin_set:Nnw\l__skdoc_example_result_coffin{\l_tmpa_dim}
    \iow_open:Nn\skdoc@output{\jobname.skdoc.tmp}
    \iow_now:Nx\skdoc@output{\tl_to_str:c{skdoc@output@skdoc@private@example}}
    \iow_close:N\skdoc@output
    \input{\jobname.skdoc.tmp}
    \vcoffin_set_end:
    \coffin_clear:N\l__skdoc_example_divider_coffin
    \dim_set:Nn\l_tmpa_dim{
        \dim_max:nn{\coffin_ht:N\l__skdoc_example_code_coffin}%
                   {\coffin_ht:N\l__skdoc_example_result_coffin}
        + 2\c__skdoc_example_margin_dim}
    \hcoffin_set:Nn\l__skdoc_example_divider_coffin{
        \color{lightgray}
        \hspace*{\c__skdoc_example_margin_dim}
        \rule{\c__skdoc_example_linewidth_dim}{\l_tmpa_dim}
        \hspace*{\c__skdoc_example_margin_dim}
    }
    \coffin_clear:N\l_tmpa_coffin
    \coffin_set_eq:NN\l_tmpa_coffin\l__skdoc_example_divider_coffin
    \coffin_join:NnnNnnnn\l_tmpa_coffin{l}{vc}%
                         \l__skdoc_example_result_coffin{r}{vc}%
                         {0pt}{0pt}
    \coffin_join:NnnNnnnn\l_tmpa_coffin{r}{vc}%
                         \l__skdoc_example_code_coffin{l}{vc}%
                         {0pt}{0pt}
    \coffin_typeset:Nnnnn\l_tmpa_coffin{T}{l}{0pt}{0pt}
    \bool_gset_false:N\g__skdoc_in_example_bool%
    \vspace*{\c__skdoc_example_margin_dim}\par
}
\DeclareDocumentEnvironment{macro}{smo}{%
    \IfBooleanTF{#1}{}{\@bsphack}
    \index@macro!{\expandafter\@gobble\string#2}
    \@macroname{#2}%
    \IfBooleanTF{#1}{
        \IfNoValueTF{#3}{}{
            \int_compare:nNnTF{#3}>{0}{
                \use:c{use_none:\prg_replicate:nn{#3}{n}}
            }{}
        }
    }{
        \PrintMacroImpl{#2}
        \IfNoValueTF{#3}{
            \macro@impl@argline@noarg{(no~arguments)}
        }{\macro@impl@args[#3]}
    }%
}{
    \let\skdoc@macroname@key\@empty
    \IfBooleanTF{#1}{}{\par\@esphack}
}
\DeclareDocumentEnvironment{environment}{smo}{%
    \IfBooleanTF{#1}{}{\@bsphack}
    \index@environment!{#2}
    \@environmentname{#2}%
    \IfBooleanTF{#1}{
        \IfNoValueTF{#3}{}{
            \int_compare:nNnTF{#3}>{0}{
                \use:c{use_none:\prg_replicate:nn{#3}{n}}
            }{}
        }
    }{
        \PrintEnvImplName{#2}
        \IfNoValueTF{#3}{
            \macro@impl@argline@noarg{(no~arguments)}
        }{\macro@impl@args[#3]}
    }%
}{
    \let\skdoc@macroname@key\@empty
    \IfBooleanTF{#1}{}{\par\@esphack}
}
\DeclareDocumentEnvironment{option}{smg}{%
    \IfBooleanTF{#1}{}{\@bsphack}
    \index@option!{#2}
    \@optionname{#2}%
    \IfBooleanTF{#1}{}{
        \vspace{\baselineskip}
        \PrintEnvImplName{#2}
        \IfNoValueTF{#3}{
            \macro@impl@argline@noarg{(option)}
        }{
            \macro@impl@argline@noarg{
                Option~with~values~\texttt{\textcolor{gray}{#3}}
            }
        }
    }%
}{
    \let\skdoc@macroname@key\@empty
    \IfBooleanTF{#1}{}{\par\@esphack}
}
\DeclareDocumentEnvironment{bibentry}{sm}{%
    \IfBooleanTF{#1}{}{\@bsphack}
    \index@bibentry!{\expandafter\@gobble\string#2}
    \@bibentryname{#2}%
    \IfBooleanTF{#1}{}{
        \vspace{\baselineskip}
        \PrintEnvImplName{#2}
        \macro@impl@argline@noarg{(\hologoRobust{BibTeX}~entry~type)}
    }%
}{
    \let\skdoc@macroname@key\@empty
    \IfBooleanTF{#1}{}{\par\@esphack}
}
\DeclareDocumentEnvironment{theme}{sm}{%
    \IfBooleanTF{#1}{}{\@bsphack}
    \index@theme!{#2}
    \@themename{#2}%
    \IfBooleanTF{#1}{}{
        \vspace{\baselineskip}
        \PrintEnvImplName{#2}
        \macro@impl@argline@noarg{(theme)}
    }%
}{
    \let\skdoc@macroname@key\@empty
    \IfBooleanTF{#1}{}{\par\@esphack}
}
\DeclareDocumentEnvironment{macro*}{mo}%
    {\begin{macro}*{#1}[#2]}{\end{macro}}
\DeclareDocumentEnvironment{environment*}{mo}%
    {\begin{environment}*{#1}[#2]}{\end{environment}}
\DeclareDocumentEnvironment{option*}{mg}%
    {\begin{option}*{#1}{#2}}{\end{option}}
\DeclareDocumentEnvironment{bibentry*}{m}%
    {\begin{bibentry}*{#1}}{\end{bibentry}}
\DeclareDocumentEnvironment{theme*}{m}%
    {\begin{theme}*{#1}}{\end{theme}}
\def\PrintEnvImplName#1{%
    \par\leavevmode\null
    \hbox{%
        \marginnote{\llap{\implstyle{#1\strut}}}%
    }
    \null
}
\def\PrintMacroImpl#1{%
    \par
    \hbox{%
        \edef\name{\expandafter\@gobble\string#1}%
        \global\@namedef{href@impl@\name}{}%
        \immediate\write\@mainaux{%
            \global\noexpand\@namedef{href@impl@\name}{}%
        }%
        \raisebox{4ex}[4ex]{\hypertarget{impl:\name}{}}%
        \@ifundefined{href@desc@\name}{}{\hyperlink{desc:\name}}%
        \marginnote{\llap{\PrintMacroImplName{#1}}}%
    }%
    \par
}
\def\macro@impl@argline#1#2{%
    \par\noindent{\texttt{\##1}:~#2\strut}%
}
\def\macro@impl@args[#1]{%
    \vspace*{-\baselineskip}
    \begingroup
    \let\macro@impl@argcnt\@tempcnta
    \let\macro@impl@curarg\@tempcntb
    \macro@impl@argcnt=#1\relax
    \macro@impl@curarg=0\relax
    \ifnum\macro@impl@curarg<\macro@impl@argcnt\relax
        \expandafter\macro@impl@arg
    \else
        \expandafter\macro@impl@endargs
    \fi
}
\def\macro@impl@arg@noopt#1{%
    \macro@impl@argline{\the\macro@impl@curarg}{#1}
    \ifnum\macro@impl@curarg<\macro@impl@argcnt\relax
        \expandafter\macro@impl@arg
    \else
        \expandafter\macro@impl@endargs
    \fi
}
\def\macro@impl@arg@opt#1[#2]{%
    \macro@impl@argline{\the\macro@impl@curarg}
        {#1\hfill\AndDefault{#1}\vspace{-\baselineskip}}
    \ifnum\macro@impl@curarg<\macro@impl@argcnt\relax
        \expandafter\macro@impl@arg
    \else
        \expandafter\macro@impl@endargs
    \fi
}
\def\macro@impl@arg#1{%
    \advance\macro@impl@curarg by\@ne\relax
    \@ifnextchar[%]
        {\macro@impl@arg@opt{#1}}%
        {\macro@impl@arg@noopt{#1}}%
}
\def\macro@impl@endargs{
    \endgroup
    \peek_meaning_ignore_spaces:NTF\begin
        {
            \vspace{-\baselineskip}
            \bool_gset_true:N\g__skdoc_negative_space_bool
            \PushPreHook{par}{
                \bool_gset_false:N\g__skdoc_negative_space_bool
                \PopPreHook{par}
            }
        }
        {\par\medskip}%
}
\def\macro@impl@argline@noarg#1{%
    \vspace*{-\baselineskip}
    \par\noindent{#1\strut}
    \peek_meaning_ignore_spaces:NTF\begin
        {
            \vspace{-\baselineskip}
            \bool_gset_true:N\g__skdoc_negative_space_bool
            \PushPreHook{par}{
                \bool_gset_false:N\g__skdoc_negative_space_bool
                \PopPreHook{par}
            }
        }
        {\par\medskip}%
}
\prg_new_conditional:Nnn\__skdoc_if_do_index:{p,T,F,TF}{
    \bool_if:nTF{
        \__skdoc_if_print_code_p: &&
        !\g__skdoc_no_index_bool
    }{
        \prg_return_true:
    }{
        \prg_return_false:
    }
}
\DeclareDocumentCommand\@index@{mm}{
    \__skdoc_if_do_index:T{
        \@index@@{#1}{#2}
    }
}
\DeclareDocumentCommand\@index@@{mm}{
    \newglossaryentry{index-#1}{
        type=index,
        name={#2},
        description={\nopostdesc},
        sort={#1}
    }
}
\DeclareDocumentCommand\index@macro{st!m}{
    \def\skdoc@temp{#3-macro}
    \ifglsentryexists{index-\skdoc@temp}{}{
        \@index@{#3-macro}{\cs*{#3}}
    }
    \__skdoc_if_do_index:T{
        \IfBooleanTF{#2}{
            \glsadd[types=index,format=hyperul]{index-\skdoc@temp}
        }{
            \IfBooleanTF{#1}{
                \glsadd[types=index,format=hyperit]{index-\skdoc@temp}
            }{
                \glsadd[types=index]{index-\skdoc@temp}
            }
        }
    }
}
\DeclareDocumentCommand\index@environment{st!m}{
    \def\skdoc@temp{\string#3-env}
    \ifglsentryexists{index-\skdoc@temp}{}{
        \@index@{\string#3-env}{\env*{\string#3}~(environment)}
    }
    \__skdoc_if_do_index:T{
        \IfBooleanTF{#2}{
            \glsadd[types=index,format=hyperul]{index-\skdoc@temp}
        }{
            \IfBooleanTF{#1}{
                \glsadd[types=index,format=hyperit]{index-\skdoc@temp}
            }{
                \glsadd[types=index]{index-\skdoc@temp}
            }
        }
    }
}
\DeclareDocumentCommand\index@option{st!m}{
    \def\skdoc@temp{\string#3-opt}
    \ifglsentryexists{index-\skdoc@temp}{}{
        \@index@{\string#3-opt}{\opt*{\string#3}~(option)}
    }
    \__skdoc_if_do_index:T{
        \IfBooleanTF{#2}{
            \glsadd[types=index,format=hyperul]{index-\skdoc@temp}
        }{
            \IfBooleanTF{#1}{
                \glsadd[types=index,format=hyperit]{index-\skdoc@temp}
            }{
                \glsadd[types=index]{index-\skdoc@temp}
            }
        }
    }
}
\DeclareDocumentCommand\index@bibentry{st!m}{
    \def\skdoc@temp{#3-bib}
    \ifglsentryexists{index-\skdoc@temp}{}{
        \@index@{#3-bib}{\bib*{#3}~(\hologoRobust{BibTeX}~entry~type)}
    }
    \__skdoc_if_do_index:T{
        \IfBooleanTF{#2}{
            \glsadd[types=index,format=hyperul]{index-\skdoc@temp}
        }{
            \IfBooleanTF{#1}{
                \glsadd[types=index,format=hyperit]{index-\skdoc@temp}
            }{
                \glsadd[types=index]{index-\skdoc@temp}
            }
        }
    }
}
\DeclareDocumentCommand\index@theme{st!m}{
    \def\skdoc@temp{\string#3-theme}
    \ifglsentryexists{index-\skdoc@temp}{}{
        \@index@{\string#3-theme}{\thm*{\string#3}~(theme)}
    }
    \__skdoc_if_do_index:T{
        \IfBooleanTF{#2}{
            \glsadd[types=index,format=hyperul]{index-\skdoc@temp}
        }{
            \IfBooleanTF{#1}{
                \glsadd[types=index,format=hyperit]{index-\skdoc@temp}
            }{
                \glsadd[types=index]{index-\skdoc@temp}
            }
        }
    }
}
\DeclareDocumentCommand\index@package{st!m}{
    \def\skdoc@temp{\string#3-pkg}
    \ifglsentryexists{index-\skdoc@temp}{}{
        \@index@{\string#3-pkg}{\pkg*{\string#3}~(package)}
    }
    \__skdoc_if_do_index:T{
        \IfBooleanTF{#2}{
            \glsadd[types=index,format=hyperul]{index-\skdoc@temp}
        }{
            \IfBooleanTF{#1}{
                \glsadd[types=index,format=hyperit]{index-\skdoc@temp}
            }{
                \glsadd[types=index]{index-\skdoc@temp}
            }
        }
    }
}
\DeclareDocumentCommand\index@file{st!m}{
    \def\skdoc@temp{\string#3-file}
    \ifglsentryexists{index-\skdoc@temp}{}{
        \@index@{\string#3-file}{\file*{\string#3}~(file)}
    }
    \__skdoc_if_do_index:T{
        \IfBooleanTF{#2}{
            \glsadd[types=index,format=hyperul]{index-\skdoc@temp}
        }{
            \IfBooleanTF{#1}{
                \glsadd[types=index,format=hyperit]{index-\skdoc@temp}
            }{
                \glsadd[types=index]{index-\skdoc@temp}
            }
        }
    }
}
\ProvideDocumentCommand\hyperul{m}{
    \underline{\hyperup{#1}}
}
\newglossarystyle{docindex}{
    \glossarystyle{indexgroup}
    \renewcommand*{\glspostdescription}{\unskip\leaders\hbox to 2.9mm{\hss.}\hfill\strut}
    \renewenvironment{theglossary}{
        \bool_gset_true:N\g__skdoc_no_index_bool
        \begin{multicols}{2}
        \setlength{\parindent}{0pt}
        \setlength{\parskip}{0pt plus 0.3pt}
        \let\item\@idxitem
    }{
        \end{multicols}
        \bool_gset_false:N\g__skdoc_no_index_bool
    }
    \renewcommand*{\glossaryentryfield}[5]{
        \item\glsentryitem{##1}\glstarget{##1}{##2}
            \ifx\relax##4\relax\else\space(##4)\fi
            ##3\glspostdescription\space ##5}
    \renewcommand*{\glsgroupheading}[1]{
        \IfStrEq{##1}{default}{
            \item{\descfont\glssymbolsgroupname}
        }{
            \item{\descfont\glsgetgrouptitle{##1}}
        }
    }
    \renewcommand*{\glsgroupskip}{
        \par\vspace{15\p@}\relax
    }
}
\newglossary{index}{ids}{ido}{Index}
\AtBeginDocument{\makeglossaries}
\providecommand*\PrintIndex{%
    \begingroup
    \renewcommand*{\glossarypreamble}{
        Numbers~written~in~italic~refer~to~the~page~where~the~
        corresponding~entry~is~described;~numbers~underlined~refer~
        to~the~page~were~the~implementation~of~the~corresponding~
        entry~is~discussed.~Numbers~in~roman~refer~to~other~
        mentions~of~the~entry.\par
    }
    \printglossary[type=index,style=docindex]
    \endgroup
}
\RenewDocumentCommand\@gls@addpredefinedattributes{}{
    \GlsAddXdyAttribute{hyperit}
    \GlsAddXdyAttribute{hyperul}
    \GlsAddXdyAttribute{glsnumberformat}
    \GlsAddXdyAttribute{@gobble}
}
\DeclareDocumentCommand\generalname{}{General}
\DeclareDocumentCommand\@macroname{m}{
    \def\skdoc@macroname@stylized{\cs*{\expandafter\@gobble\string#1}}
    \def\skdoc@macroname@key{macro-\expandafter\@gobble\string#1}
}
\DeclareDocumentCommand\@environmentname{m}{
    \def\skdoc@macroname@stylized{\env*{\string#1}}
    \def\skdoc@macroname@key{env-#1}
}
\DeclareDocumentCommand\@optionname{m}{
    \def\skdoc@macroname@stylized{\opt*{\string#1}}
    \def\skdoc@macroname@key{opt-#1}
}
\DeclareDocumentCommand\@bibentryname{m}{
    \def\skdoc@macroname@stylized{\bib*{\expandafter\@gobble\string#1}}
    \def\skdoc@macroname@key{bibentry-\expandafter\@gobble\string#1}
}
\DeclareDocumentCommand\@themename{m}{
    \def\skdoc@macroname@stylized{\thm*{\string#1}}
    \def\skdoc@macroname@key{thm-#1}
}
\def\skdoc@macroname@stylized{}
\let\skdoc@macroname@key\@empty
\DeclareDocumentCommand\changes{mm}{%
    \@bsphack
    \newglossaryentry{#1}{
        type=changes,
        name={v#1},
        description={\nopostdesc},
        nonumberlist=true
    }
    \ifx\skdoc@macroname@key\@empty
        \newglossaryentry{#1-general}{
            type=changes,
            description={\generalname{}:~#2},
            parent={#1},
            sort={0},
            nonumberlist=true
        }
        \glsadd[types=changes,format=@gobble]{#1-general}
    \else
        \newglossaryentry{#1-\skdoc@macroname@key}{
            type=changes,
            description={\skdoc@macroname@stylized{}:~#2},
            parent={#1},
            sort={\skdoc@macroname@key},
            nonumberlist=true
        }
        \glsadd[types=changes,format=@gobble]{#1-\skdoc@macroname@key}
    \fi
    \@esphack
}
\newglossarystyle{changelog}{
    \glossarystyle{altlist}
    \renewenvironment{theglossary}{
        \bool_gset_true:N\g__skdoc_no_index_bool
        \begin{multicols}{2}\begin{description}
    }{
        \end{description}\end{multicols}
        \bool_gset_false:N\g__skdoc_no_index_bool
    }
    \renewcommand*{\glossaryentryfield}[5]{
        \par\vspace{5\p@}\relax
        \item[\glsentryitem{##1}\glstarget{##1}{##2}]
                    \mbox{}\par\nobreak\@afterheading
    }
    \renewcommand{\glossarysubentryfield}[6]{%
        \par\hspace*{\itemindent}
        \glssubentryitem{##2}%
        \glstarget{##2}{\strut}##4\glspostdescription\space ##6
    }
}
\newglossary{changes}{gls}{glo}{Changes}
\AtBeginDocument{\makeglossaries}
\DeclareDocumentCommand\PrintChanges{}{%
    \begingroup
    \printglossary[type=changes,style=changelog]
    \endgroup
}
\newcounter{skdoc@impl@page}
\AtBeginShipout{
    \__skdoc_if_print_code:F{\AtBeginShipoutDiscard}
}
\DeclareDocumentCommand\OnlyDescription{}{
    \bool_gset_false:N\g__skdoc_with_implementation_bool
}
\DeclareDocumentCommand\Implementation{}{
    \bool_if:NF\g__skdoc_with_implementation_bool{
        \clearpage
        \bool_gset_true:N\g__skdoc_in_implementation_bool
        \let\skdoc@old@part\part
        \DeclareDocumentCommand\part{som}{}
        \let\skdoc@old@section\section
        \DeclareDocumentCommand\section{som}{}
        \let\skdoc@old@subsection\subsection
        \DeclareDocumentCommand\subsection{som}{}
        \let\skdoc@old@subsubsection\subsubsection
        \DeclareDocumentCommand\subsubsection{som}{}
        \let\skdoc@old@paragraph\paragraph
        \DeclareDocumentCommand\paragraph{som}{}
        \let\skdoc@old@subparagraph\subparagraph
        \DeclareDocumentCommand\subparagraph{som}{}
        \cs_if_exist:NTF\refsection{\refsection}{}
        \setcounter{skdoc@impl@page}{\value{page}}
    }
}
\DeclareDocumentCommand\Finale{}{
    \bool_if:NF\g__skdoc_with_implementation_bool{
        \cs_if_exist:NTF\refsection{\printbibliography\endrefsection}{}
        \clearpage
        \bool_gset_false:N\g__skdoc_in_implementation_bool
        \let\part\skdoc@old@part
        \let\section\skdoc@old@section
        \let\subsection\skdoc@old@subsection
        \let\subsubsection\skdoc@old@subsubsection
        \let\paragraph\skdoc@old@paragraph
        \let\subparagraph\skdoc@old@subparagraph
        \setcounter{page}{\value{skdoc@impl@page}}
    }
}
\let\@ctan\@empty%
\let\@repository\@empty%
\let\@plainemail\@empty%
\let\@email\@empty%
\let\@version\@empty%
\DeclareDocumentCommand\package{om}{%
    \keys_define:nn{skdoc@package}{%
        vcs .value_required:,%
        vcs .code:n = \repository{##1},%
        ctan .code:n = \ctan{##1},%
        ctan .default:n = #2%
    }%
    \IfNoValueTF{#1}{}{\keys_set:nn{skdoc@package}{#1}}%
    \def\@package{#2}%
    \title{The~\textbf{\pkg*{\@package}}~package}%
}
\DeclareDocumentCommand\ctan{m}{%
    \def\@ctan{\url{http://www.ctan.org/pkg/#1}}%
}
\DeclareDocumentCommand\repository{m}{%
    \def\@repository{\url{#1}}%
}
\DeclareDocumentCommand\email{m}{%
    \def\@plainemail{#1}%
    \def\@email{\href{mailto:\@plainemail}{\@plainemail}}%
}
\DeclareDocumentCommand\version{m}{%
    \def\@version{#1}%
}
\package{\jobname}
\DeclareDocumentCommand\theversion{}{v\@version}
\DeclareDocumentCommand\thepackage{}{\pkg*{\@package}}
\DeclareDocumentCommand\thepkg{}{\thepackage}
\ifpdf
    \def\skdocpdfsettings{%
        \hypersetup{%
            pdfauthor   = {\@author\space<\@plainemail>},
            pdftitle    = {\@title},
            pdfsubject  = {Documentation~of~LaTeX~package~\@package},
            pdfkeywords = {\@package,~LaTeX,~TeX}
        }%
    }%
\else
    \let\skdocpdfsettings\empty%
\fi
\DeclareDocumentCommand\Notice{m}{
    (\emph{\textbf{Note:}~#1})
}
\DeclareDocumentCommand\Warning{+m}{
    \vspace{\baselineskip}
    \par\noindent
    \fbox{\begin{minipage}[c]{\textwidth}
        \centering
        \textbf{Warning:}~#1
    \end{minipage}}
    \vspace{\baselineskip}
    \par
}
\DeclareDocumentCommand\LongWarning{+m}{
    \Warning{
        \par\noindent
        \begin{minipage}{\textwidth}
            #1
        \end{minipage}
    }
}
\def\@maketitle{%
    \newpage
    \null
    \begin{flushleft}%
    {%
        \Huge\sectfont\@title%
        \ifx\@ctan\@empty\else%
            \footnote{Available~on~\@ctan.}%
        \fi
        \ifx\@repository\@empty\else%
            \footnote{Development~version~available~on~\@repository.}%
        \fi%
        \par%
    }%
    \vskip 1em
    {%
        \Large\@author
        \ifx\@email\@empty\else%
            \space
            \newlength\skdoc@minipage@ew%
            \settowidth{\skdoc@minipage@ew}{%
                \normalsize{$\lceil${\@email}$\rfloor$}}
            \begin{minipage}[b]{\skdoc@minipage@ew}
                \normalsize{$\lceil${\@email}$\rfloor$}
            \end{minipage}\par%
        \fi%
    }%
    \ifx\@version\@empty\else
        \vskip .5em
        {%
            \large Version~\@version\par%
        }%
    \fi
    \end{flushleft}%
    \par\bigskip%
}
\def\maketitle{%
    \begingroup
    \skdocpdfsettings
    \renewcommand\thefootnote{\@fnsymbol\c@footnote}
    \@maketitle
    \setcounter{footnote}{0}
    \skdocpdfsettings
    \endgroup
}
\DeclareDocumentEnvironment{abstract}{}{
    \newlength\skdoc@abstract@tw%
    \newlength\skdoc@abstract@aw%
    \settowidth{\skdoc@abstract@tw}{\descfont\abstractname}%
    \setlength{\skdoc@abstract@aw}{\the\textwidth-\the\skdoc@abstract@tw-2em}%
    \begin{minipage}{\textwidth}
        \begin{minipage}[t]{\skdoc@abstract@tw}%
            \begin{flushright}%
                \leavevmode\descfont\abstractname%
            \end{flushright}%
        \end{minipage}%
        \hspace{1em}%
        \begin{minipage}[t]{\skdoc@abstract@aw}%
}{
        \end{minipage}
    \end{minipage}
}
\let\l@section@\l@section
\def\l@section{\vskip -.75ex\l@section@}
\def\l@subsection{\vskip.35ex\penalty\@secpenalty\@dottedtocline{2}{1.5em}{2.7em}}
\def\l@subsubsection#1#2{
    \leftskip 4.2em
    \parindent 0pt
    {\let\numberline\@gobble{\small #1~[#2]}}
}
\def\l@table{\@dottedtocline{1}{0pt}{1.5em}}
\def\l@figure{\@dottedtocline{1}{0pt}{1.5em}}
\def\@pnumwidth{1.7em}
\AtEndDocument{\addtocontents{toc}{\par}}
\let\old@tableofcontents\tableofcontents
\DeclareDocumentCommand\tableofcontents{}{
    \bool_gset_true:N\g__skdoc_no_index_bool
    \microtypesetup{protrusion=false}
    \old@tableofcontents
    \microtypesetup{protrusion=true}
    \bool_gset_false:N\g__skdoc_no_index_bool
}
\DeclareDocumentCommand\PrintLPPL{}{
    \begingroup
    \IfFileExists{lppl.tex}{
        \let\old@verbatim@font\verbatim@font
        \def\verbatim@font{
            \old@verbatim@font\tiny
        }
        \def\LPPLicense{\begingroup\small}
        \def\endLPPLicense{\endmulticols\endgroup}
        \DeclareDocumentCommand\LPPLsection{m}{
            \section{####1}
        }
        \DeclareDocumentCommand\skdoc@lppl@hack{m}{
            \end{multicols}
            \begin{multicols}{2}
                [\subsection*{####1}][6\baselineskip]
        }
        \DeclareDocumentCommand\LPPLsubsection{m}{
            \subsection*{####1}
            \let\LPPLsubsection\skdoc@lppl@hack
            \begin{multicols}{2}
        }
        \DeclareDocumentCommand\LPPLsubsubsection{m}{
            \subsubsection*{####1}
        }
        \DeclareDocumentCommand\LPPLparagraph{m}{\paragraph*{####1}}
        \DeclareDocumentCommand\LPPLfile{m}{\file{####1}}
        \let\oldmakeatletter\makeatletter
        \long\def\makeatletter####1\makeatother{
            \let\makeatletter\oldmakeatletter
        }
        \setlength\leftmargini{15pt}
        \setlength\leftmarginii{12.5pt}
        \setlength\leftmarginiii{10pt}
        \newenvironment{enum}[1][0]{
            \list\labelenumi{
                \usecounter{enumi}
                \setcounter{enumi}{####1}
                \addtocounter{enumi}{-1}
                \leftmargin 30pt
                \itemindent-15pt
                \labelwidth 15pt
                \labelsep 0pt
                \def\makelabel########1{########1\hss}}
        }{\endlist}
        \input{lppl}
    }{
        \msg_warning:nn{skdoc}{no-lppl}
    }
    \endgroup
}
\deftripstyle{skdoc}%
    {}{}{}%
    {\small The~\textbf{\pkg*{\@package}}~package,~v\@version}{}{\small\pagemark}
\AfterBeginDocument{\pagestyle{skdoc}}
\RenewDocumentCommand{\othersectionlevelsformat}{m}{%
    \makebox[0pt][r]{%
    \fontfamily{fos}\mdseries\selectfont
    \csname the#1\endcsname\enskip}%
}
\g@addto@macro\@verbatim{\microtypesetup{activate=false}}
\AtEndOfClass{%
    \microtypesetup{expansion,kerning,spacing,tracking}%
    \DisableLigatures{family = tt*}%
}
\AtBeginDocument{
    \ifdefined\defbibheading
        \defbibheading{bibliography}[\bibname]{\section{#1}}
    \fi
    \@ifpackageloaded{bibtex}{\msg_warning:nn{skdoc}{bibtex-unsupported}}{}
}
\AtBeginDocument{\reversemarginpar}
\endinput
%%
%% End of file `skdoc.cls'.
