summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/skdoc
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2013-05-27 01:20:56 +0000
committerNorbert Preining <preining@logic.at>2013-05-27 01:20:56 +0000
commitbddefbf234bbe8889456b2e1b09cce68cf590891 (patch)
tree76869528777f4951ab78a9b15d1e15f593721418 /Master/texmf-dist/tex/latex/skdoc
parentf07b7c015a77f69963eb08048aba8c5621cdb0c1 (diff)
skdoc 5/27
git-svn-id: svn://tug.org/texlive/trunk@30697 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/skdoc')
-rw-r--r--Master/texmf-dist/tex/latex/skdoc/skdoc.cls555
1 files changed, 447 insertions, 108 deletions
diff --git a/Master/texmf-dist/tex/latex/skdoc/skdoc.cls b/Master/texmf-dist/tex/latex/skdoc/skdoc.cls
index 2c55dff1035..a03f7990f41 100644
--- a/Master/texmf-dist/tex/latex/skdoc/skdoc.cls
+++ b/Master/texmf-dist/tex/latex/skdoc/skdoc.cls
@@ -8,7 +8,7 @@
%%
%% skdoc documentation class
%%
-%% Copyright (C) 2012 by Simon Sigurdhsson <sigurdhsson@gmail.com>
+%% 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
@@ -26,7 +26,7 @@
%% and the derived filebase skdoc.cls.
\RequirePackage{expl3}
\ProvidesExplClass{skdoc}
- {2012/12/26}{1.0}{skdoc documentation class}
+ {2013/05/24}{1.3a}{skdoc documentation class}
\PassOptionsToPackage{log-declarations=false}{xparse}
\LoadClass[ DIV7,
headings=big,
@@ -35,15 +35,16 @@
bibliography=totocnumbered,
index=totoc
]{scrartcl}
-\RequirePackage{etoolbox,xstring,xparse,atbegshi,kvoptions}
-\RequirePackage{verbatim,marginnote,calc,hyperref,multicol,hologo}
+\RequirePackage{etoolbox,xstring,xparse,atbegshi,kvoptions,pdftexcmds}
+\RequirePackage{verbatim,needspace,marginnote,calc,hyperref,multicol,hologo}
\RequirePackage[nomain,xindy,numberedsection,order=letter,
sanitize={description=false,sort=false}]{glossaries}
\RequirePackage{ydoc-code,ydoc-desc}
\RequirePackage[british]{babel}
\RequirePackage[english=british]{csquotes}
\RequirePackage[font=small,labelfont=bf,textfont=it]{caption}
-\RequirePackage{scrpage2,PTSerif,ascii}
+\RequirePackage{scrpage2,PTSerif}
+\usepackage[scaled=1.03]{inconsolata}
\RequirePackage[defaultsans,osfigures,scale=0.95]{opensans}
\RequirePackage[babel]{microtype}
\msg_new:nnn{skdoc}{key-exists}{File~key~"#1"~already~declared!}
@@ -51,17 +52,249 @@
\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
+\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]
+\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
@@ -76,13 +309,15 @@
\def\skdoc@preamble{}%
\def\skdoc@key{#2}%
\IfNoValueTF{#1}{}{\keys_set:nn{skdoc@declarefile}{#1}}
- \tl_new:c{skdoc@output@\skdoc@key}
\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}
}
- \IfStrEq{\skdoc@preamble}{}{}{
+ \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{
@@ -102,60 +337,116 @@
\AfterEndDocument{\csname skdoc@write@#2\endcsname}
\group_end:
}
+\clist_new:N\l__skdoc_keys
\DeclareDocumentEnvironment{skdoc@verbatim}{m}{%
- \iftoggle{skdoc@impl}{\@bsphack}{}
- \def\skdoc@key{#1}
- \int_if_exist:cTF{skdoc@output@\skdoc@key @line}{}{
- \msg_critical:nnx{skdoc}{key-nexists}{\skdoc@key}
- }%
- \marginnote{
- \leavevmode
- \llap{
- \scriptsize\color{gray}
- $\langle$\skdoc@key$\rangle$
- \makebox[2ex]{\strut}
+ \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{%
- \tl_gput_right:cx{skdoc@output@\skdoc@key}{\the\verbatim@line\iow_newline:}%
- \int_gincr:c{skdoc@output@\skdoc@key @line}%
- \iftoggle{skdoc@impl}{
- \noindent\leavevmode%
- \hspace*{-5ex}
- \begin{minipage}[c][1ex]{\textwidth}
- \makebox[4ex]{%
- \leavevmode
- \tiny\color{lightgray}\hfill%
- \int_use:c{skdoc@output@\skdoc@key @line}%
- }%
- \hspace*{1ex}%
- {
- \verbatim@font\footnotesize
- \the\verbatim@line
- }
- \end{minipage}
- \vskip-.75ex\par
- }{}
+ \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%
- \iftoggle{skdoc@impl}{
+ \bool_if:nT{
+ \__skdoc_if_print_code_p: &&
+ !\g__skdoc_use_minted_bool
+ }{
\frenchspacing\@vobeyspaces
- }{}
+ }
\verbatim@start%
}{%
- \iftoggle{skdoc@impl}{\@esphack}{}%
+ \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}{
- \iftoggle{skdoc@impl}{
+ \__skdoc_if_print_code:T{
\vspace{.2\baselineskip}
- \par\noindent
- }{}
+ \bool_if:NF\g__skdoc_use_minted_bool{\par\noindent}
+ }
\skdoc@verbatim{#1}
}{
\endskdoc@verbatim
- \iftoggle{skdoc@impl}{
+ \__skdoc_if_print_code:T{
\vspace{.5\baselineskip}
- }{}
+ }
}
\DeclareDocumentCommand\PreambleTo{mm}{%
\group_begin:
@@ -212,47 +503,45 @@
citecolor=black,
urlcolor=extlink
}
-\newtoggle{skdoc@noindex}
-\togglefalse{skdoc@noindex}
\DeclareDocumentCommand\cs{sm}{
\texttt{\char`\\#2}
- \iftoggle{skdoc@noindex}{}{
+ \bool_if:NF\g__skdoc_no_index_bool{
\IfBooleanTF{#1}{}{\index@macro{#2}}
}
}
\DeclareDocumentCommand\env{sm}{
\texttt{#2}
- \iftoggle{skdoc@noindex}{}{
+ \bool_if:NF\g__skdoc_no_index_bool{
\IfBooleanTF{#1}{}{\index@environment{#2}}
}
}
\DeclareDocumentCommand\pkg{sm}{
\textsf{#2}
- \iftoggle{skdoc@noindex}{}{
+ \bool_if:NF\g__skdoc_no_index_bool{
\IfBooleanTF{#1}{}{\index@package{#2}}
}
}
\DeclareDocumentCommand\opt{sm}{
\texttt{#2}
- \iftoggle{skdoc@noindex}{}{
+ \bool_if:NF\g__skdoc_no_index_bool{
\IfBooleanTF{#1}{}{\index@option{#2}}
}
}
\DeclareDocumentCommand\bib{sm}{
\texttt{@#2}
- \iftoggle{skdoc@noindex}{}{
+ \bool_if:NF\g__skdoc_no_index_bool{
\IfBooleanTF{#1}{}{\index@bibentry{#2}}
}
}
\DeclareDocumentCommand\thm{sm}{
\textrm{#2}
- \iftoggle{skdoc@noindex}{}{
+ \bool_if:NF\g__skdoc_no_index_bool{
\IfBooleanTF{#1}{}{\index@theme{#2}}
}
}
\DeclareDocumentCommand\file{sm}{
\texttt{#2}
- \iftoggle{skdoc@noindex}{}{
+ \bool_if:NF\g__skdoc_no_index_bool{
\IfBooleanTF{#1}{}{\index@file{#2}}
}
}
@@ -332,14 +621,14 @@
\Options{#1}
}
\def\skdoc@WithValues@peek{
- \ifx\@let@token\AndDefault\else\par\noindent\nobreak\fi
+ \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
+ \llap{\textcolor{gray}{\texttt{(#1)}}}\par\noindent\nobreak\ignorespaces
}
\DeclareDocumentCommand\BibEntry{m}{
\marginnote{
@@ -355,25 +644,75 @@
\textcolor{gray}{\texttt{,#2}}
}
}
- \par\noindent\nobreak
+ \par\noindent\nobreak\ignorespaces
}
\DeclareDocumentCommand\Theme{m}{
\marginnote{
\index@theme*{#1}
\hfill\llap{\textcolor{macrodesc}{\thm{#1}}}
}
- \nobreak\par\noindent\nobreak
+ \nobreak\par\noindent\nobreak\ignorespaces
}
\DeclareDocumentCommand\DescribeFile{m}{
\marginnote{
\index@file*{#1}
\hfill\llap{\textcolor{macrodesc}{\file{#1}}}
}
- \nobreak\par\noindent\nobreak
+ \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}{}{
- \minisec{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}{%
\@bsphack
\index@macro!{\expandafter\@gobble\string#2}
@@ -381,7 +720,7 @@
\IfBooleanTF{#1}{
\IfNoValueTF{#3}{}{
\int_compare:nNnTF{#3}>{0}{
- \cs:w use_none:\prg_replicate:nn{#3}{n}\cs_end:
+ \use:c{use_none:\prg_replicate:nn{#3}{n}}
}{}
}
}{
@@ -401,7 +740,7 @@
\IfBooleanTF{#1}{
\IfNoValueTF{#3}{}{
\int_compare:nNnTF{#3}>{0}{
- \cs:w use_none:\prg_replicate:nn{#3}{n}\cs_end:
+ \use:c{use_none:\prg_replicate:nn{#3}{n}}
}{}
}
}{
@@ -467,9 +806,11 @@
\DeclareDocumentEnvironment{theme*}{m}%
{\begin{theme}*{#1}}{\end{theme}}
\def\PrintEnvImplName#1{%
- \par\mbox{}
- \marginnote{\llap{\implstyle{#1}}}
- \par
+ \par\leavevmode\null
+ \hbox{%
+ \marginnote{\llap{\implstyle{#1\strut}}}%
+ }
+ \null
}
\def\PrintMacroImpl#1{%
\par
@@ -508,21 +849,20 @@
\vspace*{-\baselineskip}
\par\noindent{#1\strut}\par\medskip%
}
-\prg_new_conditional:Nnn\__skdoc_do_index:{p}{
- \iftoggle{skdoc@impl}{
+\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:
}{
- \iftoggle{skdoc@in@impl}{
- \prg_return_false:
- }{
- \prg_return_true:
- }
+ \prg_return_false:
}
}
\DeclareDocumentCommand\@index@{mm}{
- \if_predicate:w\__skdoc_do_index_p:
+ \__skdoc_if_do_index:T{
\@index@@{#1}{#2}
- \fi:
+ }
}
\DeclareDocumentCommand\@index@@{mm}{
\newglossaryentry{index-#1}{
@@ -537,7 +877,7 @@
\ifglsentryexists{index-\skdoc@temp}{}{
\@index@{#3}{\cs*{#3}}
}
- \if_predicate:w\__skdoc_do_index_p:
+ \__skdoc_if_do_index:T{
\IfBooleanTF{#2}{
\glsadd[types=index,format=hyperul]{index-\skdoc@temp}
}{
@@ -547,14 +887,14 @@
\glsadd[types=index]{index-\skdoc@temp}
}
}
- \fi:
+ }
}
\DeclareDocumentCommand\index@environment{st!m}{
\def\skdoc@temp{\string#3}
\ifglsentryexists{index-\skdoc@temp}{}{
\@index@{\string#3}{\env*{\string#3}~(environment)}
}
- \if_predicate:w\__skdoc_do_index_p:
+ \__skdoc_if_do_index:T{
\IfBooleanTF{#2}{
\glsadd[types=index,format=hyperul]{index-\skdoc@temp}
}{
@@ -564,14 +904,14 @@
\glsadd[types=index]{index-\skdoc@temp}
}
}
- \fi:
+ }
}
\DeclareDocumentCommand\index@option{st!m}{
\def\skdoc@temp{\string#3}
\ifglsentryexists{index-\skdoc@temp}{}{
\@index@{\string#3}{\opt*{\string#3}~(option)}
}
- \if_predicate:w\__skdoc_do_index_p:
+ \__skdoc_if_do_index:T{
\IfBooleanTF{#2}{
\glsadd[types=index,format=hyperul]{index-\skdoc@temp}
}{
@@ -581,14 +921,14 @@
\glsadd[types=index]{index-\skdoc@temp}
}
}
- \fi:
+ }
}
\DeclareDocumentCommand\index@bibentry{st!m}{
\def\skdoc@temp{#3}
\ifglsentryexists{index-\skdoc@temp}{}{
\@index@{#3}{\bib*{#3}~(\hologoRobust{BibTeX}~entry~type)}
}
- \if_predicate:w\__skdoc_do_index_p:
+ \__skdoc_if_do_index:T{
\IfBooleanTF{#2}{
\glsadd[types=index,format=hyperul]{index-\skdoc@temp}
}{
@@ -598,14 +938,14 @@
\glsadd[types=index]{index-\skdoc@temp}
}
}
- \fi:
+ }
}
\DeclareDocumentCommand\index@theme{st!m}{
\def\skdoc@temp{\string#3}
\ifglsentryexists{index-\skdoc@temp}{}{
\@index@{\string#3}{\thm*{\string#3}~(theme)}
}
- \if_predicate:w\__skdoc_do_index_p:
+ \__skdoc_if_do_index:T{
\IfBooleanTF{#2}{
\glsadd[types=index,format=hyperul]{index-\skdoc@temp}
}{
@@ -615,14 +955,14 @@
\glsadd[types=index]{index-\skdoc@temp}
}
}
- \fi:
+ }
}
\DeclareDocumentCommand\index@package{st!m}{
\def\skdoc@temp{\string#3}
\ifglsentryexists{index-\skdoc@temp}{}{
\@index@{\string#3}{\pkg*{\string#3}~(package)}
}
- \if_predicate:w\__skdoc_do_index_p:
+ \__skdoc_if_do_index:T{
\IfBooleanTF{#2}{
\glsadd[types=index,format=hyperul]{index-\skdoc@temp}
}{
@@ -632,14 +972,14 @@
\glsadd[types=index]{index-\skdoc@temp}
}
}
- \fi:
+ }
}
\DeclareDocumentCommand\index@file{st!m}{
\def\skdoc@temp{\string#3}
\ifglsentryexists{index-\skdoc@temp}{}{
\@index@{\string#3}{\file*{\string#3}~(file)}
}
- \if_predicate:w\__skdoc_do_index_p:
+ \__skdoc_if_do_index:T{
\IfBooleanTF{#2}{
\glsadd[types=index,format=hyperul]{index-\skdoc@temp}
}{
@@ -649,7 +989,7 @@
\glsadd[types=index]{index-\skdoc@temp}
}
}
- \fi:
+ }
}
\ProvideDocumentCommand\hyperul{m}{
\underline{\hyperup{#1}}
@@ -658,14 +998,14 @@
\glossarystyle{indexgroup}
\renewcommand*{\glspostdescription}{\unskip\leaders\hbox to 2.9mm{\hss.}\hfill\strut}
\renewenvironment{theglossary}{
- \toggletrue{skdoc@noindex}
+ \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}
- \togglefalse{skdoc@noindex}
+ \bool_gset_false:N\g__skdoc_no_index_bool
}
\renewcommand*{\glossaryentryfield}[5]{
\item\glsentryitem{##1}\glstarget{##1}{##2}
@@ -687,7 +1027,7 @@
\providecommand*\PrintIndex{%
\begingroup
\renewcommand*{\glossarypreamble}{
- Numbers~written~in~boldface~refer~to~the~page~where~the~
+ 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~
@@ -758,11 +1098,11 @@
\newglossarystyle{changelog}{
\glossarystyle{altlist}
\renewenvironment{theglossary}{
- \toggletrue{skdoc@noindex}
+ \bool_gset_true:N\g__skdoc_no_index_bool
\begin{multicols}{2}\begin{description}
}{
\end{description}\end{multicols}
- \togglefalse{skdoc@noindex}
+ \bool_gset_false:N\g__skdoc_no_index_bool
}
\renewcommand*{\glossaryentryfield}[5]{
\par\vspace{5\p@}\relax
@@ -782,21 +1122,17 @@
\printglossary[type=changes,style=changelog]
\endgroup
}
-\newtoggle{skdoc@impl}
-\newtoggle{skdoc@in@impl}
-\toggletrue{skdoc@impl}
-\togglefalse{skdoc@in@impl}
\newcounter{skdoc@impl@page}
\AtBeginShipout{
- \iftoggle{skdoc@impl}{}{
- \iftoggle{skdoc@in@impl}{\AtBeginShipoutDiscard}{}
- }
+ \__skdoc_if_print_code:F{\AtBeginShipoutDiscard}
+}
+\DeclareDocumentCommand\OnlyDescription{}{
+ \bool_gset_false:N\g__skdoc_with_implementation_bool
}
-\DeclareDocumentCommand\OnlyDescription{}{\togglefalse{skdoc@impl}}
\DeclareDocumentCommand\Implementation{}{
- \iftoggle{skdoc@impl}{}{
+ \bool_if:NF\g__skdoc_with_implementation_bool{
\clearpage
- \toggletrue{skdoc@in@impl}
+ \bool_gset_true:N\g__skdoc_in_implementation_bool
\let\skdoc@old@part\part
\DeclareDocumentCommand\part{som}{}
\let\skdoc@old@section\section
@@ -809,13 +1145,15 @@
\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{}{
- \iftoggle{skdoc@impl}{}{
+ \bool_if:NF\g__skdoc_with_implementation_bool{
+ \cs_if_exist:NTF\refsection{\printbibliography\endrefsection}{}
\clearpage
- \togglefalse{skdoc@in@impl}
+ \bool_gset_false:N\g__skdoc_in_implementation_bool
\let\part\skdoc@old@part
\let\section\skdoc@old@section
\let\subsection\skdoc@old@subsection
@@ -967,11 +1305,11 @@
\AtEndDocument{\addtocontents{toc}{\par}}
\let\old@tableofcontents\tableofcontents
\DeclareDocumentCommand\tableofcontents{}{
- \toggletrue{skdoc@noindex}
+ \bool_gset_true:N\g__skdoc_no_index_bool
\microtypesetup{protrusion=false}
\old@tableofcontents
\microtypesetup{protrusion=true}
- \togglefalse{skdoc@noindex}
+ \bool_gset_false:N\g__skdoc_no_index_bool
}
\DeclareDocumentCommand\PrintLPPL{}{
\begingroup
@@ -1040,6 +1378,7 @@
\ifdefined\defbibheading
\defbibheading{bibliography}[\bibname]{\section{#1}}
\fi
+ \@ifpackageloaded{bibtex}{\msg_warning:nn{skdoc}{bibtex-unsupported}}{}
}
\AtBeginDocument{\reversemarginpar}
\endinput