3 %%% Styles and other hacking for the Sod manual
5 %%% (c) 2015 Straylight/Edgeware
8 %%%----- Licensing notice ---------------------------------------------------
10 %%% This file is part of the Sensible Object Design, an object system for C.
12 %%% SOD is free software; you can redistribute it and/or modify
13 %%% it under the terms of the GNU General Public License as published by
14 %%% the Free Software Foundation; either version 2 of the License, or
15 %%% (at your option) any later version.
17 %%% SOD is distributed in the hope that it will be useful,
18 %%% but WITHOUT ANY WARRANTY; without even the implied warranty of
19 %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 %%% GNU General Public License for more details.
22 %%% You should have received a copy of the GNU General Public License
23 %%% along with SOD; if not, write to the Free Software Foundation,
24 %%% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 %% More reference types.
33 %% Other languages with special typesetting.
34 \def\Cplusplus{C\kern-\p@++}
37 %% Special maths notation.
38 \def\chain#1#2{\mathsf{ch}_{#1}(#2)}
39 \def\chainhead#1#2{\mathsf{hd}_{#1}(#2)}
40 \def\chaintail#1#2{\mathsf{tl}_{#1}(#2)}
42 %% Other mathematical tweaks.
43 \let\implies\Rightarrow
44 \let\epsilon\varepsilon
46 %% A table heading cell. Clone and hack \multicolumn.
47 \def\thd{\omit\@ifnextchar[\thd@{\thd@[l]}}
50 \tab@multicol \tab@initread \let\tab@looped\tab@err@multi
51 \tab@preamble{}\def\tab@midtext{\bfseries#2}\tab@readpreamble{#1}%
53 \endgroup \ignorespaces
56 %% Unix manpage references.
57 \def\man#1#2{\textbf{#1}(#2)}
59 %% Listings don't need to be small.
60 \let\listingsize\relax
63 \def\fixme#1{\leavevmode\marginpar{FIXME}\index{FIXME}[FIXME: #1]}
67 every picture/.style={>=stealth, thick},
68 lit/.style={font=\sffamily}
71 %% Metavariables are italics without decoration.
72 \def\syntleft{\normalfont\itshape}
75 %% Literal code is in sans face.
76 \def\codeface{\upshape\sffamily}
77 \DeclareRobustCommand\code[1]{%
78 \ifmmode\hbox\else\leavevmode\fi%
79 {\normalfont\codeface\/#1\/}%
81 \def\ulitleft{\normalfont\codeface}
83 \def\lit@i#1#2#3{\ifmmode\leavevmode\hbox\fi{#1{#3\/}#2}}
85 %% Conditionally enter maths mode. Can't use \ensuremath here because we
86 %% aren't necessarily sure where the maths will actually end.
87 \let\m@maybe@end\relax
88 \def\m@maybe{\ifmmode\else$\let\m@maybe@end$\fi}
90 %% Standard syntax shortcuts.
91 \atdef <#1>{\synt{#1}\@scripts}
92 \atdef "#1"{\lit*{#1}\@scripts}
93 \atdef `#1'{\lit{#1}\@scripts}
94 \atdef |#1|{\lit*{#1}\@scripts}
96 %% A handy abbreviation; `\\' itself is too good to steal.
97 \atdef \\{\textbackslash}
99 %% Intercept grammar typesetting and replace the vertical bar with the
100 %% maths-font version.
101 \let\@@grammar\grammar
102 \def\grammar{\def\textbar{\hbox{$|$}}\@@grammar}
104 %% Collect super- and subscripts. (Note that underscores are active for the
105 %% most part.) When we're done, end maths mode if we entered it
107 \def\@scripts{\futurelet\@ch\@scripts@i}
108 \begingroup\lccode`\~=`\_\lowercase{\endgroup
109 \def\@scripts@i{\if1\ifx\@ch~1\else\ifx\@ch^1\else0\fi\fi%
110 \expandafter\@scripts@ii\else\expandafter\m@maybe@end\fi}}
111 \def\@scripts@ii#1#2{\m@maybe#1{#2}\@scripts}
113 %% Doubling characters, maybe. Either way, chain onto \@scripts.
114 \def\dbl@maybe#1{\let\@tempa#1\futurelet\@ch\dbl@maybe@i}
115 \def\dbl@maybe@i{\m@maybe\ifx\@ch\@tempa\@tempa\!\@tempa%
116 \expandafter\@firstoftwo\expandafter\@scripts%
117 \else\@tempa\expandafter\@scripts\fi}
119 %% Lookahead without eating spaces.
120 \def\@ifnextchar@preserve#1#2#3{%
121 \let\want@= #1\def\@tempa{#2}\def\@tempb{#3}%
122 \futurelet\nch@\@ifnch@p%
125 \ifx\want@\nch@\expandafter\@tempa\else\expandafter\@tempb\fi}
127 %% Extra syntax for Lisp templates. These produce the maths-font versions of
128 %% characters, which should contrast well against the sans face used for
130 \atdef [{\dbl@maybe[}
131 \atdef ]{\dbl@maybe]}
132 \atdef {{\m@maybe\{\@scripts}
133 \atdef }{\m@maybe\}\@scripts}
134 \atdef ({\m@maybe(\@scripts}
135 \atdef ){\m@maybe)\@scripts}
136 \atdef !{\m@maybe|\@scripts}
137 \def\returns{\m@maybe\longrightarrow\m@maybe@end\hspace{0.5em}\ignorespaces}
138 \atdef >{\leavevmode\unskip\hspace{0.5em}\returns}
139 \atdef -{\leavevmode\hbox\bgroup\futurelet\ch@\@dash}
142 --\raisebox{.4pt}{>}%
143 \def\next@{\@firstoftwo{\egroup\penalty200\relax}}%
146 \def\next@{\@firstoftwo{\futurelet\ch@\@dash}}%
155 \def\comment#1{\mbox{\normalfont\itshape\/#1\/}}
156 \atdef /*#1*/{/*\comment{#1}*/}
157 \def\@semis;{\@ifnextchar@preserve;{;\@semis}\@semicomment}
158 \def\@semicomment#1\\{\comment{#1}\\}
161 %% Environment for setting programs. Newlines are explicit, because
162 %% otherwise I need comments in weird places to make the vertical spacing
163 %% come out properly. You can write `\obeylines' if you really want to.
164 \def\@prog{\let\prog@@cr\@tabcr\let\@tabcr\@progcr\codeface\tabbing}
165 \def\prog{\quote\@prog}
166 \def\endprog{\endtabbing\endquote}
168 \let\endnprog\endtabbing
169 \def\ind{\quad\=\+\kill}
170 \def\@progcr{\futurelet\@tempa\@progcr@i}
171 {\def\:{\gdef\@progcr@sp}\: {\@progcr}}
172 \atdef~{\textasciitilde}
174 \ifx\@tempa\@sptoken\let\next@\@progcr@sp\else
175 \if1\ifx\@tempa[1\else
178 \let\next@\prog@@cr\else
179 \if1\ifx\@tempa+1\else
182 \let\next@\@progcr@ii\else
183 \let\next@\@progcr@a\fi\fi\fi
185 \def\@progcr@a{\prog@@cr*{}\ignorespaces}
186 \def\@progcr@ii#1{\csname @progcr@#1\endcsname\ignorespaces}
187 \@namedef{@progcr@+}{\prog@@cr[\medskipamount]}
188 \@namedef{@progcr@-}{\prog@@cr*[\jot]}
189 \def\macsl{\`\textbackslash\hskip\leftmargin}
191 %% Put a chunk of text in a box.
192 \newenvironment{boxy}[1][\q@]{%
194 \dimen@\linewidth\advance\dimen@-1.2pt\advance\dimen@-2ex%
196 \vbox\bgroup\hrule\hbox\bgroup\vrule%
197 \vbox\bgroup\vskip1ex\hbox\bgroup\hskip1ex\minipage\dimen@%
198 \def\@temp{#1}\ifx\@temp\q@\else\leavevmode{\headfam\bfseries#1\quad}\fi%
200 \endminipage\hskip1ex\egroup\vskip1ex\egroup%
201 \vrule\egroup\hrule\egroup%
206 %% Lisp documentation machinery.
207 \def\definedescribecategory#1{%
208 \@ifnextchar[{\def@desc{#1}}{\def@desc{#1}[plain]}}
209 \def\def@desc#1[#2]#3{\@namedef{cat!#1}##1{#3}\@namedef{catsw!#1}{#2}}
210 \def\describecategoryname{\@ifnextchar[\@descname@i{\@descname@i[]}}
211 \def\@descname@i[#1]#2{%
212 \expandafter\let\expandafter\@tempa\csname cat!#2\endcsname%
213 \expandafter\let\expandafter\@tempb\csname modcat/#1\endcsname%
214 \ifx\@tempa\relax\@tempb{#2}\else\@tempa\@tempb\fi}
215 \def\@mod@dispatch#1#2{\csname #1/#2\endcsname}
216 \def\@desc@dispatch#1#2{%
218 \expandafter\ifx\csname catsw!#2\endcsname\relax plain%
219 \else \csname catsw!#2\endcsname \fi%
223 \definedescribecategory{sym}{symbol}
224 \definedescribecategory{fun}{#1{function}}
225 \definedescribecategory{gf}{generic #1{function}}
226 \definedescribecategory{msg}{message}
227 \definedescribecategory{var}{variable}
228 \definedescribecategory{modvar}{module variable}
229 \definedescribecategory{const}{constant}
230 \definedescribecategory{meth}[method]{primary #1{method}}
231 \definedescribecategory{ar-meth}[method]{\code{:around} #1{method}}
232 \definedescribecategory{be-meth}[method]{\code{:before} #1{method}}
233 \definedescribecategory{af-meth}[method]{\code{:after} #1{method}}
234 \definedescribecategory{cls}{class}
235 \definedescribecategory{rst}{restart}
236 \definedescribecategory{ty}{type}
237 \definedescribecategory{type}{type}
238 \definedescribecategory{mac}{#1{macro}}
239 \definedescribecategory{feat}{feature macro}
240 \definedescribecategory{lmac}{local #1{macro}}
241 \definedescribecategory{parse}{parser spec}
242 \definedescribecategory{parseform}{parser form}
243 \definedescribecategory{opt}{option handler}
244 \definedescribecategory{optmac}{option macro}
245 \definedescribecategory{plug}{pluggable parser}
246 \def\nlret{\\\hspace{4em}\returns}
248 \@namedef{modcat/}#1{#1}
249 \@namedef{modlabel/}#1{#1}
250 \@namedef{modindex/}#1{#1@\noexpand\code{#1}}
252 \@namedef{modcat/setf}#1{\code{setf}-#1}
253 \@namedef{modlabel/setf}#1{setf/#1}
254 \@namedef{modindex/setf}#1{#1@\noexpand\code{#1}}
256 \@namedef{modcat/muffs}#1{#1}
257 \@namedef{modlabel/muffs}#1{*#1*}
258 \@namedef{modindex/muffs}#1{#1@\noexpand\code{*#1*}}
260 \@namedef{modcat/kwd}#1{#1}
261 \@namedef{modlabel/kwd}#1{:#1}
262 \@namedef{modindex/kwd}#1{#1@\noexpand\code{:#1}}
264 \@namedef{descargs/plain}#1{#1{}}
265 \@namedef{desclabel/plain}#1#2#3{#1:\@mod@dispatch{modlabel}{#2}{#3}}
266 \@namedef{descindex/plain}#1#2#3{%
267 \@mod@dispatch{modindex}{#2}{#3}!%
268 \protect\describecategoryname[#2]{#1}%
271 \@namedef{descargs/method}#1#2{#1{{#2}}}
272 \@namedef{desclabel/method}#1#2#3#4%
273 {#1:\@mod@dispatch{modlabel}{#2}{#3}(#4)}
274 \@namedef{descindex/method}#1#2#3#4{%
275 \@mod@dispatch{modindex}{#2}{#3}!%
276 \protect\describecategoryname[#2]{#1}%
277 \protect\fmtspecs{ specialized at }{#4}%
284 \if!#2!\else\count@\z@\toks@{}#1\@fmtspecs@i#2,\q@,\fi}
285 \def\@fmtspecs@i#1,{%
288 \ifcase\count@(no args?!)%
295 \ifnum\count@>\@ne, \fi%
297 \toks@{\code{#1}}\advance\count@\@ne%
298 \expandafter\@fmtspecs@i%
302 %% \parse@dhd{NEXT}[MOD]{CAT}{...}...[NAME]{SYNOPSIS}
303 %% call NEXT{MOD}{CAT}{{...}...}{NAME}{SYNOPSIS}
307 \def\parse@dhd#1{% {NEXT}
308 \@ifnextchar[{\parse@dhd@a{#1}}{\parse@dhd@c{#1}}}
309 \def\parse@dhd@a#1[#2]#3{% {NEXT}[MOD]{CAT}
310 \@desc@dispatch{descargs}{#3}{\parse@dhd@ab{#1}{#2}{#3}}}
311 \def\parse@dhd@ab#1#2#3#4{% {NEXT}{MOD}{CAT}{{...}...}
312 \@ifnextchar[{\parse@dhd@ac{#1}{#2}{#3}{#4}}{\parse@dhd@ad{#1}{#2}{#3}{#4}}}
313 \def\parse@dhd@ac#1#2#3#4[#5]#6{% {NEXT}{MOD}{CAT}{{...}...}[NAME]{SYNOPSIS}
314 #1{#2}{#3}{#4}{#5}{#6}}
315 \def\parse@dhd@ad#1#2#3#4#5{% {NEXT}{MOD}{CAT}{{...}...}{NAME [ARGS...]}
316 \parse@dhd@ae{#1}{#2}{#3}{#4}{#5}#5 \q@}
317 \def\parse@dhd@ae#1#2#3#4#5#6 #7\q@{%
318 % {NEXT}{MOD}{CAT}{{...}...}{SYNSOPSIS}NAME [ARGS...]\q@
319 #1{#2}{#3}{#4}{#6}{#5}}
321 \def\parse@dhd@c#1#2{% {NEXT}{CAT}
322 \@desc@dispatch{descargs}{#2}{\parse@dhd@cb{#1}{#2}}}
323 \def\parse@dhd@cb#1#2#3{% {NEXT}{CAT}{{...}...}
324 \@ifnextchar[{\parse@dhd@cc{#1}{#2}{#3}}{\parse@dhd@cd{#1}{#2}{#3}}}
325 \def\parse@dhd@cc#1#2#3[#4]#5{% {NEXT}{CAT}{{...}...}[NAME]{SYNOPSIS}
326 #1{}{#2}{#3}{#4}{#5}}
327 \def\parse@dhd@cd#1#2#3#4{% {NEXT}{CAT}{{...}...}{SYNOPSIS}
328 \parse@dhd@ce{#1}{#2}{#3}{#4}#4 \q@}
329 \def\parse@dhd@ce#1#2#3#4#5 #6\q@{%
330 % {NEXT}{CAT}{{...}...}{SYNOPSIS}NAME [ARGS...]\q@
332 \ifx\@setf\temp@\def\next@{\parse@dhd@csetf{#1}{#2}{#3}{#4}#6 \q@}%
333 \else\def\temp@##1##2*##3\q@{\def\temp@{##1##3}}\temp@#5*\q@%
334 \ifx\temp@\@starstar\def\next@{\parse@dhd@cmuffs{#1}{#2}{#3}{#4}#5}%
335 \else\def\temp@##1##2\q@{\def\temp@{##1}}\temp@#5\q@%
336 \if:\temp@\def\next@{\parse@dhd@ckwd{#1}{#2}{#3}{#4}#5\q@}%
337 \else\def\next@{#1{}{#2}{#3}{#5}{#4}}\fi\fi\fi%
340 \def\parse@dhd@csetf#1#2#3#4(#5 #6\q@{%
341 % {NEXT}{CAT}{{...}...}{SYNOPSIS}(NAME [ARGS...])\q@
342 #1{setf}{#2}{#3}{#5}{#4}}
343 \def\parse@dhd@cmuffs#1#2#3#4*#5*{%
344 % {NEXT}{CAT}{{...}...}{SYNOPSIS}*NAME*
345 #1{muffs}{#2}{#3}{#5}{#4}}
346 \def\parse@dhd@ckwd#1#2#3#4:#5\q@{%
347 % {NEXT}{CAT}{{...}...}{SYNOPSIS}:NAME\q@
348 #1{kwd}{#2}{#3}{#5}{#4}}
351 \def\dhead{\parse@dhd\dhead@}
352 \def\dhead@#1#2#3#4#5{% {MOD}{CAT}{{...}...}{NAME}{SYNOPSIS}
353 \if@dheadfirst\global\@dheadfirstfalse\else\relax\\*[\smallskipamount]\fi%
355 {\let\protect\@empty\let\@uscore\relax%
356 \edef\temp@{\@desc@dispatch{desclabel}{#2}{#2}{#1}{#4}#3}%
357 \def\@uscore{_\@gobble}\expandafter\message\expandafter{\temp@}%
358 \def\@uscore{-\@gobble}\expandafter\label\expandafter{\temp@}}%
359 {\begingroup\lccode`\~=`\_\lowercase{\endgroup\def~{_}}%
360 \protected@edef\@tempa##1{%
361 \noexpand\index{\@desc@dispatch{descindex}{#2}{#2}{#1}{#4}#3##1}}%
362 \toks@\expandafter{\@tempa{|)}}%
363 \toks\tw@\expandafter{\after@desc}%
364 \xdef\after@desc{\the\toks\tw@\the\toks@}%
366 \rlap{\hb@xt@\linewidth{\hfil\normalfont\bfseries
367 [\describecategoryname[#1]{#2}]}}%
372 \let\saved@after@desc\after@desc%
375 \if@nobreak\else\par\goodbreak\fi%
376 \global\@dheadfirsttrue%
378 \let\@endparenv\relax%
379 \clubpenalty\@M \widowpenalty\@M \interlinepenalty50%
382 \penalty\@M\@afterheading%
383 \list{}{\rightmargin\z@\topsep\z@}\item%
385 \def\desc@end{\endlist\after@desc\global\let\after@desc\saved@after@desc}
387 \@namedef{describe*}#1{\desc@begin{#1}}
388 \expandafter\let\csname enddescribe*\endcsname\desc@end
389 \def\describe{\parse@dhd\desc@}
390 \def\desc@#1#2#3#4#5{\desc@begin{\dhead@{#1}{#2}{#3}{#4}{#5}}}
391 \let\enddescribe\desc@end
393 \def\descref{\@ifstar%
394 {\descref@i{}\@gobble{}}%
395 {\descref@i{ (}{\noexpand\autopageref}{)}}}
396 \def\descref@i#1#2#3#4#5{\@ifnextchar@preserve[%
397 {\descref@ii{#1}{#2}{#3}{#4}{#5}}%
398 {\descref@iii{#1}{#2}{#3}{#4}{#5}{}}}
399 \def\descref@ii#1#2#3#4#5[#6]{\descref@iii{#1}{#2}{#3}{#4}{#5}{ #6}}
400 \def\descref@iii#1#2#3#4#5#6{%
403 \def\@uscore{-\@gobble}%
406 \noexpand\hyperref[#4:#5]%
410 \@tempa{{\code{#5}}#6#1}#3%
413 %%%----- That's all, folks --------------------------------------------------