summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/dox/dox.sty
blob: c2ef47d8a8f1b1b335fd617fecfb4b83449565ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
%%
%% 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 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.1
%% 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.1 or later is part of all distributions of LaTeX
%% version 1999/06/01 or later.

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

%% \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}[2010/12/16 v2.2 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}%
    \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\@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}}
\@doxcreateenv{Macro}{macro}

\@doxcreatedescribe{Env}
\@doxcreateenv{Env}{environment}

\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}}

\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'.