%%
%% This is file `dox.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% dox.dtx  (with options: `header,dox')
%% 


%% Copyright (C) 2009, 2010, 2017 Didier Verna

%% This file is part of DoX.

%% DoX 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.

%% DoX consists of the files listed in the file `README.md'.

%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dox}[2017/01/26 v2.3 Extensions to the doc package]

\RequirePackage{kvoptions}
\SetupKeyvalOptions{family=dox,prefix=dox@}

\DeclareBoolOption{noprint}
\DeclareBoolOption{noindex}
\DeclareBoolOption{macrolike}
\DeclareStringOption{idxtype}

\long\def\@@doxenv#1#2{%
  \endgroup%
  \topsep\MacroTopsep%
  \trivlist%
    \edef\saved@macroname{\string#2}%
    \@nameuse{@Save#1IndexName}{\saved@macroname}%
    \def\makelabel##1{\llap{##1}}%
    \if@inlabel%
      \let\@tempa\@empty%
      \count@\macro@cnt%
      \loop\ifnum\count@>\z@%
        \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne%
      \repeat%
      \edef\makelabel##1{\llap{\vtop to\baselineskip{\@tempa\hbox{##1}\vss}}}%
      \advance\macro@cnt\@ne%
    \else%
      \macro@cnt\@ne%
    \fi%
    \ifdox@noprint%
      \item%
    \else%
      \edef\@tempa{%
        \noexpand\item[%
        \expandafter\noexpand\csname Print#1Name\endcsname{\saved@macroname}]}%
      \@tempa%
    \fi%
    \ifdox@noindex\else%
      \global\advance\c@CodelineNo\@ne%
      \@nameuse{SpecialMain#1Index}{#2}\nobreak%
      \global\advance\c@CodelineNo\m@ne%
    \fi%
    \ignorespaces}
\def\@doxenv#1[#2]{%
  \@nameuse{dox@noprint\dox@noprintdefault}%
  \@nameuse{dox@noindex\dox@noindexdefault}%
  \setkeys{dox}{#2}%
  \begingroup%
    \catcode`\\12%
    \MakePrivateLetters%
    \@@doxenv{#1}}

\def\@@doxdescribe#1#2{%
    \endgroup%
    \ifdox@noprint\else%
      \marginpar{\raggedleft\@nameuse{PrintDescribe#1}{#2}}%
    \fi%
    \ifdox@noindex\else%
      \@nameuse{Special#1Index}{#2}%
    \fi%
    \endgroup%
  \@esphack\ignorespaces}
\def\@doxdescribe#1[#2]{%
  \leavevmode\@bsphack%
  \begingroup%
    \setkeys{dox}{#2}%
    \begingroup%
      \MakePrivateLetters%
      \@@doxdescribe{#1}}

\def\@doxsavemacrolikeindexname#1{%
  \edef\saved@indexname{\expandafter\@gobble#1}}
\def\@doxsaveindexname#1{\let\saved@indexname#1}

\def\@doxcreatespecialmainindex#1#2#3{%
  \expandafter\def\csname SpecialMain#1Index\endcsname##1{%
    \@bsphack%
    \special@index{##1\actualchar{\string\ttfamily\space##1} (#2)
      \encapchar main}%
    \special@index{#3:\levelchar##1\actualchar{\string\ttfamily\space##1}
      \encapchar main}%
    \@esphack}}
\def\@doxcreatespecialmainmacrolikeindex#1#2#3{%
  \expandafter\def\csname SpecialMain#1Index\endcsname##1{%
    \@SpecialIndexHelper@##1\@nil
    \@bsphack%
    \special@index{\@gtempa\actualchar
      \string\verb\quotechar*\verbatimchar\bslash\@gtempa\verbatimchar
      \space(#2)\encapchar main}%
    \special@index{#3:\levelchar\@gtempa\actualchar%
      \string\verb\quotechar*\verbatimchar\bslash\@gtempa\verbatimchar
      \encapchar main}%
    \@esphack}}

\def\@doxcreatespecialindex#1#2#3{%
  \expandafter\def\csname Special#1Index\endcsname##1{%
    \@bsphack%
    \index{##1\actualchar{\protect\ttfamily##1} (#2)\encapchar usage}%
    \index{#3:\levelchar##1\actualchar{\protect\ttfamily##1}
      \encapchar usage}%
    \@esphack}}
\def\@doxcreatespecialmacrolikeindex#1#2#3{%
  \expandafter\def\csname Special#1Index\endcsname##1{%
    \@SpecialIndexHelper@##1\@nil
    \@bsphack%
    \index{\@gtempa\actualchar
      \string\verb\quotechar*\verbatimchar\bslash\@gtempa\verbatimchar
      \space(#2)\encapchar usage}%
    \index{#3:\levelchar\@gtempa\actualchar
      \string\verb\quotechar*\verbatimchar\bslash\@gtempa\verbatimchar
      \encapchar usage}%
    \@esphack}}

\def\@doxcreatedescribe#1{%
  \expandafter\def\csname Describe#1\endcsname{%
    \@ifnextchar[%]
    {\@doxdescribe{#1}}{\@doxdescribe{#1}[]}}}

\def\@doxcreateenv#1#2{%
  \expandafter\def\csname #2\endcsname{%
    \@ifnextchar[%]
    {\@doxenv{#1}}{\@doxenv{#1}[]}}
  \expandafter\let\csname end#2\endcsname\endtrivlist}

\let\SpecialMacroIndex\SpecialUsageIndex
\@doxcreatedescribe{Macro}

\def\SpecialMainMacroIndex#1{%
  \SpecialMainIndex{#1}\nobreak%
  \DoNotIndex{#1}}
\let\@SaveMacroIndexName\@doxsavemacrolikeindexname
\@doxcreateenv{Macro}{macro}

\@doxcreatedescribe{Env}
\@doxcreateenv{Env}{environment}
\let\@SaveEnvIndexName\@doxsaveindexname

\newcommand\doxitem[4][]{%
  \@nameuse{dox@macrolike\dox@macrolikedefault}%
  \def\dox@idxtype{#3}%
  \setkeys{dox}{#1}
  \@ifundefined{Print#2Name}{%
    \ifdox@macrolike
      \expandafter\def\csname Print#2Name\endcsname##1{%
        \strut\MacroFont\string ##1\ }
    \else
      \expandafter\def\csname Print#2Name\endcsname##1{%
        \strut\MacroFont ##1\ }
    \fi}{}
  \ifdox@macrolike
    \def\@doxexpr{\@doxcreatespecialmainmacrolikeindex{#2}}%
  \else
    \def\@doxexpr{\@doxcreatespecialmainindex{#2}}%
  \fi
  \expandafter\@doxexpr\expandafter{\dox@idxtype}{#4}%
  \@ifundefined{PrintDescribe#2}{%
    \ifdox@macrolike
      \expandafter\def\csname PrintDescribe#2\endcsname##1{%
        \strut\MacroFont\string ##1\ }
    \else
      \expandafter\def\csname PrintDescribe#2\endcsname##1{%
        \strut\MacroFont ##1\ }
    \fi}{}
  \ifdox@macrolike
    \def\@doxexpr{\@doxcreatespecialmacrolikeindex{#2}}%
  \else
    \def\@doxexpr{\@doxcreatespecialindex{#2}}%
  \fi
  \expandafter\@doxexpr\expandafter{\dox@idxtype}{#4}%
  \@doxcreatedescribe{#2}
  \@doxcreateenv{#2}{#3}
  \ifdox@macrolike
    \expandafter\let\csname @Save#2IndexName\endcsname%
      \@doxsavemacrolikeindexname%
  \else
    \expandafter\let\csname @Save#2IndexName\endcsname\@doxsaveindexname%
  \fi}
\ProcessKeyvalOptions*
\ifdox@noprint
  \def\dox@noprintdefault{true}
\else
  \def\dox@noprintdefault{false}
\fi
\ifdox@noindex
  \def\dox@noindexdefault{true}
\else
  \def\dox@noindexdefault{false}
\fi
\ifdox@macrolike
  \def\dox@macrolikedefault{true}
\else
  \def\dox@macrolikedefault{false}
\fi

\endinput
%%
%% End of file `dox.sty'.
