File: tcode.sty

package info (click to toggle)
tcode 0.1.20080918-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 440 kB
  • sloc: perl: 831; xml: 84; sh: 37; csh: 16; makefile: 13
file content (214 lines) | stat: -rw-r--r-- 7,814 bytes parent folder | download | duplicates (2)
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
\RequirePackage{html}
\RequirePackage{alltt}
\ProvidesPackage{tcode}
    [2003/08/01 TCode]

\latex{
\newcommand{\param}[2]{\paragraph{\texttt{#1}: }#2}
\newcommand{\blocktag}[2]{\paragraph{\texttt{#1}: }#2}
\newcommand{\return}[1]{\paragraph{\textbf{Returns} }#1}
\newcommand{\exception}[2]{\paragraph{\texttt{#1}: }#2}
\def\bs{\char92}
\newcommand{\htsum}{\sum}
\newcommand{\htint}{\int}
\newcommand{\htprod}{\prod}
}

%\def\defmodule#1 {\addcontentsline{toc}{subsection}{#1} \markboth{#1}{#1}
%   \centerline {\LARGE\bf #1}\bigskip \thispagestyle{nomark}}
\def\defclass#1 {\section*{\centerline {\LARGE\bf #1}}\bigskip
  \markboth{#1}{#1}\thispagestyle{nomark}
   \addcontentsline{toc}{subsection}{#1}}
\let\defmodule=\defclass

\newcommand{\guisec}[1]{\vspace{20pt}
\noindent\hrulefill\hspace{10pt}{\bf #1}\hspace{10pt}\hrulefill
\vspace{10pt}\nopagebreak}

\newif\ifdetailed\detailedtrue
\def\detailed{\begingroup\setbox0=\vbox\bgroup\smallskip}
\def\enddetailed{\egroup\ifdetailed\unvbox0\fi\endgroup}

\def\citep{\@ifnextchar [{\@tempswatrue\@citexp}{\@tempswafalse\@citexp[]}}


{\obeyspaces\gdef {\ }}
\def\setverbatim{\def\par{\leavevmode\endgraf}
            \parskip=0pt\parindent=0pt\obeylines\obeyspaces }
\chardef\other=12
\def\ttverbatim{\setverbatim\tt
       \catcode`~=\other
       \catcode`\{=\other \catcode`\}=\other \catcode`\_=\other
       \catcode`\^=\other \catcode`\$=\other \catcode`\%=\other
       \catcode`\#=\other \catcode`\&=\other \baselineskip=11pt
       }
    % Reproduit tel quel ce qui est ecrit, en caracteres \tt.
    % On doit faire  \begingroup\ttverbatim   ....  \endgroup
\def\smallttverbatim{\ttverbatim\small\tt}
\def\code {\vfil\vfilneg\vbox\bgroup\ttverbatim}
\def\longcode {\vfil\vfilneg\bgroup\ttverbatim}
\def\smallc {\small\tt\baselineskip=9.5pt}
\def\footc {\footnotesize\tt\baselineskip=9.0pt}
\def\smallcode {\code\smallc}
\let\endcode=\egroup
\let\endlongcode=\egroup
\let\vcode=\code
\let\endvcode=\egroup


% \latex{\def\bs{\char92}}
% \html{\def\bs{\rawhtml\\endrawhtml}}


% Changes @ into an ordinary character.
\makeatletter

%\def\latexonly{}
%\def\endlatexonly{}

% We define a TeX command that takes anything as an argument.
% But the argument must be followed by some predetermined string.
% Strongly inspired from the LaTeX verbatim environment
% Some catcodes must be changed to allow \, { and } inside
% that string. Without any change, this would be processed as a
% control sequence instead of a normal string.
% Here, the group is not a macro and the tokens are
% processed, so the catcode changes have immediate effect.
\begingroup \catcode `|=0 \catcode `[= 1
\catcode`]=2 \catcode `\{=12 \catcode `\}=12
\catcode`\\=12 |gdef|@xhideenv#1\end{hide}[|end[hide]]
|gdef|@xhide#1\endhide[|endhide]
|endgroup

% This command activates the verbatim mode that will allow
% the command defined above to take paragraphs as its argument, not
% only one line of text as in usual cases. The catcode of
% every special character, including escape, is changed to other
% so no LaTeX command will be processed. The commands following
% the \let\do line has effect even if \ is redefined because
% the \@hide command's definition was tokenized before the catcodes
% change.
\def\@hide{\ttverbatim
  \let\do\@makeother \dospecials
%\obeylines
  \everypar \expandafter{\the\everypar \unpenalty}%
\@vobeyspaces
}

% To make an environment that hides its contents, we put
% the contents into box0 instead of the outer vertical list.
% If full is set to true, the boxing will be undone and
% the contents, moved to the outer vertical list.
% The outer grouping allows the box to be local to the
% environments. With boxes like that, nesting is allowed.
\newif\ifhide\hidetrue
\def\hide{\begingroup\setbox0=\vbox\bgroup\smallskip}
% \def\endhide{\egroup\iffull\unvbox0\fi\endgroup}
\def\endhide{\egroup\ifhide\else\unvbox0\fi\endgroup}
%  perhaps  \iffull ...\fi  -->  \ifhide\else ... \fi


% Here, we use a different strategy because no command processing
% must occur. First, verbatim mode is enabled and a special
% command is called. This command takes one argument and
% must be followed by \end{htmlonly}. The argument, which is the
% contents of the environment, will be discarded without processing.
% This technique is strongly inspired from the LaTeX verbatim
% environment.
%\def\htmlonly{\begingroup\@hide \@xhtmlonly}
%\def\endhtmlonly{\endgroup}

% When tokenizing the definition of code command,
% TeX must know that { and } can be part of a TeX command,
% [ and ] must become group delimiters.
% These changes will apply to a group defined here, not
% for the content inside the code environment.
% Inside the code command, we must redefine the catcode.
% When the macro is expanded, it will execute the catcode tokens,
% changing again { and } to make them ``letters''.
\begingroup
\catcode`\{=11
\catcode`\}=11
\catcode`\[=1
\catcode`\]=2
\gdef\@code[\ttverbatim
\let\@xh=\@xhide
\def\hide[\bgroup
  \let\do\@makeother \dospecials
  \everypar \expandafter[\the\everypar \unpenalty]%
  \@vobeyspaces \@xh]
\def\endhide[\egroup\let\@xh=\@xhide]
\catcode`\{=11
\catcode`\}=11
\def\begin{hide}[\let\@xh=\@xhideenv
\begin[hide]]
]
\gdef\code[\vfil\vfilneg\vbox\bgroup\@code
\def\end{code}[\end[code]]]
\gdef\longcode[\vfil\vfilneg\bgroup\@code
\def\end{longcode}[\end[longcode]]]
\gdef\smallcode[\code\smallc
\def\end{smallcode}[\end[smallcode]]]
\gdef\vcode[\code
\def\end{vcode}[\end[vcode]]]
\gdef\longvcode[\longcode
\def\end{longvcode}[\end[longvcode]]]
\endgroup
\def\endcode{\egroup}
\def\endlongcode{\egroup}
\def\endsmallcode{\egroup}
\def\endvcode{\egroup}
\def\endlongvcode{\egroup}

%%  This is adapted from \boxedverbatim in moreverb.sty
\def\boxedverbatiminput#1{%
  \def\verbatim@processline{%
    {\setbox1=\hbox{\the\verbatim@line}%
    \hsize=\wd0 \the\verbatim@line\par}}%
  \@minipagetrue%%%DPC%%%
  \@tempswatrue%%%DPC%%%
  \setbox0=\vbox\bgroup \verbatiminput{#1}\egroup
  \centerline{\fbox{\box0}}%
}

\makeatother

\def\parup{\nobreak\vskip -2pt\nobreak}
\def\tab{\begingroup\small\parindent=0pt%
   \advance\leftskip by 1.5em\parup}
\def\tabb{\begingroup\small\parindent=0pt%
   \advance\leftskip by 3.0em\parup}
\def\tabbb{\begingroup\small\parindent=0pt%
   \advance\leftskip by 4.5em\parup}
\def\endtab{\vskip 0.01pt\advance\leftskip by -1.5em\normalsize%
    \endgroup}
\def\endtabb{\vskip 0.01pt\advance\leftskip by -3.0em\normalsize%
    \endgroup}
\def\endtabbb{\vskip 0.01pt\advance\leftskip by -4.5em\normalsize%
    \endgroup}

% The class and externalclass macros could be merged if it was
% possible to react differently if an optional argument is absent.
% TeX, unfortunately, does not support overloading of macros.
% class could have an optional argument for the package.
% If it is specified, we format \texttt{package.class}.
% If not, we format \texttt{class}. To have that work,
% we would have to force the user to append a period after
% the package name (\class[package.]{class}).
\def\class#1{\texttt{#1}}
\def\externalclass#1#2{\texttt{#2}}

% The same type of problem happens here.
% Signature could be turned into an optional argument,
% but it would have to go at the beginning of the method,
% which is not intuitive. (e.g. \method[double]{density})
\def\method#1#2{\texttt{#1}}
% We have to choose whether the name of the class will be prepended
% before the name of the method.  This increases the quantity
% of long typed-text names that result in overfull hboxe.
% In Javadoc, since the name is an hyperlink, the class name is
% less a necessity. So in general, it is not required. One can
% prepend it manually before the \externalmethod if needed.
\def\externalmethod#1#2#3#4{\texttt{#3}}
\def\clsexternalmethod#1#2#3#4{\texttt{#2}\discretionary{}{}{}\texttt{.#3}}
\def\unmoved{\relax}