Debian Codegraph @

texmf-dist/tex/latex/base/source2edoc.cls

raw
1
2 % This class is buggy and needs fixing
3
4 \ProvidesClass{source2edoc}
5 [2024/02/14 v0.2e Quick hack to typeset source2.tex
6 (not usable for anything else and buggy -- will vanish again)!]
7
8
9
10 \LoadClass[kernel]{l3doc}
11
12 \RemoveFromHook{begindocument}[l3doc] % drop the standard setting making " a shortverb
13 \AddToHook{begindocument}{\MakeShortVerb \|} % but readd | as one
14
15 %\ShowHook{begindocument}
16
17
18
19
20 \ExplSyntaxOn
21
22 % in 2e we have a lot of functions that have no ``user-level'' documentation so we disable
23 % a bogus backref in that case. Over time the sources should be cleaned up to have such documentation.
24
25 \cs_set_protected:Npn \__codedoc_print_documented:
26 {
27 \seq_gset_filter:NNn \g__codedoc_nested_names_seq
28 \g__codedoc_nested_names_seq
29 { ! \__codedoc_if_macro_internal_p:n {##1} }
30 \seq_if_empty:NF \g__codedoc_nested_names_seq
31 {
32 % This is a crude change: we grab the first name
33 \__codedoc_get_hyper_target:eN
34 { \seq_item:Nn \g__codedoc_nested_names_seq { 1 } }
35 \l__codedoc_tmpa_tl
36 % ... and check if it has a reference
37 \cs_if_exist:cT{ r@\l__codedoc_tmpa_tl }
38 % If it does we show it, if not we don't.
39 {
40 \int_set:Nn \l__codedoc_tmpa_int
41 { \seq_count:N \g__codedoc_nested_names_seq }
42 \int_compare:nNnTF \l__codedoc_tmpa_int = 1 {~This~} {~These~}
43 \bool_if:NTF \l__codedoc_macro_var_bool {variable} {function}
44 \int_compare:nNnTF \l__codedoc_tmpa_int = 1 {~is~} {s~are~}
45 documented~on~page~
46 \exp_args:Nx \pageref { \l__codedoc_tmpa_tl } .
47 }
48 }
49 \seq_gclear:N \g__codedoc_nested_names_seq
50 }
51
52
53 % change the setup here: we have a lot of long names so better run raggeded
54
55 \cs_set_protected:Npn \__codedoc_macro_end_style:n #1
56 {
57 \nobreak \noindent
58 { \raggedright\hangindent1pc \footnotesize ( \emph{#1} ) \par }
59 }
60
61
62 % next two declarations should move to l3doc.cls in the l3kernel eventually
63 % they should be ``new'' not ``set'' but to avoid getting in timing issues
64 % when they will be officially defined we use ``set'' here
65
66 \cs_set_eq:NN \__codedoc_saved_detect_internals:N \__codedoc_detect_internals:N
67
68 % maybe this change should be local so that it automatically reverts on \verb=\end{macro}=
69 % without the need to explicitly turn it on again.
70
71 \cs_new_protected:Npn \InternalDetectionOff
72 { \cs_gset_eq:NN \__codedoc_detect_internals:N \use_none:n }
73 \cs_new_protected:Npn \InternalDetectionOn
74 { \cs_gset_eq:NN \__codedoc_detect_internals:N \__codedoc_saved_detect_internals:N }
75
76 \ExplSyntaxOff
77
78 \def\partname{File}
79
80
81 \gdef\codeline@wrindex#1{\if@filesw
82 \begingroup
83 \let\protect\noexpand
84 \immediate\write\@indexfile
85 {\string\indexentry{#1}%
86 {\filesep\number\c@CodelineNo}}%
87 \endgroup\fi}
88 \let\filesep\@empty
89 \def\aalph#1{\@aalph{\csname c@#1\endcsname}}
90 \def\@aalph#1{%
91 \ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or
92 j\or k\or l\or m\or n\or o\or p\or q\or r\or s\or
93 t\or u\or v\or w\or x\or y\or z\or A\or B\or C\or
94 D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or
95 N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or
96 X\or Y\or Z\or
97 aa\or bb\or cc\or % we are getting definitely too many modules
98 dd%
99 \else\@ctrerr\fi}
100 \def\docincludeaux{%
101 \def\thepart{\ifnum\value{part}<10 0\fi\arabic{part}}\def\filesep{\thepart-}%
102 \let\filekey\@gobble
103 \g@addto@macro\index@prologue{%
104 \gdef\@oddfoot{\parbox[t]{\textwidth}{\strut\footnotesize
105 \raggedright{\bfseries File Key:} \filekey}}%
106 \let\@evenfoot\@oddfoot}%
107 \global\let\docincludeaux\relax
108 \gdef\@oddfoot{%
109 \expandafter\ifx\csname ver@\currentfile\endcsname\relax
110 File \thepart: {\ttfamily\currentfile} %
111 \else
112 \GetFileInfo{\currentfile}%
113 File \thepart: {\ttfamily\filename} %
114 Date: \filedate\ %
115 Version \fileversion
116 \fi
117 \hfill\thepage}%
118 \let\@evenfoot\@oddfoot}%
119 \def\MaintainedBy#1{\gdef\@maintainedby{#1}}
120 \let\@maintainedby\@empty
121 \def\MaintainedByLaTeXTeam#1{%
122 {\gdef\@maintainedby{%
123 This file is maintained by the \LaTeX{} Project team.\\%
124 Bug reports can be opened (category \texttt{#1}) at\\%
125 \url{https://latex-project.org/bugs.html}.}}}
126 \def\@maketitle{%
127 \newpage
128 \null
129 \vskip 2em%
130 \begin{center}%
131 \let \footnote \thanks
132 {\LARGE \@title \par}%
133 \vskip 1.5em%
134 {\large
135 \lineskip .5em%
136 \begin{tabular}[t]{c}%
137 \@author
138 \end{tabular}\par}%
139 \vskip 1em%
140 {\large \@date}%
141 \ifx\@maintainedby\@empty
142 \else
143 \vskip 1em%
144 \fbox{\fbox{\begin{tabular}{@{}l@{}}\@maintainedby\end{tabular}}}%
145 \fi
146 \end{center}%
147 \par
148 \vskip 1.5em}
149 \providecommand\url{\texttt}
150 \def\task#1#2{}
151
152
153 \def\oc@scan#1{%
154 \ifx\oc@bslash#1%
155 \egroup\let\next\oc@bslash\else
156 \ifcat a\noexpand#1%
157 #1\let\next\oc@scan\else
158 \ifx\oc@percent#1%
159 \def\next{\char`\%\egroup}%
160 \else
161 #1\let\next\egroup
162 \fi\fi\fi\next}
163 \def\oc@bslash{\bgroup\oc@ttf\char`\\\oc@scan}%
164 \def\oc@verb#1{%
165 \catcode`#1\active
166 \uccode`\~`#1%
167 \uppercase{\def~{{\oc@ttf\char`#1}}}}
168 \begingroup
169 \obeyspaces%
170 \catcode`\/=\catcode`\\
171 /catcode`/\/active
172 /catcode`<=/catcode`{%
173 /catcode`>=/catcode`}%
174 /catcode`/{/active%
175 /catcode`/}/active%
176 /gdef/oldc< \end{oldcomments}>%
177 /gdef/begmac< \begin{macrocode}>%
178 /gdef/obs</def <</oc@ttf/ >>>%
179 /endgroup%
180 \begingroup
181 \catcode`\/=\catcode`\\
182 \catcode`\\=13
183 /catcode`/|=/catcode`/%
184 /catcode`/%=13
185 /gdef/oldcomments{|
186 /makeatletter
187 /let/do/oc@verb/dospecials
188 /frenchspacing/@vobeyspaces/obs
189 /raggedright
190 /oc@verb/>|
191 /oc@verb/<|
192 /let\/oc@bslash
193 /let%/oc@percent
194 /obeylines
195 /parindent/z@
196 /ttfamily/expandafter/let/expandafter/oc@ttf/the/font
197 /rmfamily
198 /textit{Historical /LaTeX/,2.09 comments (not necessarily accurate any more):}
199 /hfuzz/maxdimen
200 }
201 /endgroup
202 \begingroup
203 \sloppy%
204 \obeylines%
205 \gdef\oc@percent#1^^M{%
206 \ifvmode%
207 \def\commentline{#1}%
208 \ifx\commentline\oldc%
209 \textit{End of historical \LaTeX\,2.09 comments.}
210 \end{oldcomments}%
211 \else%
212 \ifx\commentline\begmac%
213 \begin{macrocode}%
214 \else%
215 \leavevmode%
216 #1^^M%
217 \fi\fi%
218 \else%
219 {\oc@ttf\char`\%}#1^^M%
220 \fi}%
221 \endgroup%
222
223
224 % don't run tocs when they are in some module files
225 \AddToHook{cmd/tableofcontents/after}{\global\let\tableofcontents\relax}
226
227
228 % pages > 1000
229 \renewcommand\@pnumwidth{2em}
230
231 \InputIfFileExists{ltxdoc.cfg}
232 {\typeout{*************************************^^J%
233 * Local config file ltxdoc.cfg used^^J%
234 *************************************}}
235 {}
236
237
238
239 \errorstopmode
240 \batchmode
241
242 \endinput