author | Patrik Svestka <patrik.svestka@gmail.com> |
Wed, 17 Feb 2021 15:24:09 +0100 | |
branch | jv |
changeset 4568 | 524471ef6575 |
parent 4330 | 998eb03f0736 |
permissions | -rw-r--r-- |
601 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
4330 | 3 |
COPYRIGHT (c) 2015 Jan Vrany |
601 | 4 |
All Rights Reserved |
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
1400 | 13 |
"{ Package: 'stx:libbasic3' }" |
1138
aa7687ec256f
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
14 |
|
3797 | 15 |
"{ NameSpace: Smalltalk }" |
16 |
||
478 | 17 |
Object subclass:#HTMLDocGenerator |
1255 | 18 |
instanceVariableNames:'outStream pathToTopOfDocumentation |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
19 |
pathToLanguageTopOfDocumentation httpRequestOrNil |
2016 | 20 |
generateBodyOnly backRef backCmd imagePath refLines demoLines |
21 |
warnLines hintLines authorLines classProtocolCategories |
|
3643 | 22 |
instanceProtocolCategories generateJavaScriptCallInfo |
3999 | 23 |
generateDocumentForOfflineReading showUpButton' |
4106 | 24 |
classVariableNames:'CachedKWIC' |
478 | 25 |
poolDictionaries:'' |
26 |
category:'System-Documentation' |
|
27 |
! |
|
28 |
||
498 | 29 |
!HTMLDocGenerator class methodsFor:'documentation'! |
478 | 30 |
|
601 | 31 |
copyright |
32 |
" |
|
33 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
4330 | 34 |
COPYRIGHT (c) 2015 Jan Vrany |
601 | 35 |
All Rights Reserved |
36 |
||
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
||
45 |
||
46 |
! |
|
47 |
||
478 | 48 |
documentation |
49 |
" |
|
817 | 50 |
Generates HTML documentation for a class. |
4122 | 51 |
|
52 |
This is used with the SystemBrowser (classes-generate documentation menu), |
|
53 |
and the online documentation (which generates up-to-date documents just-in-time |
|
54 |
out of the running system). |
|
55 |
||
56 |
It may also be useful, to programatically generate up-to-date documents |
|
57 |
into a folder of self contained html files (eg. for deployment). |
|
817 | 58 |
|
59 |
This generator extracts the documentation methods source |
|
60 |
(or comment), individual method comments (the first comment in |
|
61 |
a method) and version information to generate a neatly formatted |
|
62 |
HTML page. |
|
63 |
If executable examples (EXBEGIN .. EXEND) are present in the classes |
|
64 |
documentation category these are also added as executable code |
|
65 |
to the document. |
|
478 | 66 |
|
3643 | 67 |
[instance variables:] |
68 |
outStream <WriteStream> internal |
|
69 |
pathToTopOfDocumentation <String> will be prepended to links. |
|
70 |
defaults to '../../doc' |
|
71 |
pathToLanguageTopOfDocumentation <String> defaults to '../../doc/online/<lang>' |
|
72 |
httpRequestOrNil internal |
|
73 |
generateBodyOnly internal |
|
74 |
backRef <URLString> if non-nil, the url for a back-button |
|
75 |
backCmd <String> if non-nil, the command for a back-button (for internal doc-browser only) |
|
76 |
imagePath <String> path to image documents |
|
77 |
refLines internal |
|
78 |
demoLines internal |
|
79 |
warnLines internal |
|
80 |
hintLines internal |
|
81 |
authorLines internal |
|
82 |
classProtocolCategories internal |
|
83 |
instanceProtocolCategories internal |
|
84 |
generateJavaScriptCallInfo <Boolean> if true, synopsis is shown in JavaScript syntax also |
|
85 |
generateDocumentForOfflineReading <Boolean> if true, document is generated with file links (instead of browser command links) |
|
86 |
for offline reading by an arbitrary browser. |
|
87 |
||
478 | 88 |
[author:] |
89 |
Claus Gittinger |
|
817 | 90 |
|
91 |
[see also:] |
|
92 |
BrowserView |
|
93 |
HTMLDocumentView |
|
478 | 94 |
" |
95 |
! ! |
|
96 |
||
498 | 97 |
!HTMLDocGenerator class methodsFor:'document generation'! |
478 | 98 |
|
3644 | 99 |
generateOfflineDocIn:aTopDirectory |
100 |
"generate a full tree of documents for offline reading. |
|
101 |
Similar to what is generated by the live-document generator, but |
|
102 |
all links are to static files. |
|
103 |
Tool for deployment." |
|
104 |
||
105 |
aTopDirectory recursiveMakeDirectory. |
|
106 |
(aTopDirectory / 'packages') recursiveMakeDirectory. |
|
107 |
(aTopDirectory / 'categories') recursiveMakeDirectory. |
|
108 |
||
109 |
(aTopDirectory / 'index.html') contents:(self htmlOfflineIndex). |
|
110 |
(aTopDirectory / 'packages/index.html') contents:(self htmlOfflinePackageList). |
|
111 |
(aTopDirectory / 'categories/index.html') contents:(self htmlOfflineClassCategoryList). |
|
112 |
"/ (aTopDirectory / 'classes/index.html') contents:(self htmlOfflineClassList). |
|
113 |
||
114 |
" |
|
115 |
self generateOfflineDocIn:'./offlineDoc' asFilename |
|
116 |
" |
|
117 |
! |
|
118 |
||
478 | 119 |
htmlClassCategoryList |
632 | 120 |
"generate a formatted list of all available class categories as |
121 |
an HTML string. Each category will be a hyperlink to another |
|
122 |
autogenerated page, containing the classes per category. |
|
123 |
The generated page is supposed to be given to an HTML reader |
|
124 |
with home being set to ../doc/online/xxx/classDoc |
|
125 |
(i.e. the images are to be found one-up in the doc hierarchy)" |
|
126 |
||
1249 | 127 |
^ self new htmlClassCategoryList |
128 |
||
129 |
" |
|
130 |
HTMLDocGenerator htmlClassCategoryList |
|
131 |
" |
|
132 |
! |
|
133 |
||
134 |
htmlClassListPrefix:prefix |
|
135 |
"generate an HTML document string which contains HREFS for a list |
|
136 |
of classes which start with some prefix (typically, the first |
|
137 |
character is given)" |
|
138 |
||
139 |
^ self new htmlClassListPrefix:prefix |
|
140 |
||
141 |
" |
|
142 |
HTMLDocGenerator htmlClassListPrefix:'A' |
|
143 |
" |
|
144 |
! |
|
145 |
||
1952
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
146 |
htmlClasses:classes title:title backTo:backRef |
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
147 |
"generate an HTML document string which contains HREFS for a given list |
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
148 |
of classes. If backref is nonNil, a back-button to that |
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
149 |
HREF is added at the top. |
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
150 |
The generated page is supposed to be given to an HTML reader |
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
151 |
with home being set to ../doc/online/xxx/classDoc |
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
152 |
(i.e. the images are to be found one-up in the doc hierarchy)" |
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
153 |
|
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
154 |
^ self new htmlClasses:classes title:title backTo:backRef |
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
155 |
! |
d4ce03b83795
Bug 85 - bad selectors when generating HTML docs
Stefan Vogel <sv@exept.de>
parents:
1923
diff
changeset
|
156 |
|
1249 | 157 |
htmlClassesListOfCategory:aCategory backTo:backMessage |
158 |
"generate an HTML document string which contains HREFS for a list |
|
159 |
of classes which are contained in a particular category." |
|
160 |
||
161 |
^ self new htmlClassesListOfCategory:aCategory backTo:backMessage |
|
162 |
! |
|
163 |
||
164 |
htmlDocOf:aClass |
|
165 |
"generate an HTML document string which contains a classes documentation" |
|
166 |
||
167 |
^ self new htmlDocOf:aClass |
|
168 |
||
169 |
" |
|
170 |
HTMLDocGenerator htmlDocOf:Array |
|
1973 | 171 |
HTMLDocumentView openFullOnText:(HTMLDocGenerator htmlDocOf:Array) |
1249 | 172 |
" |
1973 | 173 |
|
174 |
"Modified: / 05-11-2007 / 16:19:03 / cg" |
|
1249 | 175 |
! |
176 |
||
1253 | 177 |
htmlDocOf:aClass back:backCmd backRef:backRef imagePath:imagePath |
178 |
"generate a nice HTML page from a class, with a back-reference |
|
179 |
to a command or document." |
|
180 |
||
181 |
^ self new htmlDocOf:aClass back:backCmd backRef:backRef imagePath:imagePath |
|
182 |
! |
|
183 |
||
1289
c435b15b1415
oops - need ol protocol to be still there (for doc pages)
Claus Gittinger <cg@exept.de>
parents:
1280
diff
changeset
|
184 |
htmlDocOf:aClass backRef:backRef |
c435b15b1415
oops - need ol protocol to be still there (for doc pages)
Claus Gittinger <cg@exept.de>
parents:
1280
diff
changeset
|
185 |
"generate an HTML document string which contains a classes documentation" |
c435b15b1415
oops - need ol protocol to be still there (for doc pages)
Claus Gittinger <cg@exept.de>
parents:
1280
diff
changeset
|
186 |
|
c435b15b1415
oops - need ol protocol to be still there (for doc pages)
Claus Gittinger <cg@exept.de>
parents:
1280
diff
changeset
|
187 |
^ self new htmlDocOf:aClass backRef:backRef |
c435b15b1415
oops - need ol protocol to be still there (for doc pages)
Claus Gittinger <cg@exept.de>
parents:
1280
diff
changeset
|
188 |
! |
c435b15b1415
oops - need ol protocol to be still there (for doc pages)
Claus Gittinger <cg@exept.de>
parents:
1280
diff
changeset
|
189 |
|
1249 | 190 |
htmlDocOfImplementorsOf:selector |
191 |
"generate an HTML document string which contains HREFS |
|
192 |
to all implementors of a particular selector" |
|
193 |
||
194 |
^ self new htmlDocOfImplementorsOf:selector |
|
195 |
||
196 |
" |
|
197 |
HTMLDocGenerator htmlDocOfImplementorsOf:#at: |
|
198 |
" |
|
199 |
! |
|
200 |
||
1435 | 201 |
htmlDocOfImplementorsOfAnyMatching:selectorPattern |
202 |
"generate an HTML document string which contains HREFS |
|
203 |
to all implementors of a particular selector pattern" |
|
204 |
||
205 |
^ self new htmlDocOfImplementorsOfAnyMatching:selectorPattern |
|
206 |
||
207 |
" |
|
208 |
HTMLDocGenerator htmlDocOfImplementorsOfAnyMatching:'key*:x:y:' |
|
209 |
" |
|
210 |
! |
|
211 |
||
4106 | 212 |
htmlKWOCList |
213 |
" |
|
214 |
CachedKWIC := nil |
|
215 |
" |
|
216 |
CachedKWIC isNil ifTrue:[ |
|
4127 | 217 |
"/ CachedKWIC := self generateKWIC. |
218 |
CachedKWIC := self generateKWICForClassAndMethodNames. |
|
4106 | 219 |
"/ to flush the cached kwic, whenever a class-documentation method is changed |
220 |
Smalltalk addDependent:self class. |
|
221 |
]. |
|
222 |
^ self new htmlKWOCListFor:CachedKWIC |
|
223 |
||
224 |
" |
|
225 |
HTMLDocGenerator htmlKWOCList |
|
226 |
" |
|
227 |
! |
|
228 |
||
3644 | 229 |
htmlOfflineClassCategoryList |
230 |
"generate a formatted list of all available class categories as |
|
231 |
an HTML string. Each category will be a hyperlink to another |
|
232 |
autogenerated page, containing the classes per category. |
|
233 |
The generated page is supposed to be given to an HTML reader |
|
234 |
with home being set to ../doc/online/xxx/classDoc |
|
235 |
(i.e. the images are to be found one-up in the doc hierarchy)" |
|
236 |
||
237 |
^ self new |
|
238 |
generateDocumentForOfflineReading:true; |
|
239 |
htmlClassCategoryList |
|
240 |
||
241 |
" |
|
242 |
HTMLDocGenerator htmlOfflineClassCategoryList |
|
243 |
" |
|
244 |
! |
|
245 |
||
3643 | 246 |
htmlOfflineDocOf:aClass |
247 |
"generate an HTML document string which contains a class's documentation for offline reading. |
|
248 |
This is different in that it creates file links, instead of action links |
|
249 |
(action links only work with the builtin doc reader)." |
|
250 |
||
251 |
^ self new htmlOfflineDocOf:aClass |
|
252 |
||
253 |
" |
|
254 |
HTMLDocGenerator htmlDocOf:Array |
|
255 |
HTMLDocumentView openFullOnText:(HTMLDocGenerator htmlDocOf:Array) |
|
256 |
" |
|
257 |
||
258 |
"Modified: / 05-11-2007 / 16:19:03 / cg" |
|
259 |
! |
|
260 |
||
3644 | 261 |
htmlOfflineIndex |
262 |
^ '<html> |
|
263 |
<body> |
|
264 |
<ul> |
|
265 |
<li><A HREF="packages/index.html">By Package</A> |
|
266 |
<li><A HREF="categories/index.html">By Category</A> |
|
267 |
<li><A HREF="classes/index.html">By Class Name</A> |
|
268 |
</ul> |
|
269 |
</body> |
|
270 |
</html> |
|
271 |
' |
|
272 |
! |
|
273 |
||
274 |
htmlOfflinePackageList |
|
275 |
"generate an HTML string for all packages in the system" |
|
276 |
||
277 |
^ self new |
|
278 |
generateDocumentForOfflineReading:true; |
|
279 |
htmlPackageList |
|
280 |
||
281 |
" |
|
282 |
HTMLDocGenerator htmlOfflinePackageList |
|
283 |
" |
|
284 |
! |
|
285 |
||
2017 | 286 |
htmlPackageDocOf:packageID |
287 |
"generate an HTML document string which contains a packages classlist" |
|
288 |
||
289 |
^ self new htmlPackageDocOf:packageID |
|
290 |
||
291 |
" |
|
292 |
HTMLDocGenerator htmlPackageDocOf:#'stx:libbasic' |
|
293 |
HTMLDocumentView openFullOnText:(HTMLDocGenerator htmlPackageDocOf:#'stx:libbasic') |
|
294 |
" |
|
295 |
! |
|
296 |
||
2018 | 297 |
htmlPackageList |
298 |
"generate an HTML string for all packages in the system" |
|
299 |
||
300 |
^ self new htmlPackageList |
|
301 |
||
302 |
" |
|
303 |
HTMLDocGenerator htmlPackageList |
|
304 |
" |
|
305 |
! |
|
306 |
||
1249 | 307 |
htmlSelectorList |
308 |
"generate an HTML string for all selectors (for which methods exist) |
|
309 |
in the system" |
|
310 |
||
311 |
^ self new htmlSelectorList |
|
312 |
||
313 |
" |
|
314 |
HTMLDocGenerator htmlSelectorList |
|
315 |
" |
|
316 |
! |
|
317 |
||
318 |
htmlSelectorListMatching:prefix |
|
319 |
"generate an HTML string for all selectors which match a pattern |
|
320 |
(and for which methods exist) in the system" |
|
321 |
||
322 |
^ self new htmlSelectorListMatching:prefix |
|
323 |
! |
|
324 |
||
325 |
htmlSelectorListPrefix:prefix |
|
326 |
"generate an HTML string for all selectors whose names starts with |
|
327 |
a prefix (and for which methods exist) in the system" |
|
328 |
||
329 |
^ self new htmlSelectorListPrefix:prefix |
|
330 |
||
331 |
" |
|
332 |
HTMLDocGenerator htmlSelectorListPrefix:'a' |
|
333 |
" |
|
334 |
! |
|
335 |
||
336 |
manPageFor:aCommandName |
|
337 |
"generate a (unix-) man page for a given command & convert the output to html" |
|
338 |
||
339 |
^ self new manPageFor:aCommandName |
|
340 |
||
341 |
" |
|
342 |
HTMLDocGenerator manPageFor:'ls' |
|
343 |
||
344 |
HTMLDocumentView openFullOnText:(HTMLDocGenerator manPageFor:'ls') |
|
345 |
" |
|
346 |
! |
|
347 |
||
348 |
manPageFor:aManPageTemplateFile manCommand:nroffCommand |
|
349 |
"convert man-command output to html. |
|
350 |
Only the body of the text (without head../head and body../body) is generated" |
|
351 |
||
352 |
^ self new manPageFor:aManPageTemplateFile manCommand:nroffCommand |
|
353 |
||
354 |
" |
|
355 |
HTMLDocGenerator |
|
356 |
manPageForFile:'/usr/man/man2/open.2' |
|
357 |
manCommand:'nroff -man /usr/man/man2/open.2' |
|
358 |
" |
|
359 |
! |
|
360 |
||
361 |
manPageForFile:aManPageTemplateFile |
|
362 |
"convert a .man file to html" |
|
363 |
||
364 |
^ self new manPageForFile:aManPageTemplateFile |
|
365 |
||
366 |
" |
|
367 |
HTMLDocGenerator manPageForFile:'/usr/man/man2/open.2' |
|
368 |
||
369 |
HTMLDocumentView openFullOnText:(HTMLDocGenerator manPageForFile:'../../stc/stc.1') |
|
370 |
" |
|
371 |
! ! |
|
372 |
||
3625 | 373 |
!HTMLDocGenerator class methodsFor:'document generation-helpers'! |
374 |
||
4127 | 375 |
camelCaseSeparatedWordsOf:wordIn do:aBlock |
376 |
" |
|
377 |
self camelCaseSeparatedWordsOf:'HelloWorld' do:[:w | Transcript showCR:w] |
|
378 |
self camelCaseSeparatedWordsOf:'abcDef' do:[:w | Transcript showCR:w] |
|
379 |
self camelCaseSeparatedWordsOf:'UTFEncoder' do:[:w | Transcript showCR:w] |
|
380 |
self camelCaseSeparatedWordsOf:'JisEncoder' do:[:w | Transcript showCR:w] |
|
381 |
self camelCaseSeparatedWordsOf:'JISEncode' do:[:w | Transcript showCR:w] |
|
382 |
" |
|
383 |
|state newState in out ch part| |
|
384 |
||
385 |
in := wordIn readStream. |
|
386 |
out := '' writeStream. |
|
387 |
[in atEnd] whileFalse:[ |
|
388 |
ch := in next. |
|
389 |
(ch isDigit or:[ch == $_]) ifFalse:[ |
|
390 |
newState := ch isUppercase. |
|
391 |
]. |
|
392 |
(newState ~~ state) ifTrue:[ |
|
393 |
newState == true ifTrue:[ |
|
394 |
"/ going from lower- to uppercase |
|
395 |
part := out contents. |
|
396 |
part notEmpty ifTrue:[ aBlock value:part ]. |
|
397 |
out := '' writeStream. |
|
398 |
out nextPut:ch. |
|
399 |
state := newState. |
|
400 |
] ifFalse:[ |
|
401 |
"/ going upper- to lowercase |
|
402 |
out size <= 1 ifTrue:[ |
|
403 |
out nextPut:ch. |
|
404 |
] ifFalse:[ |
|
405 |
|prev| |
|
406 |
||
407 |
prev := out contents. |
|
408 |
aBlock value:(prev copyButLast). |
|
409 |
out := '' writeStream. |
|
410 |
out nextPut:prev last. |
|
411 |
out nextPut:ch. |
|
412 |
]. |
|
413 |
state := newState. |
|
414 |
]. |
|
415 |
] ifFalse:[ |
|
416 |
out nextPut:ch. |
|
417 |
]. |
|
418 |
]. |
|
419 |
part := out contents. |
|
420 |
part notEmpty ifTrue:[ aBlock value:part ]. |
|
421 |
! |
|
422 |
||
4106 | 423 |
generateKWIC |
424 |
|fillWords kwic| |
|
425 |
||
426 |
fillWords := |
|
427 |
#( |
|
428 |
'the' 'a' |
|
429 |
'can' 'you' |
|
4125 | 430 |
'to' 'in' 'out' 'at' 'of' |
4110 | 431 |
'also' 'with' 'without' 'all' 'any' 'how' |
4123 | 432 |
'however' 'although' 'always' 'either' 'neither' |
4110 | 433 |
'anywhere' 'anyway' 'anything' 'anyone' |
4123 | 434 |
'not' 'but' 'else' 'elsewhere' |
4106 | 435 |
'am' 'are' 'is' 'be' 'will' 'wont' 'won''t' 'do' 'don''t' |
4125 | 436 |
'no' 'non' 'now' 'old' 'on' 'only' |
4106 | 437 |
'my' 'their' 'your' 'its' |
438 |
'one' 'two' 'three' |
|
4125 | 439 |
'etc' 'for' 'lot' 'lots' 'made' 'may' 'most' 'mostly' 'much' |
4106 | 440 |
'use' 'this' 'that' 'which' 'what' 'why' |
4125 | 441 |
'or' 'other' 'please' |
4106 | 442 |
). |
443 |
||
444 |
kwic := KeywordInContextIndexBuilder new. |
|
445 |
kwic excluded:fillWords. |
|
4127 | 446 |
kwic separatorAlgorithm:[:line | |
447 |
line asCollectionOfSubstringsSeparatedByAny:' ^~=@.:,;-+*/()[]|{}#"''<>',Character cr |
|
448 |
]. |
|
4106 | 449 |
kwic exclusionFilter:[:word | |
450 |
word size == 1 |
|
451 |
or:[ word conform:#isDigit ]]. |
|
4122 | 452 |
|
4106 | 453 |
Smalltalk allClassesDo:[:eachClass | |
4126 | 454 |
eachClass isLoaded ifTrue:[ |
455 |
|doc| |
|
456 |
||
457 |
doc := eachClass commentOrDocumentationString. |
|
458 |
doc notEmptyOrNil ifTrue:[ |
|
459 |
kwic addLine:doc reference:eachClass ignoreCase:true. |
|
460 |
]. |
|
461 |
]. |
|
4106 | 462 |
]. |
4122 | 463 |
|
4123 | 464 |
"/ if we have a key like 'startWith:' in the list, |
465 |
"/ and 'starts' is also there, place the 'startsWith:' entries into the same bin. |
|
4122 | 466 |
kwic remapKeywordsWith:[:oldKey :knownMappings | |
467 |
|newKey| |
|
468 |
||
4125 | 469 |
6 to:oldKey size - 1 do:[:len | |
4122 | 470 |
newKey isNil ifTrue:[ |
4123 | 471 |
|part| |
472 |
||
473 |
part := (oldKey copyTo:len). |
|
474 |
(knownMappings includes:part) ifTrue:[ |
|
475 |
newKey := part. |
|
4122 | 476 |
]. |
477 |
]. |
|
478 |
]. |
|
479 |
newKey ? oldKey. |
|
480 |
]. |
|
481 |
||
4106 | 482 |
^ kwic |
483 |
||
484 |
" |
|
4122 | 485 |
CachedKWIC := nil. |
4106 | 486 |
self generateKWIC |
487 |
" |
|
488 |
! |
|
489 |
||
4127 | 490 |
generateKWICForClassAndMethodNames |
491 |
|fillWords kwic| |
|
492 |
||
493 |
fillWords := |
|
494 |
#( |
|
495 |
"/ 'the' 'a' |
|
496 |
"/ 'can' 'you' |
|
497 |
"/ 'to' 'in' 'out' 'at' 'of' |
|
498 |
"/ 'also' 'with' 'without' 'all' 'any' 'how' |
|
499 |
"/ 'however' 'although' 'always' 'either' 'neither' |
|
500 |
"/ 'anywhere' 'anyway' 'anything' 'anyone' |
|
501 |
"/ 'not' 'but' 'else' 'elsewhere' |
|
502 |
"/ 'am' 'are' 'is' 'be' 'will' 'wont' 'won''t' 'do' 'don''t' |
|
503 |
"/ 'no' 'non' 'now' 'old' 'on' 'only' |
|
504 |
"/ 'my' 'their' 'your' 'its' |
|
505 |
"/ 'one' 'two' 'three' |
|
506 |
"/ 'etc' 'for' 'lot' 'lots' 'made' 'may' 'most' 'mostly' 'much' |
|
507 |
"/ 'use' 'this' 'that' 'which' 'what' 'why' |
|
508 |
"/ 'or' 'other' 'please' |
|
509 |
). |
|
510 |
||
511 |
kwic := KeywordInContextIndexBuilder new. |
|
512 |
kwic excluded:fillWords. |
|
513 |
kwic separatorAlgorithm:[:name | |
|
514 |
|words| |
|
515 |
words := Set new. |
|
516 |
(name asCollectionOfSubstringsSeparatedBy:$:) do:[:eachPart | |
|
517 |
eachPart notEmpty ifTrue:[ |
|
518 |
self camelCaseSeparatedWordsOf:eachPart do:[:w | words add:w]. |
|
519 |
]. |
|
520 |
]. |
|
521 |
words := words reject:[:w | w isEmpty]. |
|
522 |
words |
|
523 |
]. |
|
524 |
||
525 |
Smalltalk allClassesDo:[:eachClass | |
|
526 |
kwic addLine:eachClass name reference:eachClass ignoreCase:true. |
|
527 |
"/ eachClass isLoaded ifTrue:[ |
|
528 |
"/ eachClass theNonMetaclass selectorsAndMethodsDo:[:sel :mthd | |
|
529 |
"/ kwic addLine:sel reference:mthd ignoreCase:true. |
|
530 |
"/ ]. |
|
531 |
"/ eachClass theMetaclass selectorsAndMethodsDo:[:sel :mthd| |
|
532 |
"/ kwic addLine:sel reference:mthd ignoreCase:true. |
|
533 |
"/ ]. |
|
534 |
"/ ]. |
|
535 |
]. |
|
536 |
^ kwic |
|
537 |
||
538 |
" |
|
539 |
CachedKWIC := nil. |
|
540 |
self generateKWICForClassAndMethodNames |
|
541 |
" |
|
542 |
! |
|
543 |
||
3625 | 544 |
htmlForMethod:aMethod |
545 |
|who sel partStream args argStream methodSpecLine| |
|
546 |
||
547 |
who := aMethod who. |
|
548 |
sel := who methodSelector. |
|
549 |
||
550 |
partStream := sel keywords readStream. |
|
551 |
||
552 |
(args := aMethod methodArgNames) notNil ifTrue:[ |
|
553 |
argStream := args readStream. |
|
554 |
||
555 |
methodSpecLine := ''. |
|
556 |
1 to:sel numArgs do:[:index | |
|
557 |
methodSpecLine size > 0 ifTrue:[ |
|
558 |
methodSpecLine := methodSpecLine , ' ' |
|
559 |
]. |
|
560 |
methodSpecLine := methodSpecLine , '<B>' , partStream next , '</B>'. |
|
561 |
methodSpecLine := methodSpecLine , ' <I>' , argStream next , '</I>'. |
|
562 |
]. |
|
563 |
] ifFalse:[ |
|
564 |
methodSpecLine := '<B>' , partStream next , '</B>' |
|
565 |
]. |
|
566 |
^ methodSpecLine |
|
567 |
||
568 |
"Created: / 05-11-2007 / 16:13:39 / cg" |
|
569 |
! ! |
|
570 |
||
1255 | 571 |
!HTMLDocGenerator class methodsFor:'pathnames'! |
572 |
||
1993
68da9e3a68e9
make accessors for doc-directory and language-directories
Claus Gittinger <cg@exept.de>
parents:
1979
diff
changeset
|
573 |
findPathToTopOfDocumentation |
3999 | 574 |
|triedDirs| |
575 |
||
576 |
triedDirs := OrderedCollection new. |
|
4001 | 577 |
triedDirs add:(Smalltalk packageDirectory directory pathName). |
3999 | 578 |
triedDirs addAll: |
579 |
#( |
|
580 |
'../../doc/online' |
|
581 |
'doc/online' |
|
582 |
'/opt/stx/doc/online' |
|
583 |
). |
|
584 |
triedDirs do:[:eachPathToTry | |
|
1993
68da9e3a68e9
make accessors for doc-directory and language-directories
Claus Gittinger <cg@exept.de>
parents:
1979
diff
changeset
|
585 |
(eachPathToTry asFilename exists |
68da9e3a68e9
make accessors for doc-directory and language-directories
Claus Gittinger <cg@exept.de>
parents:
1979
diff
changeset
|
586 |
and:[eachPathToTry asFilename isDirectory]) |
68da9e3a68e9
make accessors for doc-directory and language-directories
Claus Gittinger <cg@exept.de>
parents:
1979
diff
changeset
|
587 |
ifTrue:[ |
68da9e3a68e9
make accessors for doc-directory and language-directories
Claus Gittinger <cg@exept.de>
parents:
1979
diff
changeset
|
588 |
^ eachPathToTry |
68da9e3a68e9
make accessors for doc-directory and language-directories
Claus Gittinger <cg@exept.de>
parents:
1979
diff
changeset
|
589 |
] |
68da9e3a68e9
make accessors for doc-directory and language-directories
Claus Gittinger <cg@exept.de>
parents:
1979
diff
changeset
|
590 |
]. |
68da9e3a68e9
make accessors for doc-directory and language-directories
Claus Gittinger <cg@exept.de>
parents:
1979
diff
changeset
|
591 |
^ '.' |
3999 | 592 |
|
593 |
" |
|
594 |
self findPathToTopOfDocumentation |
|
595 |
" |
|
1993
68da9e3a68e9
make accessors for doc-directory and language-directories
Claus Gittinger <cg@exept.de>
parents:
1979
diff
changeset
|
596 |
! |
68da9e3a68e9
make accessors for doc-directory and language-directories
Claus Gittinger <cg@exept.de>
parents:
1979
diff
changeset
|
597 |
|
1255 | 598 |
languageSpecificDocDirectory |
599 |
|lang| |
|
600 |
||
2178
af7b05dfeaae
changed: #languageSpecificDocDirectory
Claus Gittinger <cg@exept.de>
parents:
2055
diff
changeset
|
601 |
lang := UserPreferences current language. |
1255 | 602 |
|
603 |
"XXX Kludge for now, map ISO-639 abbreviations to dir names. |
|
604 |
Should rename the directories" |
|
605 |
||
606 |
lang == #en ifTrue:[ |
|
607 |
^ 'english'. |
|
608 |
]. |
|
609 |
lang == #de ifTrue:[ |
|
610 |
^ 'german'. |
|
611 |
]. |
|
612 |
lang == #fr ifTrue:[ |
|
613 |
^ 'french'. |
|
614 |
]. |
|
615 |
lang == #it ifTrue:[ |
|
616 |
^ 'italian'. |
|
617 |
]. |
|
3643 | 618 |
"/ lang == #es ifTrue:[ |
619 |
"/ ^ 'spanish'. |
|
620 |
"/ ]. |
|
1255 | 621 |
lang == #jp ifTrue:[ |
622 |
^ 'japanese'. |
|
623 |
]. |
|
624 |
^ 'english'. |
|
625 |
||
626 |
" |
|
627 |
self languageSpecificDocDirectory |
|
628 |
" |
|
629 |
! ! |
|
630 |
||
631 |
!HTMLDocGenerator methodsFor:'accessing'! |
|
632 |
||
3643 | 633 |
generateBodyOnly:aBoolean |
634 |
generateBodyOnly := aBoolean. |
|
635 |
! |
|
636 |
||
637 |
generateDocumentForOfflineReading |
|
638 |
^ generateDocumentForOfflineReading ? false |
|
639 |
! |
|
640 |
||
641 |
generateDocumentForOfflineReading:aBoolean |
|
642 |
generateDocumentForOfflineReading := aBoolean. |
|
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
643 |
! |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
644 |
|
3625 | 645 |
generateJavaScriptCallInfo |
646 |
^ generateJavaScriptCallInfo ? false |
|
647 |
! |
|
648 |
||
649 |
generateJavaScriptCallInfo:aBoolean |
|
650 |
generateJavaScriptCallInfo := aBoolean. |
|
651 |
! |
|
652 |
||
1257
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
653 |
httpRequest:aRequest |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
654 |
httpRequestOrNil := aRequest. |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
655 |
! |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
656 |
|
1255 | 657 |
pathToLanguageTopOfDocumentation:something |
658 |
pathToLanguageTopOfDocumentation := something. |
|
659 |
! |
|
660 |
||
661 |
pathToTopOfDocumentation:something |
|
662 |
pathToTopOfDocumentation := something. |
|
3999 | 663 |
! |
664 |
||
665 |
showUpButton |
|
666 |
^ showUpButton ? true |
|
667 |
! |
|
668 |
||
669 |
showUpButton:aBoolean |
|
670 |
showUpButton := aBoolean |
|
1255 | 671 |
! ! |
672 |
||
1249 | 673 |
!HTMLDocGenerator methodsFor:'document generation'! |
674 |
||
2016 | 675 |
generateClassInfoForClass:aClass |
2017 | 676 |
|owner packageID| |
2016 | 677 |
|
678 |
owner := aClass owningClass. |
|
2017 | 679 |
packageID := aClass package. |
2016 | 680 |
|
681 |
outStream nextPutLine:'<dl>'. |
|
682 |
outStream nextPutLine:'<dt><a name="PACKAGE"><b>Package:</b></A>'. |
|
2017 | 683 |
outStream nextPutAll:'<dd><b>'. |
684 |
self generatePackageDocReferenceFor:packageID text:packageID. |
|
685 |
"/ outStream nextPutAll:packageID. |
|
686 |
outStream nextPutLine:'</b>'. |
|
2016 | 687 |
outStream nextPutLine:'</dl>'. |
688 |
||
689 |
||
690 |
aClass category notNil ifTrue:[ |
|
691 |
outStream nextPutLine:'<dl>'. |
|
692 |
outStream nextPutLine:'<dt><a name="CATEGORY"><b>Category:</b></A>'. |
|
693 |
outStream nextPutLine:'<dd><b>', aClass category , '</b>'. |
|
694 |
outStream nextPutLine:'</dl>'. |
|
695 |
]. |
|
696 |
||
697 |
owner notNil ifTrue:[ |
|
698 |
outStream nextPutLine:'<dl>'. |
|
699 |
outStream nextPutLine:'<dt><a name="OWNER"><b>Owner:</b></A>'. |
|
700 |
outStream nextPutAll:'<dd><b>'. |
|
701 |
self generateClassDocReferenceFor:owner name. |
|
702 |
outStream cr. |
|
703 |
"/ outStream nextPutLine:(self |
|
704 |
"/ anchorForHTMLDocAction: |
|
705 |
"/ ('htmlDocOf:', owner name ) |
|
706 |
"/ info: |
|
707 |
"/ ( 'Show documentation of ' , owner nameWithoutPrefix ) |
|
708 |
"/ text: |
|
709 |
"/ owner nameWithoutPrefix). |
|
710 |
outStream nextPutLine:'</b>'. |
|
711 |
] ifFalse:[ |
|
712 |
self htmlRevisionDocOf:aClass to:outStream. |
|
713 |
]. |
|
714 |
outStream nextPutLine:'</dl>'. |
|
715 |
||
716 |
authorLines notNil ifTrue:[ |
|
717 |
outStream nextPutLine:'<dl><dt><a name="AUTHOR"><b>Author:</b></A>'. |
|
718 |
authorLines do:[:l| |
|
719 |
outStream nextPutLine:'<dd><b>', l , '</b>'. |
|
720 |
]. |
|
721 |
outStream nextPutLine:'</dl>'. |
|
722 |
]. |
|
723 |
! |
|
724 |
||
725 |
generateClassProtocolDocumentationForClass:aClass |
|
726 |
|metaClass shortMetaName| |
|
727 |
||
728 |
classProtocolCategories notEmpty ifTrue:[ |
|
729 |
metaClass := aClass class. |
|
730 |
shortMetaName := metaClass nameWithoutPrefix. |
|
731 |
||
732 |
outStream nextPutLine:'<li><a href="#CLASSPROTOCOL" name="I_CLASSPROTOCOL">Class protocol</a>'. |
|
733 |
outStream nextPutLine:'<ul>'. |
|
734 |
classProtocolCategories do:[:cat | |
|
735 |
outStream nextPutLine:'<li><a name="I_' , shortMetaName , '_category_' , cat , '"' , |
|
736 |
' href="#' , shortMetaName , '_category_' , cat , |
|
737 |
'">' , cat , '</a> '. |
|
738 |
]. |
|
739 |
outStream nextPutLine:'</ul>'. |
|
740 |
]. |
|
741 |
! |
|
742 |
||
743 |
generateDemo |
|
744 |
outStream nextPutLine:'<h2><a name="DEMOSTARTUP" href="#I_DEMOSTARTUP">Demonstration:</A></h2>'. |
|
745 |
demoLines do:[:l | |
|
746 |
outStream nextPutLine:'<a INFO="demonstration" type="example">'. |
|
747 |
outStream nextPutLine:'<pre><code>'. |
|
748 |
outStream nextPutLine:' ' , l withoutSeparators. |
|
749 |
outStream nextPutLine:'</code></pre>'. |
|
750 |
outStream nextPutLine:'</a>'. |
|
751 |
outStream nextPutLine:'<br>'. |
|
752 |
]. |
|
753 |
! |
|
754 |
||
755 |
generateDescription:docu |
|
756 |
docu notNil ifTrue:[ |
|
757 |
outStream nextPutLine:'<h2><a name="DESCRIPTION" href="#I_DESCRIPTION">Description:</A></h2>'. |
|
758 |
outStream nextPutLine:'<BR>'. |
|
759 |
||
760 |
outStream nextPutLine:'<pre>'. |
|
761 |
outStream nextPutLine:docu. |
|
762 |
outStream nextPutLine:'</pre>'. |
|
763 |
self generateHorizontalLine. |
|
764 |
]. |
|
765 |
! |
|
766 |
||
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
767 |
generateExampleEnd |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
768 |
outStream nextPutLine:'</code></pre>'. |
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
769 |
self generatingForSTXBrowser ifTrue:[ |
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
770 |
outStream nextPutLine:'</a>'. |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
771 |
]. |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
772 |
outStream nextPutLine:'</td></tr></table>'. |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
773 |
! |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
774 |
|
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
775 |
generateExampleStart |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
776 |
outStream nextPutLine:'<p></p><table width="100%" bgcolor="#eedddd"><tr><td>'. |
1343 | 777 |
self generatingForSTXBrowser ifTrue:[ |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
778 |
outStream nextPutLine:'<a info="execute the example" type="example" showresult>'. |
1343 | 779 |
]. |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
780 |
outStream nextPutLine:'<pre><code>'. |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
781 |
! |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
782 |
|
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
783 |
generateExamples:examples |
3625 | 784 |
"everything between exBegin and exEnd is shown as code example; |
785 |
the remaining text is shown as regular text (commenting the code, I hope)" |
|
786 |
||
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
787 |
|inExample| |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
788 |
|
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
789 |
inExample := false. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
790 |
outStream nextPutLine:'<h2><a name="EXAMPLES" href="#I_EXAMPLES">Examples:</A></h2>'. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
791 |
outStream nextPutLine:'<BR>'. |
1343 | 792 |
|
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
793 |
examples do:[:line | |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
794 |
line withoutSeparators = '[exBegin]' ifTrue:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
795 |
inExample ifTrue:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
796 |
self generateExampleEnd. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
797 |
]. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
798 |
self generateExampleStart. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
799 |
inExample := true. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
800 |
] ifFalse:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
801 |
line withoutSeparators = '[exEnd]' ifTrue:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
802 |
inExample ifTrue:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
803 |
self generateExampleEnd. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
804 |
]. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
805 |
inExample := false. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
806 |
] ifFalse:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
807 |
outStream nextPutLine:line |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
808 |
] |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
809 |
]. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
810 |
]. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
811 |
inExample ifTrue:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
812 |
self generateExampleEnd. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
813 |
]. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
814 |
self generateHorizontalLine. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
815 |
! |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
816 |
|
2016 | 817 |
generateInheritanceTreeForClass:aClass |
818 |
|indent first supers subs| |
|
819 |
||
820 |
supers := aClass allSuperclasses. |
|
821 |
(aClass == Autoload or:[aClass == Object]) ifTrue:[ |
|
822 |
subs := #() |
|
823 |
] ifFalse:[ |
|
824 |
subs := self shownSubclassesOf:aClass. |
|
825 |
]. |
|
826 |
||
827 |
outStream nextPutLine:'<h2><a name="INHERITANCE" href="#I_INHERITANCE">Inheritance:</A></h2>'. |
|
828 |
outStream nextPutLine:'<pre>'. |
|
829 |
indent := 3. |
|
830 |
first := true. |
|
831 |
(supers size > 0) ifTrue:[ |
|
832 |
supers reverseDo:[:cls | |
|
833 |
|className| |
|
834 |
||
835 |
className := cls name. |
|
836 |
first ifFalse:[ |
|
837 |
outStream spaces:indent; nextPutLine:'|'. |
|
838 |
outStream spaces:indent; nextPutAll:'+--'. |
|
839 |
indent := indent + 3. |
|
840 |
] ifTrue:[ |
|
841 |
outStream spaces:indent |
|
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
842 |
]. |
2016 | 843 |
first := false. |
844 |
||
845 |
self generateClassDocReferenceFor:className. |
|
846 |
outStream cr. |
|
847 |
]. |
|
848 |
outStream spaces:indent; nextPutLine:'|'. |
|
849 |
outStream spaces:indent. |
|
850 |
outStream nextPutAll:'+--<B>'; nextPutAll:aClass name; nextPutLine:'</B>'. |
|
851 |
indent := indent + 3. |
|
852 |
] ifFalse:[ |
|
853 |
outStream spaces:indent; nextPutLine:'nil'. |
|
854 |
outStream spaces:indent; nextPutLine:'|'. |
|
855 |
outStream spaces:indent; nextPutAll:'+--<B>'; nextPutAll:aClass name; nextPutLine:'</B>'. |
|
856 |
aClass ~~ Object ifTrue:[ |
|
857 |
outStream cr. |
|
858 |
outStream nextPutLine:' <B>This class inherits NOTHING - most messages will lead into doesNotUnderstand:</B>' |
|
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
859 |
]. |
2016 | 860 |
indent := indent + 3. |
861 |
]. |
|
862 |
||
863 |
subs notEmpty ifTrue:[ |
|
864 |
subs do:[:aSubclass | |
|
865 |
|className| |
|
866 |
||
867 |
className := aSubclass name. |
|
868 |
outStream spaces:indent; nextPutLine:'|'. |
|
869 |
outStream spaces:indent; nextPutAll:'+--'. |
|
870 |
self generateClassDocReferenceFor:className. |
|
871 |
outStream cr. |
|
872 |
] |
|
873 |
] ifFalse:[ |
|
874 |
aClass == Object ifTrue:[ |
|
875 |
outStream spaces:indent; nextPutLine:'|'. |
|
876 |
outStream spaces:indent; nextPutLine:'+-- ... almost every other class ...' |
|
877 |
] |
|
878 |
]. |
|
879 |
||
880 |
outStream nextPutLine:'</pre>'. |
|
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
881 |
! |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
882 |
|
2016 | 883 |
generateInstanceProtocolDocumentationForClass:aClass |
884 |
|shortName| |
|
885 |
||
886 |
shortName := aClass nameWithoutPrefix. |
|
887 |
instanceProtocolCategories notEmpty ifTrue:[ |
|
888 |
outStream nextPutLine:'<li><a href="#INSTANCEPROTOCOL" name="I_INSTANCEPROTOCOL">Instance protocol</a>'. |
|
889 |
outStream nextPutLine:'<ul>'. |
|
890 |
instanceProtocolCategories do:[:cat | |
|
891 |
outStream nextPutLine:'<li><a name="I_' , shortName , '_category_' , cat , '"' , |
|
892 |
' href="#' , shortName , '_category_' , cat , |
|
893 |
'">' , cat , '</a> '. |
|
894 |
]. |
|
895 |
outStream nextPutLine:'</ul>'. |
|
896 |
]. |
|
897 |
! |
|
898 |
||
899 |
generatePrivateClassInfoForClass:aClass withPrivateClasses:privateClasses |
|
900 |
outStream nextPutLine:'<pre>'. |
|
901 |
privateClasses do:[:cls | |
|
902 |
|nm fullName| |
|
903 |
||
904 |
nm := cls nameWithoutPrefix. |
|
905 |
fullName := cls name. |
|
906 |
outStream nextPutAll:' '. |
|
907 |
(cls owningClass isLoaded not |
|
908 |
or:[cls owningClass wasAutoloaded]) ifTrue:[ |
|
909 |
self |
|
910 |
generateClassDocReferenceFor:fullName |
|
911 |
text:nm |
|
912 |
autoloading:(cls owningClass name) |
|
913 |
] ifFalse:[ |
|
914 |
self |
|
915 |
generateClassDocReferenceFor:fullName |
|
916 |
text:nm. |
|
917 |
]. |
|
918 |
outStream cr. |
|
919 |
]. |
|
920 |
outStream nextPutLine:'</pre>'. |
|
921 |
! |
|
922 |
||
923 |
generateRefLineFor:ref forClass:aClass |
|
1337
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
924 |
|idx1 idx2 realRef ns nm href| |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
925 |
|
2016 | 926 |
outStream nextPutAll:' '. |
1337
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
927 |
|
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
928 |
idx1 := ref indexOf:$:. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
929 |
idx2 := ref indexOf:$: startingAt:idx1+1. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
930 |
|
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
931 |
(idx1 == 0 or:[idx2 == (idx1+1)]) ifTrue:[ |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
932 |
(ref includesMatchCharacters) ifTrue:[ |
2016 | 933 |
outStream nextPutAll:(self |
1337
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
934 |
anchorForHTMLDocAction: |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
935 |
('htmlClassesMatching:''' , ref , ''' backTo:nil') |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
936 |
info: |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
937 |
( 'Show documentation of ' , ref ) |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
938 |
text: |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
939 |
ref). |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
940 |
^ self |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
941 |
]. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
942 |
|
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
943 |
realRef := ref. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
944 |
((ns := aClass nameSpace) notNil and:[ns ~~ Smalltalk]) ifTrue:[ |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
945 |
ns isNameSpace ifTrue:[ |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
946 |
(ns at:realRef asSymbol) notNil ifTrue:[ |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
947 |
realRef := ns name , '::' , realRef |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
948 |
] |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
949 |
] |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
950 |
]. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
951 |
self generateClassDocReferenceFor:realRef text:ref. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
952 |
^ self |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
953 |
]. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
954 |
|
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
955 |
(ref startsWith:'http:') ifTrue:[ |
2016 | 956 |
outStream nextPutAll:'<a href="' , ref , '"><I>' , ref , '</I></a>'. |
1337
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
957 |
^ self. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
958 |
]. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
959 |
|
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
960 |
nm := (ref copyFrom:2 to:idx1-1) withoutSpaces. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
961 |
href := (ref copyFrom:(ref indexOf:$:)+1 to:(ref size - 1)) withoutSpaces. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
962 |
(href startsWith:'man:') ifTrue:[ |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
963 |
href := (href copyFrom:5) withoutSpaces. |
2016 | 964 |
outStream nextPutAll:'<a INFO="Show manual page" href="' , self pathToTopOfDocumentation , '/misc/onlyInSTX2.html" action="html:' , self class name , ' manPageFor:''' , href , '''">[<I>' , nm , '</I>]</A>'. |
1337
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
965 |
^ self. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
966 |
]. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
967 |
(href startsWith:'http:') ifTrue:[ |
2016 | 968 |
outStream nextPutAll:'<a href="' , href , '">[<I>' , nm , '</I>]</a>'. |
1337
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
969 |
^ self |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
970 |
]. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
971 |
(href startsWith:'html:') ifTrue:[ |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
972 |
href := (href copyFrom:6) withoutSpaces. |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
973 |
]. |
2016 | 974 |
outStream nextPutAll:'<a href="' , (self pathToDocumentationFile:href) , '">[<I>' , nm , '</I>]</a>'. |
1337
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
975 |
! |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
976 |
|
2016 | 977 |
generateRefLines:refLines forClass:aClass |
978 |
outStream nextPutLine:'<pre>'. |
|
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
979 |
refLines do:[:l | |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
980 |
l isString ifTrue:[ |
2016 | 981 |
self generateRefLineFor:l forClass:aClass. |
982 |
outStream cr. |
|
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
983 |
] ifFalse:[ |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
984 |
l do:[:ref | |
2016 | 985 |
self generateRefLineFor:ref forClass:aClass. |
986 |
outStream cr. |
|
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
987 |
]. |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
988 |
]. |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
989 |
]. |
2016 | 990 |
outStream nextPutLine:'</pre>'. |
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
991 |
! |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
992 |
|
2016 | 993 |
generateSubclassInfoForClass:aClass |
994 |
|subs| |
|
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
995 |
|
1974 | 996 |
subs := self shownSubclassesOf:aClass. |
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
997 |
|
2016 | 998 |
outStream nextPutLine:'<pre>'. |
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
999 |
subs do:[:cls | |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1000 |
|nm| |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1001 |
|
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1002 |
nm := cls name. |
2016 | 1003 |
outStream nextPutAll:' '. |
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1004 |
cls isLoaded ifFalse:[ |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1005 |
self |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1006 |
generateClassDocReferenceFor:nm |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1007 |
text:nm |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1008 |
autoloading:nm |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1009 |
] ifTrue:[ |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1010 |
self generateClassDocReferenceFor:nm. |
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1011 |
]. |
2016 | 1012 |
outStream cr. |
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1013 |
]. |
2016 | 1014 |
outStream nextPutLine:'</pre>'. |
1973 | 1015 |
|
1974 | 1016 |
"Modified: / 05-11-2007 / 17:22:43 / cg" |
3643 | 1017 |
! ! |
1018 |
||
1019 |
!HTMLDocGenerator methodsFor:'document generation-API'! |
|
1312
88d8f1ea1645
fields / urlParameters vs. arguments
Claus Gittinger <cg@exept.de>
parents:
1311
diff
changeset
|
1020 |
|
478 | 1021 |
htmlDocOf:aClass |
632 | 1022 |
"generate an HTML document string which contains a classes documentation" |
1023 |
||
4002 | 1024 |
^ self htmlDocOf:aClass theNonMetaclass back:nil backRef:nil |
478 | 1025 |
|
1026 |
" |
|
1027 |
self htmlDocOf:PostscriptPrinterStream |
|
1028 |
" |
|
1029 |
||
632 | 1030 |
"Modified: / 30.10.1997 / 13:22:19 / cg" |
478 | 1031 |
! |
1032 |
||
1033 |
htmlDocOf:aClass back:backCmd |
|
632 | 1034 |
"generate an HTML document string which contains a classes documentation" |
1035 |
||
478 | 1036 |
^ self htmlDocOf:aClass back:backCmd backRef:nil |
1037 |
||
632 | 1038 |
"Modified: / 30.10.1997 / 13:22:27 / cg" |
478 | 1039 |
! |
1040 |
||
1041 |
htmlDocOf:aClass back:backCmd backRef:backRef |
|
540
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1042 |
"generate a nice HTML page from a class, with a back-reference |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1043 |
to a command or document. |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1044 |
|
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1045 |
Extract sections from the classes documentation method, |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1046 |
where the following lines start a special subsection: |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1047 |
[see also:] - references to other classes and/or documents |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1048 |
[start with:] - one-liners to start a demonstration |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1049 |
[author:] - author(s) of this class |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1050 |
[warning:] - usage warnings if any |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1051 |
[hints:] - usage hints if any |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1052 |
Each section ends with an empty line - however, for formatting, |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1053 |
a line consisting of a single backslash character will be converted |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1054 |
to an empty line. |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1055 |
|
632 | 1056 |
Also extract examples from the classes example method, |
540
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1057 |
where executable examples are made from sections enclosed in: |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1058 |
[exBegin] |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1059 |
... |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1060 |
[exEnd] |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1061 |
these parts are displayed in courier and will be made executable. |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1062 |
everything else is plain documentation text. |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1063 |
" |
907
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1064 |
|
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1065 |
^ self |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1066 |
htmlDocOf:aClass |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1067 |
back:backCmd |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1068 |
backRef:backRef |
1255 | 1069 |
imagePath:(self pathToTopOfDocumentation , '/icons') |
907
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1070 |
! |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1071 |
|
1328 | 1072 |
htmlDocOf:aClass back:backCmdArg backRef:backRefArg imagePath:imagePathArg |
907
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1073 |
"generate a nice HTML page from a class, with a back-reference |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1074 |
to a command or document. |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1075 |
|
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1076 |
Extract sections from the classes documentation method, |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1077 |
where the following lines start a special subsection: |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1078 |
[see also:] - references to other classes and/or documents |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1079 |
[start with:] - one-liners to start a demonstration |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1080 |
[author:] - author(s) of this class |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1081 |
[warning:] - usage warnings if any |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1082 |
[hints:] - usage hints if any |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1083 |
Each section ends with an empty line - however, for formatting, |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1084 |
a line consisting of a single backslash character will be converted |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1085 |
to an empty line. |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1086 |
|
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1087 |
Also extract examples from the classes example method, |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1088 |
where executable examples are made from sections enclosed in: |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1089 |
[exBegin] |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1090 |
... |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1091 |
[exEnd] |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1092 |
these parts are displayed in courier and will be made executable. |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1093 |
everything else is plain documentation text. |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1094 |
" |
540
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1095 |
|
2016 | 1096 |
|docu examples wasLoaded didLoadBin |
3643 | 1097 |
privateClasses owner ownerName shortName | |
478 | 1098 |
|
1328 | 1099 |
backRef := backRefArg. |
1100 |
backCmd := backCmdArg. |
|
1101 |
imagePath := imagePathArg. |
|
1102 |
||
600 | 1103 |
aClass isNil ifTrue:[ |
1104 |
^ '' "/ just in case ... |
|
1105 |
]. |
|
1106 |
||
2016 | 1107 |
outStream := '' writeStream. |
1328 | 1108 |
shortName := aClass nameWithoutPrefix. |
2016 | 1109 |
|
1110 |
self generateHTMLHeadWithTitle:('Class: ' , aClass name). |
|
1328 | 1111 |
self generateBODYStart. |
1112 |
self generateBackButton. |
|
1113 |
||
1896
ed785b09f5b1
changed #listAtCategoryNamed:
Claus Gittinger <cg@exept.de>
parents:
1435
diff
changeset
|
1114 |
(aClass isRealNameSpace) ifTrue:[ |
2016 | 1115 |
outStream |
1116 |
nextPutLine:'<h1>'; |
|
1117 |
nextPutAll:'NameSpace: '; |
|
1118 |
nextPutLine:(shortName); |
|
1119 |
nextPutLine:'</h1>'. |
|
1328 | 1120 |
self generateBODYandHTMLEnd. |
2016 | 1121 |
^ outStream contents. |
1328 | 1122 |
]. |
1123 |
||
478 | 1124 |
(wasLoaded := aClass isLoaded) ifFalse:[ |
1125 |
"/ load it - but not a binary |
|
1126 |
didLoadBin := Smalltalk loadBinaries. |
|
1127 |
Smalltalk loadBinaries:false. |
|
530
d27016ae003f
try harder to extract some source info (module & directory)
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
1128 |
[ |
1256 | 1129 |
Autoload autoloadFailedSignal handle:[:ex | |
1309 | 1130 |
^ 'Autoload of ' , aClass name , ' failed - no documentation available.' |
1256 | 1131 |
] do:[ |
1132 |
aClass autoload. |
|
1133 |
]. |
|
1140
96ccc944d23a
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1134 |
] ensure:[ |
530
d27016ae003f
try harder to extract some source info (module & directory)
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
1135 |
didLoadBin ifTrue:[Smalltalk loadBinaries:true]. |
1256 | 1136 |
]. |
478 | 1137 |
]. |
1138 |
||
499 | 1139 |
owner := aClass owningClass. |
569 | 1140 |
privateClasses := aClass privateClassesSorted. |
499 | 1141 |
|
2016 | 1142 |
docu := self extractDocumentationFromClass:aClass. |
1143 |
"/ refLines, demoLines etc. are generated as a side effect. |
|
1144 |
||
1145 |
examples := self extractExamplesFromClass:aClass. |
|
1146 |
||
1147 |
self extractProtocolCategoriesFrom:aClass. |
|
1148 |
||
1149 |
outStream nextPutLine:'<h1>'. |
|
1150 |
outStream nextPutAll:'Class: '. |
|
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
1151 |
|
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
1152 |
self generatingForSTXBrowser ifTrue:[ |
2016 | 1153 |
outStream |
1154 |
nextPutAll:'<a INFO="Open a Browser on ' , shortName , '" type="example" action="Smalltalk browseInClass:' , aClass name , '">'; |
|
1155 |
nextPutAll:shortName; nextPutLine:'</a>'. |
|
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
1156 |
] ifFalse:[ |
2016 | 1157 |
outStream nextPutAll:shortName. |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
1158 |
]. |
499 | 1159 |
owner notNil ifTrue:[ |
3643 | 1160 |
ownerName := owner nameWithoutPrefix. |
2016 | 1161 |
outStream nextPutAll:' (private in '. |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
1162 |
self generatingForSTXBrowser ifTrue:[ |
2016 | 1163 |
outStream |
3643 | 1164 |
nextPutAll:'<a INFO="Open a Browser on ' , ownerName , '" type="example" action="Smalltalk browseInClass:' , owner name , '">'; |
1165 |
nextPutAll:(ownerName); nextPutLine:'</a>)'. |
|
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
1166 |
] ifFalse:[ |
3643 | 1167 |
outStream nextPutAll:ownerName. |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
1168 |
]. |
523 | 1169 |
] ifFalse:[ |
1170 |
aClass nameSpace ~~ Smalltalk ifTrue:[ |
|
2016 | 1171 |
outStream nextPutAll:' (in ' , aClass nameSpace name , ')' |
523 | 1172 |
] |
499 | 1173 |
]. |
2016 | 1174 |
outStream nextPutLine:'</h1>'. |
478 | 1175 |
|
499 | 1176 |
owner notNil ifTrue:[ |
2016 | 1177 |
outStream nextPutLine:'This class is only visible from within'. |
3643 | 1178 |
outStream nextPutAll:ownerName. |
499 | 1179 |
owner owningClass notNil ifTrue:[ |
2016 | 1180 |
outStream nextPutAll:' (which is itself a private class of '. |
1181 |
outStream nextPutAll:owner owningClass nameWithoutPrefix. |
|
1182 |
outStream nextPutAll:')' |
|
499 | 1183 |
]. |
2016 | 1184 |
outStream nextPutLine:'.' |
499 | 1185 |
]. |
1186 |
||
478 | 1187 |
"/ |
1188 |
"/ index |
|
1189 |
"/ |
|
1190 |
"/ s nextPutAll:'Index:'; cr. |
|
2016 | 1191 |
outStream nextPutLine:'<ul>'. |
1192 |
outStream nextPutLine:'<li><a href="#INHERITANCE" name="I_INHERITANCE">Inheritance</a>'. |
|
540
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1193 |
|
478 | 1194 |
docu notNil ifTrue:[ |
2016 | 1195 |
outStream nextPutLine:'<li><a href="#DESCRIPTION" name="I_DESCRIPTION">Description</a>'. |
478 | 1196 |
]. |
2016 | 1197 |
warnLines notEmptyOrNil ifTrue:[ |
1198 |
outStream nextPutLine:'<li><a href="#WARNING" name="I_WARNING">Warning</a>'. |
|
540
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1199 |
]. |
2016 | 1200 |
hintLines notEmptyOrNil ifTrue:[ |
1201 |
outStream nextPutLine:'<li><a href="#HINTS" name="I_HINTS">Hints</a>'. |
|
540
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1202 |
]. |
478 | 1203 |
refLines notNil ifTrue:[ |
2016 | 1204 |
outStream nextPutLine:'<li><a href="#SEEALSO" name="I_SEEALSO">Related information</a>'. |
478 | 1205 |
]. |
1206 |
||
511
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1207 |
"/ s nextPutLine:'<li><a href="#INSTANCEVARIABLES" name="I_INSTANCEVARIABLES">Instance variables</a>'. |
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1208 |
"/ s nextPutLine:'<li><a href="#CLASSVARIABLES" name="I_CLASSVARIABLES">Class variables</a>'. |
478 | 1209 |
|
2016 | 1210 |
self generateClassProtocolDocumentationForClass:aClass. |
1211 |
self generateInstanceProtocolDocumentationForClass:aClass. |
|
1212 |
||
1213 |
privateClasses notEmptyOrNil ifTrue:[ |
|
499 | 1214 |
privateClasses := privateClasses asOrderedCollection sort:[:a :b | a nameWithoutPrefix < b nameWithoutPrefix]. |
2016 | 1215 |
outStream nextPutLine:'<li><a href="#PRIVATECLASSES" name="I_PRIVATECLASSES">Private classes</a>'. |
499 | 1216 |
]. |
1217 |
||
478 | 1218 |
(aClass == Object or:[aClass == Autoload]) ifTrue:[ |
2016 | 1219 |
outStream nextPutLine:'<li><a href="#SUBCLASSES" name="I_SUBCLASSES">Subclasses</a>'. |
478 | 1220 |
]. |
1221 |
demoLines notNil ifTrue:[ |
|
2016 | 1222 |
outStream nextPutLine:'<li><a href="#DEMOSTARTUP" name="I_DEMOSTARTUP">Demonstration</a>'. |
478 | 1223 |
]. |
1224 |
examples notNil ifTrue:[ |
|
2016 | 1225 |
outStream nextPutLine:'<li><a href="#EXAMPLES" name="I_EXAMPLES">Examples</a>'. |
478 | 1226 |
]. |
2016 | 1227 |
outStream nextPutLine:'</ul>'. |
1249 | 1228 |
self generateHorizontalLine. |
478 | 1229 |
|
1230 |
"/ |
|
1231 |
"/ hierarchy |
|
1232 |
"/ |
|
2016 | 1233 |
self generateInheritanceTreeForClass:aClass. |
1249 | 1234 |
self generateHorizontalLine. |
478 | 1235 |
|
1236 |
"/ |
|
1237 |
"/ category, version & package |
|
1238 |
"/ |
|
2016 | 1239 |
self generateClassInfoForClass:aClass. |
1249 | 1240 |
self generateHorizontalLine. |
478 | 1241 |
|
2016 | 1242 |
self generateDescription:docu. |
478 | 1243 |
|
540
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1244 |
warnLines notNil ifTrue:[ |
2016 | 1245 |
outStream nextPutLine:'<h2><a name="WARNING" href="#I_WARNING">Warning:</A></h2>'. |
1246 |
outStream nextPutLine:'<BR>'. |
|
1247 |
||
1248 |
outStream nextPutLine:'<pre>'. |
|
1249 |
||
1250 |
warnLines := self undentedToFirstLinesIndent:warnLines. |
|
2865 | 1251 |
outStream nextPutAllLines:warnLines. |
2016 | 1252 |
outStream nextPutLine:'</pre>'. |
1249 | 1253 |
self generateHorizontalLine. |
540
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1254 |
]. |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1255 |
|
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1256 |
hintLines notNil ifTrue:[ |
2016 | 1257 |
outStream nextPutLine:'<h2><a name="HINTS" href="#I_HINTS">Hints:</A></h2>'. |
1258 |
outStream nextPutLine:'<BR>'. |
|
1259 |
||
1260 |
outStream nextPutLine:'<pre>'. |
|
1261 |
hintLines := self undentedToFirstLinesIndent:hintLines. |
|
540
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1262 |
|
2865 | 1263 |
outStream nextPutAllLines:hintLines. |
2016 | 1264 |
outStream nextPutLine:'</pre>'. |
1249 | 1265 |
self generateHorizontalLine. |
540
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1266 |
]. |
c20e12db0340
added optional Warning & Hints sections
Claus Gittinger <cg@exept.de>
parents:
530
diff
changeset
|
1267 |
|
478 | 1268 |
"/ |
1269 |
"/ see also |
|
1270 |
"/ |
|
1271 |
refLines notNil ifTrue:[ |
|
2016 | 1272 |
outStream nextPutLine:'<h2><a name="SEEALSO" href="#I_SEEALSO">Related information:</A></h2>'. |
1273 |
self generateRefLines:refLines forClass:aClass. |
|
1249 | 1274 |
self generateHorizontalLine. |
478 | 1275 |
]. |
1276 |
||
1277 |
||
1278 |
"/ |
|
1279 |
"/ inst & classVars |
|
1280 |
"/ to be added |
|
1281 |
||
1282 |
||
1283 |
"/ |
|
1284 |
"/ protocol |
|
1285 |
"/ |
|
2016 | 1286 |
self printOutHTMLProtocolOf:aClass on:outStream. |
478 | 1287 |
|
1288 |
"/ |
|
1289 |
"/ subclasses (only for Object and Autoload) |
|
1290 |
"/ |
|
1291 |
(aClass == Object or:[aClass == Autoload]) ifTrue:[ |
|
2016 | 1292 |
outStream nextPutLine:'<h2><a name="SUBCLASSES" href="#I_SUBCLASSES">Subclasses (direct subclasses only):</A></h2>'. |
1293 |
self generateSubclassInfoForClass:aClass. |
|
1249 | 1294 |
self generateHorizontalLine. |
478 | 1295 |
]. |
1296 |
||
1297 |
"/ |
|
499 | 1298 |
"/ private classes |
1299 |
"/ |
|
2016 | 1300 |
privateClasses notEmptyOrNil ifTrue:[ |
1301 |
outStream nextPutLine:'<h2><a name="PRIVATECLASSES" href="#I_PRIVATECLASSES">Private classes:</A></h2>'. |
|
1302 |
self generatePrivateClassInfoForClass:aClass withPrivateClasses:privateClasses. |
|
1249 | 1303 |
self generateHorizontalLine. |
499 | 1304 |
]. |
1305 |
||
2016 | 1306 |
"/ demonstration, if there are any |
478 | 1307 |
demoLines notNil ifTrue:[ |
2016 | 1308 |
self generateDemo. |
1249 | 1309 |
self generateHorizontalLine. |
478 | 1310 |
]. |
1311 |
||
2016 | 1312 |
"/ examples, if there are any |
478 | 1313 |
examples notNil ifTrue:[ |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
1314 |
self generateExamples:examples. |
478 | 1315 |
]. |
1316 |
||
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
1317 |
self generateBODYandHTMLEnd. |
478 | 1318 |
|
1319 |
wasLoaded ifFalse:[ |
|
1320 |
aClass unload |
|
1321 |
]. |
|
1322 |
||
2016 | 1323 |
^ outStream contents |
478 | 1324 |
|
1325 |
" |
|
1326 |
self htmlDocOf:Object |
|
1327 |
self htmlDocOf:Array |
|
1328 |
self htmlDocOf:Filename |
|
1329 |
self htmlDocOf:Block |
|
1330 |
" |
|
1331 |
||
1896
ed785b09f5b1
changed #listAtCategoryNamed:
Claus Gittinger <cg@exept.de>
parents:
1435
diff
changeset
|
1332 |
"Created: / 24-04-1996 / 15:01:59 / cg" |
2865 | 1333 |
"Modified: / 27-07-2012 / 09:29:45 / cg" |
478 | 1334 |
! |
1335 |
||
1336 |
htmlDocOf:aClass backRef:backRef |
|
632 | 1337 |
"generate an HTML document string which contains a classes documentation" |
1338 |
||
478 | 1339 |
^ self htmlDocOf:aClass back:nil backRef:backRef |
1340 |
||
632 | 1341 |
"Created: / 24.4.1996 / 15:03:25 / cg" |
1342 |
"Modified: / 30.10.1997 / 13:23:12 / cg" |
|
478 | 1343 |
! |
1344 |
||
1345 |
htmlDocOfImplementorsOf:selector |
|
632 | 1346 |
"generate an HTML document string which contains HREFS |
1347 |
to all implementors of a particular selector" |
|
1348 |
||
727
1729dca2ab7a
sort HTML-page of implemented selectors by className.
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1349 |
|sel s classes| |
478 | 1350 |
|
1249 | 1351 |
sel := self withSpecialHTMLCharactersEscaped:selector. |
478 | 1352 |
|
1249 | 1353 |
outStream := s := '' writeStream. |
478 | 1354 |
|
1249 | 1355 |
self generateHTMLHeadWithTitle:('Implementations of: ' , sel). |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
1356 |
self generateBODYStart. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
1357 |
|
1249 | 1358 |
self generateUpArrowButtonForTop. |
1359 |
self generateHorizontalLine. |
|
1360 |
self generateH1:sel. |
|
478 | 1361 |
|
511
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1362 |
s nextPutLine:'<dl>'. |
478 | 1363 |
|
727
1729dca2ab7a
sort HTML-page of implemented selectors by className.
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1364 |
classes := IdentitySet new. |
1729dca2ab7a
sort HTML-page of implemented selectors by className.
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1365 |
|
478 | 1366 |
sel := selector asSymbol. |
1249 | 1367 |
Smalltalk allClassesAndMetaclassesDo:[:cls | |
499 | 1368 |
cls isPrivate ifFalse:[ |
1138
aa7687ec256f
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
917
diff
changeset
|
1369 |
(cls includesSelector:sel) ifTrue:[ |
727
1729dca2ab7a
sort HTML-page of implemented selectors by className.
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1370 |
classes add:cls |
499 | 1371 |
] |
478 | 1372 |
] |
1373 |
]. |
|
1374 |
||
1249 | 1375 |
(classes asOrderedCollection sort:[:a :b | a name < b name]) |
1376 |
do:[:cls | |
|
1377 |
self |
|
1378 |
printOutHTMLMethodProtocol:(cls compiledMethodAt:sel) |
|
1379 |
on:s |
|
1380 |
showClassName:true |
|
1381 |
classRef:true. |
|
1382 |
s nextPutLine:'<p>'. |
|
1383 |
]. |
|
727
1729dca2ab7a
sort HTML-page of implemented selectors by className.
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1384 |
|
511
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1385 |
s nextPutLine:'</dl>'. |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
1386 |
self generateBODYandHTMLEnd. |
478 | 1387 |
|
1388 |
^ s contents |
|
1389 |
||
632 | 1390 |
"Created: / 22.4.1996 / 20:03:31 / cg" |
727
1729dca2ab7a
sort HTML-page of implemented selectors by className.
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1391 |
"Modified: / 30.10.1998 / 22:15:30 / cg" |
478 | 1392 |
! |
1393 |
||
1435 | 1394 |
htmlDocOfImplementorsOfAnyMatching:selectorPattern |
1395 |
"generate an HTML document string which contains HREFS |
|
1396 |
to all implementors of a particular selector" |
|
1397 |
||
1398 |
|s sel classes| |
|
1399 |
||
1400 |
outStream := s := '' writeStream. |
|
1401 |
||
1402 |
sel := self withSpecialHTMLCharactersEscaped:selectorPattern. |
|
1403 |
self generateHTMLHeadWithTitle:('Implementations of: ' , sel). |
|
1404 |
self generateBODYStart. |
|
1405 |
||
1406 |
self generateUpArrowButtonForTop. |
|
1407 |
self generateHorizontalLine. |
|
1408 |
||
1409 |
self generateH1:sel. |
|
1410 |
||
1411 |
s nextPutLine:'<dl>'. |
|
1412 |
||
1413 |
classes := IdentitySet new. |
|
1414 |
||
1415 |
Smalltalk allClassesAndMetaclassesDo:[:cls | |
|
1416 |
cls isPrivate ifFalse:[ |
|
1417 |
(cls methodDictionary keys contains:[:sel | selectorPattern match:sel]) ifTrue:[ |
|
1418 |
classes add:cls |
|
1419 |
] |
|
1420 |
] |
|
1421 |
]. |
|
1422 |
||
1423 |
(classes asOrderedCollection sort:[:a :b | a name < b name]) |
|
1424 |
do:[:cls | |
|
1425 |
cls methodDictionary keys do:[:eachSel | |
|
1426 |
(selectorPattern match:eachSel) ifTrue:[ |
|
1427 |
self |
|
1428 |
printOutHTMLMethodProtocol:(cls compiledMethodAt:eachSel) |
|
1429 |
on:s |
|
1430 |
showClassName:true |
|
1431 |
classRef:true. |
|
1432 |
s nextPutLine:'<p>'. |
|
1433 |
]. |
|
1434 |
]. |
|
1435 |
]. |
|
1436 |
||
1437 |
s nextPutLine:'</dl>'. |
|
1438 |
self generateBODYandHTMLEnd. |
|
1439 |
||
1440 |
^ s contents |
|
3643 | 1441 |
! |
1442 |
||
1443 |
htmlOfflineDocOf:aClass |
|
1444 |
"generate an HTML document string which contains a class's documentation for offline reading. |
|
1445 |
Offline reading means that the links to other classes are created as file links, |
|
1446 |
(as opposed to action links, which only work with the builtin doc reader)." |
|
1447 |
||
1448 |
generateDocumentForOfflineReading := true. |
|
1449 |
^ self |
|
1450 |
htmlDocOf:aClass back:nil backRef:nil |
|
1451 |
imagePath:(self pathToTopOfDocumentation , '/icons') |
|
1452 |
||
1453 |
" |
|
1454 |
self htmlOfflineDocOf:PostscriptPrinterStream |
|
1455 |
" |
|
1251 | 1456 |
! ! |
1457 |
||
1280 | 1458 |
!HTMLDocGenerator methodsFor:'document generation-helpers'! |
1251 | 1459 |
|
2016 | 1460 |
extractAndRemoveSpecial:pattern from:docu |
1461 |
"given a collection of docu lines (from documentation methods comment), |
|
1462 |
extract things like [see also:], [author:] etc. |
|
1463 |
If found, remove the lines from the string collection, |
|
1464 |
and return the extracted ones. Otherwise return nil. |
|
1465 |
Attention: docu is sideeffectively changed (lines removed)" |
|
1466 |
||
1467 |
|srchIdx idx lines l| |
|
1468 |
||
1469 |
srchIdx := docu findFirst:[:l | l asLowercase withoutSeparators = pattern]. |
|
1470 |
srchIdx ~~ 0 ifTrue:[ |
|
1471 |
lines := OrderedCollection new. |
|
1472 |
||
1473 |
idx := srchIdx+1. |
|
1474 |
[idx <= docu size] whileTrue:[ |
|
1475 |
l := docu at:idx. |
|
1476 |
(l isNil or:[l withoutSeparators size == 0]) ifTrue:[ |
|
1477 |
idx := docu size + 1. |
|
1478 |
] ifFalse:[ |
|
1479 |
l withoutSeparators = '\' ifTrue:[ |
|
1480 |
l := '' |
|
1481 |
]. |
|
1482 |
lines add:l |
|
1483 |
]. |
|
1484 |
idx := idx + 1. |
|
1485 |
]. |
|
1486 |
||
1487 |
docu removeFromIndex:srchIdx toIndex:srchIdx+lines size |
|
1488 |
]. |
|
1489 |
^ lines |
|
1490 |
||
1491 |
"Created: 25.4.1996 / 14:16:01 / cg" |
|
1492 |
"Modified: 11.1.1997 / 13:03:38 / cg" |
|
1493 |
! |
|
1494 |
||
1495 |
extractAndRemoveSpecialLinesFromDocumentation:docu |
|
1496 |
"Extract things like [see also:], [author:] etc. from docu |
|
1497 |
If found, remove the lines from the string collection, |
|
1498 |
and leave them in corresponding instVars. |
|
1499 |
Attention: docu is sideeffectively changed (lines removed)" |
|
1500 |
||
1501 |
"/ |
|
1502 |
"/ search for a [see also:] section |
|
1503 |
"/ |
|
1504 |
refLines := self extractAndRemoveSpecial:'[see also:]' from:docu. |
|
1505 |
refLines notNil ifTrue:[ |
|
1506 |
"/ care for the special tuple format |
|
1507 |
refLines := refLines collect:[:l | |
|
1508 |
|t| |
|
1509 |
||
1510 |
((t := l withoutSeparators) startsWith:'(') ifTrue:[ |
|
1511 |
t |
|
1512 |
] ifFalse:[ |
|
1513 |
t := l asCollectionOfWords. |
|
1514 |
(t size == 1 |
|
1515 |
and:[ (t first includes:$:) not ]) ifTrue:[ |
|
1516 |
t first |
|
1517 |
] ifFalse:[ |
|
1518 |
t |
|
1519 |
] |
|
1520 |
] |
|
1521 |
]. |
|
1522 |
]. |
|
1523 |
||
1524 |
||
1525 |
"/ |
|
1526 |
"/ search for a [start with:] section |
|
1527 |
"/ |
|
1528 |
demoLines := self extractAndRemoveSpecial:'[start with:]' from:docu. |
|
1529 |
||
1530 |
"/ |
|
1531 |
"/ search for a [author:] section |
|
1532 |
"/ |
|
1533 |
authorLines := self extractAndRemoveSpecial:'[author:]' from:docu. |
|
1534 |
authorLines isNil ifTrue:[ |
|
1535 |
authorLines := self extractAndRemoveSpecial:'[authors:]' from:docu. |
|
1536 |
]. |
|
1537 |
||
1538 |
"/ |
|
1539 |
"/ search for a [warning:] section |
|
1540 |
"/ |
|
1541 |
warnLines := self extractAndRemoveSpecial:'[warning:]' from:docu. |
|
1542 |
warnLines notNil ifTrue:[ |
|
1543 |
warnLines := warnLines asStringCollection. |
|
1544 |
]. |
|
1545 |
||
1546 |
"/ |
|
1547 |
"/ search for a [hints:] section |
|
1548 |
"/ |
|
1549 |
hintLines := self extractAndRemoveSpecial:'[hints:]' from:docu. |
|
1550 |
hintLines isNil ifTrue:[ |
|
1551 |
hintLines := self extractAndRemoveSpecial:'[hint:]' from:docu. |
|
1552 |
]. |
|
1553 |
hintLines notNil ifTrue:[ |
|
1554 |
hintLines := hintLines asStringCollection. |
|
1555 |
]. |
|
1556 |
! |
|
1557 |
||
1558 |
extractDocumentationFromClass:aClass |
|
1559 |
|documentationMethod docu| |
|
1560 |
||
1561 |
documentationMethod := aClass theMetaclass compiledMethodAt:#documentation. |
|
1562 |
documentationMethod notNil ifTrue:[ |
|
1563 |
docu := documentationMethod comment. |
|
1564 |
] ifFalse:[ |
|
1565 |
"try comment" |
|
1566 |
docu := aClass theNonMetaclass comment. |
|
1567 |
]. |
|
1568 |
docu isEmptyOrNil ifTrue:[ ^ nil ]. |
|
1569 |
||
1570 |
docu := self withSpecialHTMLCharactersEscaped:docu. |
|
1571 |
docu := docu asStringCollection. |
|
1572 |
||
1573 |
self extractAndRemoveSpecialLinesFromDocumentation:docu. |
|
1574 |
||
1575 |
docu notEmpty ifTrue:[ |
|
1576 |
"/ |
|
1577 |
"/ strip off empty lines |
|
1578 |
"/ |
|
1579 |
[docu notEmpty and:[ docu first size == 0]] whileTrue:[ |
|
1580 |
docu removeFirst |
|
1581 |
]. |
|
1582 |
[docu notEmpty and:[ docu last size == 0]] whileTrue:[ |
|
1583 |
docu removeLast |
|
1584 |
]. |
|
1585 |
]. |
|
1586 |
||
1587 |
docu notEmpty ifTrue:[ |
|
1588 |
docu := self undentedToFirstLinesIndent:docu. |
|
1589 |
]. |
|
1590 |
docu := docu asString. |
|
1591 |
^ docu |
|
1592 |
! |
|
1593 |
||
1594 |
extractExamplesFromClass:aClass |
|
1595 |
|m examples| |
|
1596 |
||
1597 |
m := aClass theMetaclass compiledMethodAt:#examples. |
|
1598 |
m isNil ifTrue:[ ^ nil]. |
|
1599 |
||
1600 |
examples := m comment. |
|
1601 |
examples isEmptyOrNil ifTrue:[ ^ nil]. |
|
1602 |
||
1603 |
examples := self withSpecialHTMLCharactersEscaped:examples. |
|
1604 |
examples := examples asStringCollection. |
|
1605 |
||
1606 |
"/ |
|
1607 |
"/ strip off empty lines |
|
1608 |
"/ |
|
3625 | 1609 |
[examples notEmpty and:[examples first isEmptyOrNil]] whileTrue:[ |
2252
cd22e5433333
changed: #extractExamplesFromClass:
Stefan Vogel <sv@exept.de>
parents:
2205
diff
changeset
|
1610 |
examples removeFirst. |
2016 | 1611 |
]. |
3625 | 1612 |
[examples notEmpty and:[examples last isEmptyOrNil]] whileTrue:[ |
2252
cd22e5433333
changed: #extractExamplesFromClass:
Stefan Vogel <sv@exept.de>
parents:
2205
diff
changeset
|
1613 |
examples removeLast. |
2016 | 1614 |
]. |
1615 |
||
1616 |
examples isEmpty ifTrue:[ ^ nil]. |
|
1617 |
||
1618 |
examples := self undentedToFirstLinesIndent:examples. |
|
1619 |
^ examples |
|
1620 |
! |
|
1621 |
||
1622 |
extractProtocolCategoriesFrom:aClass |
|
1623 |
classProtocolCategories := aClass theMetaclass categories asSortedCollection. |
|
1624 |
classProtocolCategories notEmpty ifTrue:[ |
|
1625 |
classProtocolCategories := classProtocolCategories asSortedCollection. |
|
1626 |
classProtocolCategories remove:'documentation' ifAbsent:nil. |
|
1627 |
]. |
|
1628 |
instanceProtocolCategories := aClass theNonMetaclass categories asSortedCollection. |
|
1629 |
instanceProtocolCategories notEmpty ifTrue:[ |
|
1630 |
instanceProtocolCategories := instanceProtocolCategories asSortedCollection. |
|
1631 |
]. |
|
1632 |
! |
|
1633 |
||
3625 | 1634 |
htmlForMethod:arg |
1635 |
^ self class htmlForMethod:arg |
|
1973 | 1636 |
! |
1637 |
||
1251 | 1638 |
htmlRevisionDocOf:aClass to:s |
1639 |
"extract a classes versionInfo and return an HTML document string |
|
1640 |
for that." |
|
1641 |
||
1642 |
|revInfo pckgInfo text path| |
|
1643 |
||
1644 |
revInfo := aClass revisionInfo. |
|
1645 |
pckgInfo := aClass packageSourceCodeInfo. |
|
1646 |
||
1647 |
s nextPutLine:'<dl><dt><a name="VERSION"><b>Version:</b></A>'. |
|
1648 |
||
1649 |
(revInfo isNil and:[pckgInfo isNil]) ifTrue:[ |
|
1650 |
s nextPutLine:'<dd>no revision info'. |
|
1651 |
] ifFalse:[ |
|
1652 |
||
1653 |
revInfo isNil ifTrue:[revInfo := IdentityDictionary new]. |
|
1654 |
pckgInfo isNil ifTrue:[pckgInfo := IdentityDictionary new]. |
|
1655 |
||
1656 |
s nextPutLine:'<dd>rev: <b>'. |
|
1657 |
||
1658 |
"/ fetch the revision-info; prefer revisionInfo |
|
1659 |
text := revInfo at:#revision ifAbsent:(pckgInfo at:#revision ifAbsent:'?'). |
|
1660 |
s nextPutLine:text. |
|
1661 |
||
1662 |
"/ fetch the date & time; prefer revisionInfo |
|
1663 |
text := revInfo at:#date ifAbsent:(pckgInfo at:#date ifAbsent:'?'). |
|
1664 |
s nextPutAll:'</b> date: <b>' , text. |
|
1665 |
text := revInfo at:#time ifAbsent:(pckgInfo at:#time ifAbsent:'?'). |
|
1666 |
s nextPutLine:' ', text , '</b>'. |
|
1667 |
||
1668 |
text := revInfo at:#user ifAbsent:(pckgInfo at:#user ifAbsent:'?'). |
|
1669 |
s nextPutLine:'<dd>user: <b>' , text , '</b>'. |
|
1670 |
||
1671 |
text := revInfo at:#fileName ifAbsent:(pckgInfo at:#fileNamer ifAbsent:'?'). |
|
1672 |
s nextPutAll:'<dd>file: <b>' , text. |
|
1673 |
||
1674 |
text := revInfo at:#directory ifAbsent:(pckgInfo at:#directory ifAbsent:nil). |
|
1675 |
text isNil ifTrue:[ |
|
1676 |
path := revInfo at:#repositoryPathName ifAbsent:(pckgInfo at:#repositoryPathName ifAbsent:nil). |
|
1677 |
path notNil ifTrue:[ |
|
1678 |
SourceCodeManager notNil ifTrue:[ |
|
1346
8657706d79ba
generation of relative-path in CVS fixed
Claus Gittinger <cg@exept.de>
parents:
1344
diff
changeset
|
1679 |
text := SourceCodeManager directoryFromContainerPath:path forClass:aClass. |
1251 | 1680 |
]. |
1681 |
text isNil ifTrue:[text := '?']. |
|
1682 |
] ifFalse:[ |
|
1683 |
text := '?' |
|
1684 |
] |
|
1685 |
]. |
|
1686 |
s nextPutLine:'</b> directory: <b>' , text , '</b>'. |
|
1687 |
||
1688 |
text := revInfo at:#module ifAbsent:(pckgInfo at:#module ifAbsent:nil). |
|
1689 |
text isNil ifTrue:[ |
|
1690 |
path := revInfo at:#repositoryPathName ifAbsent:(pckgInfo at:#repositoryPathName ifAbsent:nil). |
|
1691 |
path notNil ifTrue:[ |
|
1692 |
SourceCodeManager notNil ifTrue:[ |
|
1346
8657706d79ba
generation of relative-path in CVS fixed
Claus Gittinger <cg@exept.de>
parents:
1344
diff
changeset
|
1693 |
text := SourceCodeManager moduleFromContainerPath:path forClass:aClass. |
1251 | 1694 |
]. |
1695 |
text isNil ifTrue:[text := '?']. |
|
1696 |
] ifFalse:[ |
|
1697 |
text := '?' |
|
1698 |
] |
|
1699 |
]. |
|
1700 |
s nextPutAll:'<dd>module: <b>' , text. |
|
1701 |
||
1702 |
text := revInfo at:#library ifAbsent:(pckgInfo at:#library ifAbsent:'*none*'). |
|
1703 |
s nextPutLine:'</b> stc-classLibrary: <b>' , text , '</b>'. |
|
1704 |
]. |
|
1705 |
||
1706 |
"Created: / 8.1.1997 / 13:43:28 / cg" |
|
1707 |
"Modified: / 30.10.1997 / 13:24:39 / cg" |
|
478 | 1708 |
! |
1709 |
||
1710 |
printOutHTMLCategoryProtocol:aCategory of:aClass on:aStream |
|
632 | 1711 |
"append documentation on each method in a particular methodCategory |
1712 |
of the given class in HTML onto aStream." |
|
1713 |
||
523 | 1714 |
|any dict selectors methods shortName| |
1715 |
||
1716 |
shortName := aClass nameWithoutPrefix. |
|
478 | 1717 |
|
1718 |
dict := aClass methodDictionary. |
|
1719 |
||
1720 |
dict notNil ifTrue:[ |
|
1721 |
any := false. |
|
1722 |
dict do:[:aMethod | |
|
1723 |
(aCategory = aMethod category) ifTrue:[ |
|
1724 |
any := true |
|
1725 |
] |
|
1726 |
]. |
|
1727 |
||
1728 |
any ifTrue:[ |
|
523 | 1729 |
aStream nextPutLine:'<a name="' , shortName , '_category_' , aCategory , |
1730 |
'" href="#I_' , shortName , '_category_' , aCategory , |
|
511
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1731 |
'"><b>' , aCategory , '</b></A>'. |
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1732 |
aStream nextPutLine:'<dl>'. |
478 | 1733 |
|
1734 |
selectors := dict keys asArray. |
|
1735 |
methods := dict values. |
|
1736 |
selectors sortWith:methods. |
|
1737 |
methods do:[:aMethod | |
|
1738 |
(aCategory = aMethod category) ifTrue:[ |
|
1216
b854fdc89d2a
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
1178
diff
changeset
|
1739 |
Error catch:[ |
478 | 1740 |
self printOutHTMLMethodProtocol:aMethod on:aStream. |
1741 |
]. |
|
511
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1742 |
aStream nextPutLine:'<p>'. |
478 | 1743 |
] |
1744 |
]. |
|
511
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1745 |
aStream nextPutLine:'</dl>'. |
478 | 1746 |
] |
1747 |
] |
|
1748 |
||
1749 |
" |
|
1750 |
self printOutHTMLProtocolOf:Float on:Stdout |
|
1751 |
" |
|
1752 |
||
632 | 1753 |
"Created: / 22.4.1996 / 20:03:30 / cg" |
1754 |
"Modified: / 5.6.1996 / 13:41:27 / stefan" |
|
1755 |
"Modified: / 30.10.1997 / 13:27:58 / cg" |
|
478 | 1756 |
! |
1757 |
||
1758 |
printOutHTMLMethodProtocol:aMethod on:aStream |
|
1759 |
"given the source in aString, print the methods message specification |
|
1760 |
and any method comments - without source; used to generate documentation |
|
1761 |
pages" |
|
1762 |
||
907
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1763 |
^ self |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1764 |
printOutHTMLMethodProtocol:aMethod |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1765 |
on:aStream |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1766 |
showClassName:false |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1767 |
classRef:false |
478 | 1768 |
|
1769 |
"Modified: 22.4.1996 / 18:01:56 / cg" |
|
1770 |
"Created: 22.4.1996 / 20:03:30 / cg" |
|
1771 |
! |
|
1772 |
||
1773 |
printOutHTMLMethodProtocol:aMethod on:aStream showClassName:showClassName classRef:withClassRef |
|
1774 |
"given the source in aString, print the methods message specification |
|
1775 |
and any method comments - without source; used to generate documentation |
|
1776 |
pages" |
|
1777 |
||
1344 | 1778 |
|p| |
1779 |
||
1780 |
"/ p := imagePath. |
|
1781 |
"/ p isNil ifTrue:[ |
|
1782 |
"/ p := self pathToTopOfDocumentation , '/icons' |
|
1783 |
"/ ]. |
|
1784 |
p := self pathToTopOfDocumentation , '/pictures'. |
|
907
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1785 |
^ self |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1786 |
printOutHTMLMethodProtocol:aMethod |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1787 |
on:aStream |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1788 |
showClassName:showClassName |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1789 |
classRef:withClassRef |
1344 | 1790 |
picturePath:p |
907
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1791 |
! |
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1792 |
|
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1793 |
printOutHTMLMethodProtocol:aMethod on:aStream showClassName:showClassName classRef:withClassRef picturePath:picturePath |
3625 | 1794 |
"given the source in aString, print the method's message specification |
1795 |
and any method comments - without source. |
|
1796 |
used to generate documentation pages" |
|
907
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1797 |
|
1973 | 1798 |
|comment cls sel who methodSpecLine |
478 | 1799 |
firstIndent firstNonEmpty isSubres isObsolete smallOrEmpty |
3625 | 1800 |
ballColor anchorName parseTree expr obsoleteInfo |
1801 |
exampleComments isInheritedComment| |
|
478 | 1802 |
|
1803 |
who := aMethod who. |
|
505
d8d7556d05ee
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1804 |
cls := who methodClass. |
d8d7556d05ee
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
1805 |
sel := who methodSelector. |
1973 | 1806 |
|
1807 |
methodSpecLine := self htmlForMethod:aMethod. |
|
478 | 1808 |
|
632 | 1809 |
"/ use string-asSymbol (instead of the obvious symbol itself) |
1810 |
"/ in the checks below, to avoid tricking myself, |
|
1811 |
"/ when the documentation on this method is generated |
|
1812 |
"/ (otherwise, I'll say that this method is both |
|
1813 |
"/ a subres and and obsolete method ...) |
|
1814 |
||
3797 | 1815 |
isSubres := aMethod sendsAny:#( #'subclassResponsibility' #'subclassResponsibility:' ). |
478 | 1816 |
|
1973 | 1817 |
isObsolete := aMethod isObsolete. |
1818 |
"/ the above checks for the obsolete-resource flag; |
|
1819 |
"/ there is still achance for obsoleteMethodWarning to be sent, without the resource flag being present. |
|
1820 |
isObsolete ifFalse:[ |
|
1821 |
((aMethod sends:'obsoleteMethodWarning' asSymbol) |
|
1822 |
or:[(aMethod sends:'obsoleteMethodWarning:' asSymbol) |
|
1823 |
or:[(aMethod sends:'obsoleteMethodWarning:from:' asSymbol)]]) ifTrue:[ |
|
1824 |
(sel startsWith:'obsoleteMethodWarning') ifFalse:[ |
|
1825 |
true "cls ~~ Object" ifTrue:[ |
|
1826 |
isObsolete := true. |
|
1827 |
ParseTreeSearcher notNil ifTrue:[ |
|
1828 |
parseTree := cls parseTreeFor:sel. |
|
1829 |
parseTree notNil ifTrue: [ |
|
1830 |
expr := ParseTreeSearcher treeMatching:'`@e1 obsoleteMethodWarning:`@e2' in: parseTree. |
|
1831 |
expr isNil ifTrue:[ |
|
1832 |
expr := ParseTreeSearcher treeMatching:'`@e1 obsoleteMethodWarning:`@e2 from:`@e3' in: parseTree. |
|
1833 |
]. |
|
1834 |
expr notNil ifTrue:[ |
|
1835 |
|arg1| |
|
1836 |
||
1837 |
arg1 := expr arguments first. |
|
1838 |
arg1 isLiteral ifTrue:[ |
|
1839 |
arg1 value isString ifTrue:[ |
|
1840 |
obsoleteInfo := arg1 value. |
|
1841 |
]. |
|
1400 | 1842 |
]. |
1843 |
]. |
|
1844 |
]. |
|
1845 |
]. |
|
1846 |
]. |
|
1973 | 1847 |
] |
1848 |
]. |
|
478 | 1849 |
]. |
1850 |
||
1851 |
smallOrEmpty := ''. |
|
1852 |
aMethod isPrivate ifTrue:[ |
|
642
077371c28483
oops - missing trailing dQuotes - html output failed on netscape
dq
parents:
637
diff
changeset
|
1853 |
methodSpecLine := '<i>private</i> ' , methodSpecLine. |
478 | 1854 |
"/ smallOrEmpty := '-small'. |
1855 |
] ifFalse:[ |
|
1856 |
aMethod isProtected ifTrue:[ |
|
642
077371c28483
oops - missing trailing dQuotes - html output failed on netscape
dq
parents:
637
diff
changeset
|
1857 |
methodSpecLine := '<i>protected</i> ' , methodSpecLine. |
478 | 1858 |
"/ smallOrEmpty := '-small'. |
1859 |
] ifFalse:[ |
|
1860 |
aMethod isIgnored ifTrue:[ |
|
642
077371c28483
oops - missing trailing dQuotes - html output failed on netscape
dq
parents:
637
diff
changeset
|
1861 |
methodSpecLine := '[ ' , methodSpecLine , ' ] (<i>invisible</i>)'. |
478 | 1862 |
"/ smallOrEmpty := '-small'. |
1863 |
] |
|
1864 |
] |
|
1865 |
]. |
|
4051 | 1866 |
aMethod isExtension ifTrue:[ |
1867 |
methodSpecLine := methodSpecLine,(' <br>( <i>an extension from the %1 package</i> )' bindWith:aMethod package). |
|
1868 |
]. |
|
478 | 1869 |
|
632 | 1870 |
aStream nextPutLine:'<DT>'. |
478 | 1871 |
|
1872 |
||
1873 |
cls isMeta ifTrue:[ |
|
1874 |
ballColor := 'yellow' |
|
1875 |
] ifFalse:[ |
|
1876 |
ballColor := 'red' |
|
1877 |
]. |
|
1878 |
||
907
1a6b647d1b43
picture & icon path (for HTTP server)
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
1879 |
aStream nextPutLine:'<IMG src="' , picturePath , '/' , ballColor , '-ball' , smallOrEmpty , '.gif" alt="o " width=6 height=6>'. |
1335 | 1880 |
aStream nextPutAll:' '. |
478 | 1881 |
|
1249 | 1882 |
sel := self withSpecialHTMLCharactersEscaped:sel. |
1883 |
anchorName := cls name , '_' , sel. |
|
478 | 1884 |
|
1885 |
withClassRef ifTrue:[ |
|
1250 | 1886 |
aStream nextPutAll:(self |
1887 |
anchorForHTMLDocAction: |
|
1888 |
('htmlDocOf:', cls theNonMetaclass name ) |
|
1889 |
info: |
|
1890 |
('Show documentation of ' , cls theNonMetaclass name ) |
|
1891 |
text: |
|
1892 |
cls name |
|
1893 |
name:anchorName). |
|
1894 |
aStream nextPutLine:' ' , methodSpecLine. |
|
478 | 1895 |
] ifFalse:[ |
1896 |
showClassName ifTrue:[ |
|
1897 |
methodSpecLine := cls name , ' ' , methodSpecLine |
|
1898 |
]. |
|
1899 |
||
1249 | 1900 |
aStream nextPutLine:'<a name="' , anchorName , '" ' , |
642
077371c28483
oops - missing trailing dQuotes - html output failed on netscape
dq
parents:
637
diff
changeset
|
1901 |
"/ 'href="' , cls name , '_' , sel , '"' , |
511
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1902 |
'>' , methodSpecLine , '</a>'. |
3625 | 1903 |
self generateJavaScriptCallInfo ifTrue:[ |
1904 |
|jsMethodSpecLine| |
|
3903
6926642e3849
Removed dependency on stx:libjavascript
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
1905 |
aStream nextPutLine:'<br>JS: ' , ((Smalltalk at: #HTMLDocGeneratorForJavaScript) htmlForMethod:aMethod). |
3625 | 1906 |
]. |
478 | 1907 |
]. |
632 | 1908 |
aStream nextPutLine:'<DD>'. |
478 | 1909 |
|
3625 | 1910 |
isInheritedComment := false. |
1911 |
comment := self methodCommentOf:aMethod. |
|
1912 |
||
1913 |
"/ filter history lines |
|
1914 |
((comment startsWith:'Created: ') |
|
1915 |
or:[ (comment startsWith:'Modified: ') ]) ifTrue:[ |
|
1916 |
comment := nil. |
|
1917 |
]. |
|
1918 |
||
1919 |
comment isEmptyOrNil ifTrue:[ |
|
1920 |
|m| |
|
1921 |
||
1922 |
m := aMethod mclass superclass lookupMethodFor:aMethod selector. |
|
1923 |
m notNil ifTrue:[ |
|
1924 |
(comment := self methodCommentOf:m) notEmptyOrNil ifTrue:[ |
|
1925 |
isInheritedComment := true. |
|
1926 |
((comment startsWith:'Created: ') |
|
1927 |
or:[ (comment startsWith:'Modified: ') ]) ifTrue:[ |
|
1928 |
comment := nil. |
|
1929 |
]. |
|
1930 |
]. |
|
1931 |
]. |
|
1932 |
]. |
|
1933 |
comment notNil ifTrue:[ |
|
1249 | 1934 |
comment := self withSpecialHTMLCharactersEscaped:comment. |
478 | 1935 |
|
1936 |
comment notEmpty ifTrue:[ |
|
1937 |
comment := comment asStringCollection. |
|
1938 |
firstIndent := comment first leftIndent. |
|
1939 |
firstIndent > 0 ifTrue:[ |
|
1940 |
comment := comment collect:[:line | |
|
1941 |
line leftIndent >= firstIndent ifTrue:[ |
|
1942 |
line copyFrom:firstIndent. |
|
1943 |
] ifFalse:[ |
|
1944 |
line |
|
1945 |
] |
|
1946 |
]. |
|
1947 |
]. |
|
1948 |
firstNonEmpty := comment findFirst:[:line | line notEmpty]. |
|
1949 |
firstNonEmpty > 1 ifTrue:[ |
|
1950 |
comment := comment copyFrom:firstNonEmpty |
|
1951 |
]. |
|
1952 |
comment := comment asString. |
|
3625 | 1953 |
|
1954 |
isInheritedComment ifTrue:[ |
|
1955 |
comment := '<I>(comment from inherited method)</I><BR>' , comment. |
|
1956 |
]. |
|
1957 |
"/ make argument names italic in the comment |
|
1958 |
aMethod numArgs > 0 ifTrue:[ |
|
1959 |
(aMethod methodArgNames ? #()) do:[:each | |
|
1960 |
comment := comment copyReplaceString:each withString:'<I>',each,'</I>' |
|
1961 |
]. |
|
1962 |
comment := comment copyReplaceString:'<I><I>' withString:'<I>'. |
|
1963 |
comment := comment copyReplaceString:'</I></I>' withString:'</I>'. |
|
1964 |
]. |
|
478 | 1965 |
]. |
1966 |
||
1967 |
comment asStringCollection do:[:line | |
|
1178 | 1968 |
aStream |
1969 |
"/ nextPutAll:'<I>'; |
|
1970 |
nextPutAll:line; |
|
1971 |
"/ nextPutAll:'</I>'; |
|
1972 |
nextPutLine:'<BR>'. |
|
478 | 1973 |
]. |
1974 |
]. |
|
1975 |
||
1976 |
isSubres ifTrue:[ |
|
511
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1977 |
aStream nextPutLine:'<BR>'. |
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1978 |
aStream nextPutLine:'<I>** This method raises an error - it must be redefined in concrete classes **</I>'. |
478 | 1979 |
]. |
1980 |
isObsolete ifTrue:[ |
|
511
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1981 |
aStream nextPutLine:'<BR>'. |
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1982 |
aStream nextPutLine:'<I>** This is an obsolete interface - do not use it (it may vanish in future versions) **</I>'. |
1400 | 1983 |
obsoleteInfo notNil ifTrue:[ |
1984 |
aStream nextPutLine:'<BR>'. |
|
1985 |
aStream nextPutLine:'<I>** ' , obsoleteInfo , ' **</I>'. |
|
1986 |
]. |
|
478 | 1987 |
]. |
1988 |
||
3625 | 1989 |
(isSubres | isObsolete) ifFalse:[ |
1990 |
exampleComments := self methodExampleCommentsOf:aMethod. |
|
1991 |
exampleComments notEmptyOrNil ifTrue:[ |
|
1992 |
exampleComments do:[:each | |
|
1993 |
|exampleCode| |
|
1994 |
||
1995 |
exampleCode := self undentedToFirstLinesIndent:each asStringCollection. |
|
1996 |
[exampleCode size > 0 and:[(exampleCode first ? '') withoutSeparators isEmpty]] |
|
1997 |
whileTrue:[ exampleCode removeFirst]. |
|
1998 |
[exampleCode size > 0 and:[(exampleCode last ? '') withoutSeparators isEmpty]] |
|
1999 |
whileTrue:[ exampleCode removeLast]. |
|
2000 |
||
2001 |
exampleCode notEmpty ifTrue:[ |
|
2002 |
outStream nextPutLine:'<blockquote>'. |
|
2003 |
outStream nextPutLine:'usage example(s):<br>'. |
|
2004 |
self generateExampleStart. |
|
2005 |
exampleCode do:[:eachLine | |
|
2006 |
outStream nextPutLine:eachLine |
|
2007 |
]. |
|
2008 |
self generateExampleEnd. |
|
2009 |
outStream nextPutLine:'</blockquote>'. |
|
2010 |
]. |
|
2011 |
]. |
|
2012 |
]. |
|
2013 |
]. |
|
2014 |
||
2015 |
" |
|
2016 |
self basicNew |
|
2017 |
printOutHTMLMethodProtocol:(Array compiledMethodAt:#addAllNonNilElementsTo:) |
|
2018 |
on:Transcript |
|
2019 |
showClassName:true classRef:true picturePath:'pics' |
|
2020 |
" |
|
2021 |
||
1973 | 2022 |
"Created: / 22-04-1996 / 20:03:30 / cg" |
2473
34e29603f01d
changed: #printOutHTMLMethodProtocol:on:showClassName:classRef:picturePath:
Claus Gittinger <cg@exept.de>
parents:
2327
diff
changeset
|
2023 |
"Modified: / 08-08-2011 / 18:54:10 / cg" |
3903
6926642e3849
Removed dependency on stx:libjavascript
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
2024 |
"Modified: / 25-09-2015 / 07:42:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
478 | 2025 |
! |
2026 |
||
2027 |
printOutHTMLProtocolOf:aClass on:aStream |
|
632 | 2028 |
"append documentation of the given class in HTML onto aStream." |
2029 |
||
478 | 2030 |
|collectionOfCategories any| |
2031 |
||
2032 |
"/ self printOutDefinitionOn:aPrintStream. |
|
2033 |
||
732 | 2034 |
collectionOfCategories := aClass class categories asSortedCollection. |
478 | 2035 |
any := false. |
523 | 2036 |
|
2037 |
collectionOfCategories size > 0 ifTrue:[ |
|
2038 |
collectionOfCategories := collectionOfCategories asOrderedCollection. |
|
2039 |
collectionOfCategories remove:'documentation' ifAbsent:[]. |
|
2040 |
collectionOfCategories size > 0 ifTrue:[ |
|
2041 |
collectionOfCategories sort. |
|
642
077371c28483
oops - missing trailing dQuotes - html output failed on netscape
dq
parents:
637
diff
changeset
|
2042 |
aStream nextPutLine:'<h2><a name="CLASSPROTOCOL" href="#I_CLASSPROTOCOL">Class protocol:</a></h2>'. |
523 | 2043 |
collectionOfCategories do:[:aCategory | |
478 | 2044 |
self printOutHTMLCategoryProtocol:aCategory of:aClass class on:aStream. |
2045 |
any := true. |
|
523 | 2046 |
]. |
478 | 2047 |
"/ any ifFalse:[ |
2048 |
"/ aStream nextPutAll:'no new protocol' |
|
2049 |
"/ ]. |
|
1249 | 2050 |
self generateHorizontalLine. |
523 | 2051 |
] |
478 | 2052 |
]. |
2053 |
||
2054 |
||
732 | 2055 |
collectionOfCategories := aClass categories asSortedCollection. |
478 | 2056 |
any := false. |
523 | 2057 |
collectionOfCategories size > 0 ifTrue:[ |
478 | 2058 |
collectionOfCategories := collectionOfCategories asOrderedCollection sort. |
511
ef2631a2cc1c
use #nextPutLine instead of #nextPutAll; #cr
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2059 |
aStream nextPutLine:'<h2><a name="INSTANCEPROTOCOL" href="#I_INSTANCEPROTOCOL">Instance protocol:</A></h2>'. |
478 | 2060 |
collectionOfCategories do:[:aCategory | |
2061 |
self printOutHTMLCategoryProtocol:aCategory of:aClass on:aStream |
|
2062 |
]. |
|
2063 |
"/ any ifFalse:[ |
|
2064 |
"/ aStream nextPutAll:'no new protocol' |
|
2065 |
"/ ]. |
|
1249 | 2066 |
self generateHorizontalLine. |
478 | 2067 |
] |
2068 |
||
2069 |
" |
|
2070 |
self printOutHTMLProtocolOf:Float on:Stdout |
|
2071 |
" |
|
2072 |
||
632 | 2073 |
"Created: / 22.4.1996 / 20:03:30 / cg" |
732 | 2074 |
"Modified: / 25.11.1998 / 12:40:59 / cg" |
2016 | 2075 |
! |
2076 |
||
2077 |
undentedToFirstLinesIndent:someText |
|
2078 |
|undentedText firstIndent firstNonEmpty| |
|
2079 |
||
2049 | 2080 |
undentedText := someText. |
2081 |
||
2082 |
someText size > 0 ifTrue:[ |
|
2083 |
firstIndent := someText first withTabsExpanded leftIndent. |
|
2084 |
firstIndent > 0 ifTrue:[ |
|
2085 |
undentedText := someText collect:[:line | |
|
2086 |
|l| |
|
2087 |
||
2088 |
l := line withTabsExpanded. |
|
2089 |
l leftIndent >= firstIndent ifTrue:[ |
|
2090 |
l copyFrom:firstIndent + 1. |
|
2091 |
] ifFalse:[ |
|
2092 |
l |
|
2093 |
] |
|
2094 |
]. |
|
2095 |
]. |
|
2016 | 2096 |
]. |
2097 |
||
2098 |
firstNonEmpty := undentedText findFirst:[:line | line notEmpty]. |
|
2099 |
firstNonEmpty > 1 ifTrue:[ |
|
2100 |
undentedText := undentedText copyFrom:firstNonEmpty |
|
2101 |
]. |
|
2102 |
^ undentedText |
|
2103 |
! ! |
|
2104 |
||
2105 |
!HTMLDocGenerator methodsFor:'document generation-lists'! |
|
2106 |
||
2107 |
htmlClassCategoryList |
|
2108 |
"generate a formatted list of all available class categories as |
|
2109 |
an HTML string. Each category will be a hyperlink to another |
|
2110 |
autogenerated page, containing the classes per category. |
|
2111 |
The generated page is supposed to be given to an HTML reader |
|
2112 |
with home being set to ../doc/online/xxx/classDoc |
|
2113 |
(i.e. the images are to be found one-up in the doc hierarchy)" |
|
2114 |
||
2115 |
|categories s prefixList prefix prefixStack prev| |
|
2116 |
||
2117 |
categories := Smalltalk allClassCategories asOrderedCollection sort. |
|
2118 |
||
2119 |
outStream := s := '' writeStream. |
|
2120 |
||
2121 |
self generateHTMLHeadWithTitle:'Class Categories:'. |
|
2122 |
||
2123 |
self generateBODYStart. |
|
2124 |
||
2125 |
self generateUpArrowButtonForTop. |
|
2126 |
self generateHorizontalLine. |
|
2127 |
self generateH1:'Class Categories:'. |
|
2128 |
s nextPutLine:'<ul>'. |
|
2129 |
||
2130 |
prefixList := Set new. |
|
2131 |
||
2132 |
categories keysAndValuesDo:[:index :element | |
|
2133 |
|prev common| |
|
2134 |
||
2135 |
index ~~ 1 ifTrue:[ |
|
2136 |
prev := categories at:(index - 1). |
|
2137 |
common := (Array with:prev with:element) longestCommonPrefix. |
|
2138 |
(common endsWith:'-') ifTrue:[ |
|
3232
de4bd4dcb49f
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
2865
diff
changeset
|
2139 |
prefixList add:(common copyButLast:1) |
2016 | 2140 |
] ifFalse:[ |
2141 |
(common includes:$-) ifTrue:[ |
|
2142 |
prefixList add:(common copyTo:(common lastIndexOf:$-)-1). |
|
2143 |
] ifFalse:[ |
|
2144 |
"/ common = prev ifTrue:[ |
|
2145 |
"/ prefixList add:common |
|
2146 |
"/ ] |
|
2147 |
] |
|
2148 |
] |
|
2149 |
] |
|
2150 |
]. |
|
2151 |
||
2152 |
prefix := ''. prefixStack := OrderedCollection new. |
|
2153 |
prev := ''. |
|
2154 |
||
2155 |
categories := categories select:[:nm | nm ~= 'obsolete']. |
|
2156 |
||
2157 |
categories do:[:nm | |
|
2158 |
|longest| |
|
2159 |
||
2160 |
"/ longest prefix .... |
|
2161 |
longest := prefixList inject:'' into:[:maxPrefix :prefix | |
|
2162 |
|prefixWithDash| |
|
2163 |
||
2164 |
prefixWithDash := prefix , '-'. |
|
2165 |
nm = prefix ifTrue:[ |
|
2166 |
maxPrefix |
|
2167 |
] ifFalse:[ |
|
2168 |
(nm startsWith:prefixWithDash) |
|
2169 |
ifTrue:[ |
|
2170 |
prefixWithDash size > maxPrefix size |
|
2171 |
ifTrue:[ |
|
2172 |
prefixWithDash |
|
2173 |
] ifFalse:[ |
|
2174 |
maxPrefix |
|
2175 |
] |
|
2176 |
] ifFalse:[ |
|
2177 |
maxPrefix |
|
2178 |
] |
|
2179 |
] |
|
2180 |
]. |
|
2181 |
||
2182 |
longest size > 0 ifTrue:[ |
|
2183 |
longest = prefix ifTrue:[ |
|
2184 |
"/ no change |
|
2185 |
] ifFalse:[ |
|
2186 |
(longest startsWith:prefix) ifTrue:[ |
|
2187 |
prefixStack addLast:longest. |
|
2188 |
longest ~= prev ifTrue:[ |
|
2189 |
prefixStack size == 1 ifTrue:[ |
|
2190 |
s nextPutLine:'<p>'. |
|
2191 |
]. |
|
2192 |
s nextPutLine:'<li>' , (longest copyFrom:prefix size + 1). |
|
2193 |
]. |
|
2194 |
s nextPutLine:'<ul>'. |
|
2195 |
prefix := longest. |
|
2196 |
] ifFalse:[ |
|
2197 |
s nextPutLine:'</ul>'. |
|
2198 |
prefixStack notEmpty ifTrue:[ |
|
2199 |
prefixStack removeLast. |
|
2200 |
]. |
|
2201 |
||
2202 |
[prefixStack notEmpty |
|
2203 |
and:[(longest startsWith:prefixStack last) not]] whileTrue:[ |
|
2204 |
s nextPutLine:'</ul>'. |
|
2205 |
prefixStack removeLast. |
|
2206 |
]. |
|
2207 |
||
2208 |
prefixStack notEmpty ifTrue:[ |
|
2209 |
prefix := prefixStack last. |
|
2210 |
] ifFalse:[ |
|
2211 |
prefixStack addLast:longest. |
|
2212 |
prefix := longest. |
|
2213 |
longest ~= prev ifTrue:[ |
|
2214 |
prefixStack size == 1 ifTrue:[ |
|
2215 |
s nextPutLine:'<p>'. |
|
2216 |
]. |
|
2217 |
s nextPutLine:'<li>' , longest. |
|
2218 |
]. |
|
2219 |
s nextPutLine:'<ul>'. |
|
2220 |
] |
|
2221 |
]. |
|
2222 |
] |
|
2223 |
] ifFalse:[ |
|
2224 |
[prefixStack size > 0] whileTrue:[ |
|
2225 |
s nextPutLine:'</ul>'. |
|
2226 |
prefixStack removeLast. |
|
2227 |
]. |
|
2228 |
prefixStack size == 0 ifTrue:[ |
|
2229 |
s nextPutLine:'<p>'. |
|
2230 |
]. |
|
2231 |
prefix := ''. |
|
2232 |
]. |
|
2233 |
||
2234 |
s nextPutAll:'<li>'. |
|
3644 | 2235 |
self generateDocumentForOfflineReading ifTrue:[ |
2236 |
s nextPutLine:(self |
|
2237 |
anchorFor: |
|
2238 |
((nm copyReplaceAll:$ with:$_) , '/index.html' ) |
|
2239 |
info: |
|
2240 |
('Classes in ' , nm) |
|
2241 |
text: |
|
2242 |
(nm copyFrom:prefix size + 1) |
|
2243 |
name:nil). |
|
2244 |
] ifFalse:[ |
|
2245 |
s nextPutLine:(self |
|
2016 | 2246 |
anchorForHTMLDocAction: |
2247 |
('htmlClassesListOfCategory:''', nm |
|
2248 |
, ''' backTo:''htmlClassCategoryList''') |
|
2249 |
info: |
|
2250 |
('Classes in ' , nm) |
|
2251 |
text: |
|
2252 |
(nm copyFrom:prefix size + 1)). |
|
3644 | 2253 |
]. |
2016 | 2254 |
|
2255 |
prev := nm. |
|
2256 |
]. |
|
2257 |
||
2258 |
s nextPutAll:' |
|
2259 |
</ul> |
|
2260 |
'. |
|
2261 |
self generateBODYandHTMLEnd. |
|
2262 |
||
2263 |
^ s contents |
|
2264 |
||
2265 |
" |
|
2266 |
HTMLDocGenerator new htmlClassCategoryList |
|
2267 |
" |
|
2268 |
||
2269 |
"Created: / 22.4.1996 / 20:03:30 / cg" |
|
2270 |
"Modified: / 30.10.1997 / 13:16:08 / cg" |
|
2271 |
! |
|
2272 |
||
2273 |
htmlClassListPrefix:prefix |
|
2274 |
"generate an HTML document string which contains HREFS for a list |
|
2275 |
of classes which start with some prefix (typically, the first |
|
2276 |
character is given)" |
|
2277 |
||
2278 |
|classes| |
|
2279 |
||
2280 |
classes := Smalltalk allClasses |
|
2281 |
select:[:cls | |
|
2282 |
cls isPrivate not |
|
2283 |
and:[(cls isRealNameSpace not) |
|
2284 |
and:[cls name startsWith:prefix]] |
|
2285 |
]. |
|
2286 |
||
2287 |
^ self |
|
2288 |
htmlClasses:classes |
|
2289 |
title:('Classes starting with ''' , prefix asString , ''':'). |
|
2290 |
||
2291 |
"Created: / 22-04-1996 / 20:03:31 / cg" |
|
2292 |
"Modified: / 10-11-2006 / 17:11:16 / cg" |
|
2293 |
! |
|
2294 |
||
2295 |
htmlClasses:classes title:title |
|
2296 |
"generate an HTML document string which contains HREFS for a given list |
|
2297 |
of classes" |
|
2298 |
||
2299 |
^ self |
|
2300 |
htmlClasses:classes |
|
2301 |
title:title |
|
2302 |
backTo:nil |
|
2303 |
||
2304 |
"Modified: / 30.10.1997 / 13:21:40 / cg" |
|
2305 |
! |
|
2306 |
||
2307 |
htmlClasses:classes title:title backTo:backRef |
|
2308 |
"generate an HTML document string which contains HREFS for a given list |
|
2309 |
of classes. If backref is nonNil, a back-button to that |
|
2310 |
HREF is added at the top. |
|
2311 |
The generated page is supposed to be given to an HTML reader |
|
2312 |
with home being set to ../doc/online/xxx/classDoc |
|
2313 |
(i.e. the images are to be found one-up in the doc hierarchy)" |
|
2314 |
||
2315 |
|classNames s| |
|
2316 |
||
2317 |
classNames := (classes collect:[:cls | cls name]) asOrderedCollection sort. |
|
2318 |
||
2319 |
outStream := s := '' writeStream. |
|
2320 |
||
2321 |
self generateHTMLHeadWithTitle:title. |
|
2322 |
s nextPutLine:'<body>'. |
|
2323 |
backRef notNil ifTrue:[ |
|
2324 |
backRef ~~ #none ifTrue:[ |
|
2325 |
self |
|
2326 |
generateUpArrowButtonWithReference:(self pathToLanguageTopOfDocumentation , '/TOP.html') |
|
2327 |
command:backRef |
|
2328 |
imagePath:nil |
|
2329 |
altLabel:'back'. |
|
2330 |
] |
|
2331 |
] ifFalse:[ |
|
2332 |
self |
|
2333 |
generateUpArrowButtonWithReference:(self pathToLanguageTopOfDocumentation , '/TOP.html') |
|
2334 |
command:nil |
|
2335 |
imagePath:nil |
|
2336 |
altLabel:'top'. |
|
2337 |
]. |
|
2338 |
backRef ~~ #none ifTrue:[ |
|
2339 |
self generateHorizontalLine. |
|
2340 |
]. |
|
2341 |
self generateH1:title. |
|
2342 |
s nextPutLine:'<ul>'. |
|
2343 |
||
2344 |
classNames do:[:className | |
|
2345 |
s nextPutAll:'<li>'. |
|
2346 |
self generateClassDocReferenceFor:className. |
|
2347 |
s cr. |
|
2348 |
]. |
|
2349 |
||
2350 |
s nextPutAll:' |
|
2351 |
</ul> |
|
2352 |
'. |
|
2353 |
self generateBODYandHTMLEnd. |
|
2354 |
||
2355 |
^ s contents |
|
2356 |
||
2357 |
"Created: / 23.4.1996 / 15:31:55 / cg" |
|
2358 |
"Modified: / 30.10.1997 / 13:21:32 / cg" |
|
2359 |
! |
|
2360 |
||
2361 |
htmlClassesListOfCategory:category |
|
2362 |
"generate an HTML document string which contains HREFS for a list |
|
2363 |
of classes which are contained in a particular category." |
|
2364 |
||
2365 |
^ self |
|
2366 |
htmlClassesListOfCategory:category |
|
2367 |
backTo:nil |
|
2368 |
||
2369 |
"Modified: / 30.10.1997 / 13:21:23 / cg" |
|
2370 |
! |
|
2371 |
||
2372 |
htmlClassesListOfCategory:category backTo:backRef |
|
2373 |
"generate an HTML document string which contains HREFS for a list |
|
2374 |
of classes which are contained in a particular category." |
|
2375 |
||
2376 |
|classes| |
|
2377 |
||
2378 |
classes := Smalltalk allClasses |
|
2379 |
select:[:cls | cls isPrivate not |
|
2380 |
and:[(cls isRealNameSpace not) |
|
2381 |
and:[cls category = category]] |
|
2382 |
]. |
|
2383 |
||
2384 |
^ self |
|
2385 |
htmlClasses:classes |
|
2386 |
title:('Classes in: ' , category) |
|
2387 |
backTo:backRef |
|
2388 |
||
2389 |
"Created: / 23-04-1996 / 15:39:39 / cg" |
|
2390 |
"Modified: / 10-11-2006 / 17:11:23 / cg" |
|
2391 |
! |
|
2392 |
||
2393 |
htmlClassesMatching:aMatchPattern backTo:backRef |
|
2394 |
"generate an HTML document string which contains HREFS |
|
2395 |
for a list of classes whose name matches a given matchPattern." |
|
2396 |
||
2397 |
|classes cls| |
|
2398 |
||
2399 |
classes := Smalltalk allClasses |
|
2400 |
select:[:cls | cls isPrivate not |
|
2401 |
and:[(cls isRealNameSpace not) |
|
2402 |
and:[aMatchPattern match:cls name]] |
|
2403 |
]. |
|
2404 |
||
2405 |
^ self |
|
2406 |
htmlClasses:classes |
|
2407 |
title:('Classes matching: ' , aMatchPattern) |
|
2408 |
backTo:backRef |
|
2409 |
||
2410 |
" |
|
2411 |
self htmlClassesMatching:'Tgen::*' backTo:nil |
|
2412 |
" |
|
2413 |
||
2414 |
"Modified: / 10-11-2006 / 17:11:30 / cg" |
|
2415 |
! |
|
2416 |
||
4106 | 2417 |
htmlKWOCListFor:aKWIC |
2418 |
"generate a formatted list of all keywords in context from class documentation |
|
2419 |
as an HTML string. |
|
2420 |
Each keword will be a hyperlinked to another |
|
2421 |
autogenerated page, containing the classes documentation. |
|
2422 |
The generated page is supposed to be given to an HTML reader |
|
2423 |
with home being set to ../doc/online/xxx/classDoc |
|
2424 |
(i.e. the images are to be found one-up in the doc hierarchy)" |
|
2425 |
||
4108 | 2426 |
|prevWord caseMapping| |
4106 | 2427 |
|
2428 |
outStream := '' writeStream. |
|
2429 |
||
2430 |
self generateHTMLHeadWithTitle:'Keyword Index:'. |
|
2431 |
self generateBODYStart. |
|
2432 |
self generateUpArrowButtonForTop. |
|
2433 |
self generateHorizontalLine. |
|
2434 |
||
2435 |
self generateH1:'Keywords:'. |
|
2436 |
outStream nextPutLine:'<dl>'. |
|
2437 |
prevWord := nil. |
|
4108 | 2438 |
|
2439 |
caseMapping := Dictionary new. |
|
2440 |
aKWIC entriesDo:[:word :left :right :class| |
|
2441 |
|lcWord wordAlready| |
|
2442 |
||
2443 |
lcWord := word asLowercase. |
|
2444 |
lcWord ~= word ifTrue:[ |
|
2445 |
wordAlready := caseMapping at:lcWord ifAbsent:[nil]. |
|
2446 |
wordAlready isNil ifTrue:[ |
|
2447 |
caseMapping at:lcWord put:word |
|
2448 |
]. |
|
2449 |
]. |
|
2450 |
]. |
|
2451 |
||
4127 | 2452 |
aKWIC matchSorter:[:a :b | a key < b key]. |
4108 | 2453 |
|
4127 | 2454 |
aKWIC entriesDo:[:word :left :right :classOrMethod| |
4106 | 2455 |
|ref lcWord ctx| |
2456 |
||
4109 | 2457 |
ctx := (HTMLUtilities escapeCharacterEntities:(left contractAtBeginningTo:25)) |
4124 | 2458 |
, ' <b>',(HTMLUtilities escapeCharacterEntities:word),'</b> ' |
4109 | 2459 |
,(HTMLUtilities escapeCharacterEntities:(right contractAtEndTo:25)). |
4106 | 2460 |
|
2461 |
lcWord := word asLowercase. |
|
2462 |
lcWord ~= prevWord ifTrue:[ |
|
2463 |
prevWord notNil ifTrue:[ |
|
2464 |
outStream nextPutLine:'</ul></dd>'. |
|
2465 |
]. |
|
4108 | 2466 |
"/ outStream nextPutLine:'<dt>',(HTMLUtilities escapeCharacterEntities:(caseMapping at:lcWord ifAbsent:[word])),'</dt>'. |
2467 |
outStream nextPutLine:'<dt>',(HTMLUtilities escapeCharacterEntities:word),'</dt>'. |
|
4106 | 2468 |
outStream nextPutLine:'<dd><ul><li>'. |
4127 | 2469 |
classOrMethod isBehavior ifTrue:[ |
2470 |
self generateClassDocReferenceFor:classOrMethod name. |
|
2471 |
] ifFalse:[ |
|
2472 |
self generateMethodDocReferenceFor:classOrMethod selector inClass:classOrMethod mclass name text:classOrMethod selector autoloading:nil. |
|
2473 |
]. |
|
4108 | 2474 |
outStream nextPutAll:'<tab indent=300>'. |
4106 | 2475 |
outStream nextPutLine:ctx. |
2476 |
outStream nextPutLine:'</li>'. |
|
2477 |
prevWord := lcWord. |
|
2478 |
] ifFalse:[ |
|
2479 |
outStream nextPutLine:'</li><li>'. |
|
4127 | 2480 |
classOrMethod isBehavior ifTrue:[ |
2481 |
self generateClassDocReferenceFor:classOrMethod name. |
|
2482 |
] ifFalse:[ |
|
2483 |
self generateMethodDocReferenceFor:classOrMethod selector inClass:classOrMethod mclass name text:classOrMethod selector autoloading:nil. |
|
2484 |
]. |
|
4108 | 2485 |
outStream nextPutAll:'<tab indent=300>'. |
4106 | 2486 |
outStream nextPutLine:ctx. |
2487 |
outStream nextPutLine:'</li>'. |
|
2488 |
]. |
|
2489 |
]. |
|
2490 |
outStream nextPutLine:'</ul></dd>'. |
|
2491 |
outStream nextPutLine:'</dl>'. |
|
2492 |
||
2493 |
self generateBODYandHTMLEnd. |
|
2494 |
^ outStream contents |
|
2495 |
! |
|
2496 |
||
2017 | 2497 |
htmlPackageDocOf:packageID |
2498 |
|classes| |
|
2499 |
||
2500 |
classes := Smalltalk allClassesInPackage:packageID. |
|
2501 |
classes := classes reject:[:cls | cls isPrivate]. |
|
2502 |
^ self htmlClasses: classes title:'Classes in package ',packageID backTo:nil |
|
2503 |
! |
|
2504 |
||
2018 | 2505 |
htmlPackageList |
4122 | 2506 |
"generate an HTML string for a list of all packages in the system" |
2507 |
||
2508 |
^ self |
|
2509 |
htmlPackageListFor:(Smalltalk allPackageIDs) |
|
2510 |
withDocumentation:true "/ false |
|
2511 |
||
2512 |
" |
|
2513 |
self new |
|
2514 |
generateDocumentForOfflineReading:true; |
|
2515 |
htmlPackageList. |
|
2516 |
" |
|
2517 |
! |
|
2518 |
||
2519 |
htmlPackageListFor:packageNames withDocumentation:withDocumentation |
|
2520 |
"generate an HTML string for a given list of packages" |
|
2018 | 2521 |
|
2522 |
|s| |
|
2523 |
||
2524 |
s := outStream := '' writeStream. |
|
2525 |
||
2526 |
self generateHTMLHeadWithTitle:'Package Index'. |
|
2527 |
self generateBODYStart. |
|
2528 |
||
2529 |
self generateUpArrowButtonForTop. |
|
2530 |
self generateHorizontalLine. |
|
2531 |
self generateH1:'Package Index'. |
|
2532 |
s nextPutLine:'<ul>'. |
|
2533 |
||
4122 | 2534 |
packageNames |
2018 | 2535 |
do:[:p | |
2536 |
|pckgString| |
|
2537 |
||
3644 | 2538 |
(p startsWith:'__') ifFalse:[ |
2539 |
s nextPutAll:'<li>'. |
|
2540 |
pckgString := self withSpecialHTMLCharactersEscaped:p. |
|
2541 |
self generateDocumentForOfflineReading ifTrue:[ |
|
2542 |
s nextPutLine:(self |
|
2543 |
anchorFor: |
|
2544 |
((p copyReplaceAll:$: with:$/) , '/index.html' ) |
|
2545 |
info: |
|
2546 |
('Classes in Package: ' , pckgString) |
|
2547 |
text: |
|
2548 |
pckgString |
|
2549 |
name:nil). |
|
2550 |
] ifFalse:[ |
|
2551 |
s nextPutLine:(self |
|
2552 |
anchorForHTMLDocAction: |
|
2553 |
('htmlPackageDocOf:''' , pckgString , '''' ) |
|
2554 |
info: |
|
2555 |
('Classes in Package: ' , pckgString) |
|
2556 |
text: |
|
2557 |
pckgString). |
|
2558 |
]. |
|
2559 |
]. |
|
2018 | 2560 |
]. |
2561 |
||
2562 |
s nextPutLine:'</ul>'. |
|
2563 |
self generateBODYandHTMLEnd. |
|
2564 |
||
2565 |
^ s contents |
|
3644 | 2566 |
|
2567 |
" |
|
2568 |
self new |
|
2569 |
generateDocumentForOfflineReading:true; |
|
2570 |
htmlPackageList. |
|
2571 |
" |
|
2018 | 2572 |
! |
2573 |
||
2016 | 2574 |
htmlSelectorList |
2575 |
"generate an HTML string for all selectors (for which methods exist) |
|
2576 |
in the system" |
|
2577 |
||
2578 |
|selectors| |
|
2579 |
||
2580 |
selectors := IdentitySet new. |
|
2581 |
Smalltalk allClassesAndMetaclassesDo:[:cls | |
|
2582 |
selectors addAll:cls selectors. |
|
2583 |
]. |
|
2584 |
selectors := selectors asOrderedCollection sort. |
|
2585 |
||
2586 |
^ self |
|
2587 |
htmlSelectors:selectors |
|
2588 |
title:('All Selectors:'). |
|
2589 |
||
2590 |
" |
|
2591 |
self htmlSelectorList |
|
2592 |
" |
|
2593 |
||
2594 |
"Created: / 22.4.1996 / 20:03:31 / cg" |
|
2595 |
"Modified: / 5.6.1996 / 12:27:09 / stefan" |
|
2596 |
"Modified: / 30.10.1997 / 13:25:19 / cg" |
|
2597 |
! |
|
2598 |
||
2599 |
htmlSelectorListMatching:pattern |
|
2600 |
"generate an HTML string for all selectors which match a pattern |
|
2601 |
(and for which methods exist) in the system" |
|
2602 |
||
2603 |
|selectors| |
|
2604 |
||
2605 |
selectors := IdentitySet new. |
|
2606 |
Smalltalk allClassesAndMetaclassesDo:[:cls | |
|
2607 |
cls methodDictionary keysDo:[:sel | |
|
2608 |
(pattern match:sel) ifTrue:[ |
|
2609 |
selectors add:sel. |
|
2610 |
] |
|
2611 |
] |
|
2612 |
]. |
|
2613 |
selectors := selectors asOrderedCollection sort. |
|
2614 |
||
2615 |
^ self |
|
2616 |
htmlSelectors:selectors |
|
2617 |
title:('Selectors matching ''' , pattern , ''':'). |
|
2618 |
||
2619 |
" |
|
2620 |
self htmlSelectorListMatching:'*do*' |
|
2621 |
" |
|
2622 |
||
2623 |
"Created: / 22.4.1996 / 20:03:31 / cg" |
|
2624 |
"Modified: / 5.6.1996 / 12:29:27 / stefan" |
|
2625 |
"Modified: / 30.10.1997 / 13:25:50 / cg" |
|
2626 |
! |
|
2627 |
||
2628 |
htmlSelectorListPrefix:prefix |
|
2629 |
"generate an HTML string for all selectors whose names starts with |
|
2630 |
a prefix (and for which methods exist) in the system" |
|
2631 |
||
2632 |
|selectors| |
|
2633 |
||
2634 |
selectors := IdentitySet new. |
|
2635 |
Smalltalk allClassesAndMetaclassesDo:[:cls | |
|
2636 |
cls methodDictionary keysDo:[:sel | |
|
2637 |
(sel startsWith:prefix) ifTrue:[ |
|
2638 |
selectors add:sel. |
|
2639 |
] |
|
2640 |
] |
|
2641 |
]. |
|
2642 |
selectors := selectors asOrderedCollection sort. |
|
2643 |
||
2644 |
^ self |
|
2645 |
htmlSelectors:selectors |
|
2646 |
title:('Selectors starting with ''' , prefix asString , ''':'). |
|
2647 |
||
2648 |
" |
|
2649 |
self htmlSelectorListPrefix:'a' |
|
2650 |
" |
|
2651 |
||
2652 |
"Created: / 22.4.1996 / 20:03:31 / cg" |
|
2653 |
"Modified: / 5.6.1996 / 12:31:13 / stefan" |
|
2654 |
"Modified: / 30.10.1997 / 13:26:15 / cg" |
|
2655 |
! |
|
2656 |
||
2657 |
htmlSelectors:selectors title:title |
|
2658 |
"generate an HTML string for a given list of selectors" |
|
2659 |
||
2660 |
|s| |
|
2661 |
||
2662 |
s := outStream := '' writeStream. |
|
2663 |
||
2664 |
self generateHTMLHeadWithTitle:title. |
|
2665 |
self generateBODYStart. |
|
2666 |
||
2667 |
self generateUpArrowButtonForTop. |
|
2668 |
self generateHorizontalLine. |
|
2669 |
self generateH1:title. |
|
2670 |
s nextPutLine:'<ul>'. |
|
2671 |
||
2672 |
selectors do:[:sel | |
|
2673 |
|selString| |
|
2674 |
||
2675 |
selString := self withSpecialHTMLCharactersEscaped:sel. |
|
2676 |
s nextPutAll:'<li>'. |
|
2677 |
s nextPutLine:(self |
|
2678 |
anchorForHTMLDocAction: |
|
2679 |
('htmlDocOfImplementorsOf:''' , selString , '''' ) |
|
2680 |
info: |
|
2681 |
('Implementors of: ' , selString) |
|
2682 |
text: |
|
2683 |
selString). |
|
2684 |
]. |
|
2685 |
||
2686 |
s nextPutLine:'</ul>'. |
|
2687 |
self generateBODYandHTMLEnd. |
|
2688 |
||
2689 |
^ s contents |
|
2690 |
||
2691 |
"Created: / 22.4.1996 / 20:03:31 / cg" |
|
2692 |
"Modified: / 30.10.1997 / 13:26:34 / cg" |
|
478 | 2693 |
! ! |
2694 |
||
1265 | 2695 |
!HTMLDocGenerator methodsFor:'format conversion-man pages'! |
575 | 2696 |
|
2697 |
manPageFor:aCommand |
|
632 | 2698 |
"generate a (unix-) man page for a given command & convert the output to html" |
575 | 2699 |
|
2700 |
^ self |
|
2701 |
manPageFor:aCommand |
|
2702 |
inSection:nil |
|
2703 |
||
632 | 2704 |
"Modified: / 30.10.1997 / 13:29:31 / cg" |
575 | 2705 |
! |
2706 |
||
2707 |
manPageFor:aCommand inSection:sectionOrNil |
|
632 | 2708 |
"generate a (unix-) man page for some entry in a section |
575 | 2709 |
& convert the output to html" |
2710 |
||
2711 |
|manCmd| |
|
2712 |
||
2713 |
sectionOrNil isNil ifTrue:[ |
|
2714 |
manCmd := 'man ' , aCommand |
|
2715 |
] ifFalse:[ |
|
2716 |
manCmd := 'man ' , sectionOrNil printString , ' ' , aCommand |
|
2717 |
]. |
|
2718 |
^ self |
|
2719 |
manPageFor:aCommand |
|
2720 |
manCommand:manCmd. |
|
2721 |
||
632 | 2722 |
"Created: / 9.9.1996 / 17:45:08 / cg" |
2723 |
"Modified: / 30.10.1997 / 13:29:44 / cg" |
|
575 | 2724 |
! |
2725 |
||
2726 |
manPageFor:aCommand manCommand:manCommand |
|
577 | 2727 |
"convert man-command output to html. |
632 | 2728 |
Only the body of the text (without head../head and body../body) is generated" |
575 | 2729 |
|
1249 | 2730 |
|manPageStream text| |
575 | 2731 |
|
1249 | 2732 |
manPageStream := PipeStream readingFrom:manCommand. |
2733 |
manPageStream notNil ifTrue:[ |
|
2734 |
[ |
|
2735 |
text := self manPageFromStream:manPageStream. |
|
2736 |
] ensure:[ |
|
4117 | 2737 |
manPageStream abortAndClose. |
1249 | 2738 |
] |
575 | 2739 |
]. |
2740 |
||
1249 | 2741 |
text isEmptyOrNil ifTrue:[ |
2742 |
^ self noManPageForCommand:aCommand usingManCommand:manCommand. |
|
575 | 2743 |
]. |
2744 |
||
1249 | 2745 |
^ '<pre> |
2746 |
' , text , ' |
|
575 | 2747 |
</pre> |
2748 |
' |
|
2749 |
||
2750 |
" |
|
2751 |
self manPageFor:'cvs' |
|
2752 |
" |
|
2753 |
||
632 | 2754 |
"Modified: / 28.6.1996 / 21:28:47 / stefan" |
2755 |
"Created: / 9.9.1996 / 17:43:16 / cg" |
|
2756 |
"Modified: / 30.10.1997 / 13:30:22 / cg" |
|
575 | 2757 |
! |
2758 |
||
2759 |
manPageForFile:aFilename |
|
2760 |
"convert a .man file to html" |
|
2761 |
||
2762 |
^ self |
|
2763 |
manPageFor:aFilename asFilename name |
|
2764 |
manCommand:('nroff -man ' , aFilename asFilename pathName). |
|
2765 |
||
2766 |
" |
|
2767 |
self manPageForFile:'../../stc/stc.1' |
|
2768 |
" |
|
2769 |
" |
|
2770 |
HTMLDocumentView openFullOnText:(self manPageForFile:'../../stc/stc.1') |
|
2771 |
" |
|
2772 |
||
2773 |
"Modified: 4.4.1997 / 10:44:05 / cg" |
|
1249 | 2774 |
! |
2775 |
||
2776 |
manPageFromStream:manPageStream |
|
2777 |
"convert man-command output to html. |
|
2778 |
Only the body of the text (without head../head and body../body) is generated. |
|
2779 |
This method looks for |
|
2780 |
char-backspace-char -> bold |
|
2781 |
char-backspace-underline -> italic" |
|
2782 |
||
2783 |
|state ch keep| |
|
2784 |
||
2785 |
outStream := '' writeStream. |
|
2786 |
state := nil. |
|
2787 |
keep := nil. |
|
2788 |
[manPageStream atEnd] whileFalse:[ |
|
2789 |
ch := manPageStream next. |
|
2790 |
||
2791 |
ch notNil ifTrue:[ |
|
4197 | 2792 |
state isNil ifTrue:[ |
1249 | 2793 |
ch == Character backspace ifTrue:[ |
2794 |
state := #back |
|
2795 |
] ifFalse:[ |
|
2796 |
keep notNil ifTrue:[ |
|
2797 |
self nextPutAllEscaped:keep. |
|
2798 |
]. |
|
2799 |
keep := ch |
|
2800 |
] |
|
2801 |
] ifFalse:[ |
|
2802 |
state == #back ifTrue:[ |
|
2803 |
ch == keep ifTrue:[ |
|
2804 |
self nextPutBold:ch. |
|
2805 |
] ifFalse:[ |
|
2806 |
ch == $_ ifTrue:[ |
|
2807 |
keep notNil ifTrue:[ |
|
2808 |
self nextPutItalic:keep. |
|
2809 |
]. |
|
2810 |
] ifFalse:[ |
|
2811 |
keep == $_ ifTrue:[ |
|
2812 |
self nextPutItalic:ch. |
|
2813 |
] ifFalse:[ |
|
2814 |
keep notNil ifTrue:[ |
|
2815 |
self nextPutAllEscaped:keep. |
|
2816 |
self nextPutAllEscaped:ch. |
|
2817 |
]. |
|
2818 |
]. |
|
2819 |
]. |
|
2820 |
]. |
|
2821 |
state := keep := nil. |
|
2822 |
] |
|
2823 |
] |
|
2824 |
] |
|
2825 |
]. |
|
2826 |
||
2827 |
keep notNil ifTrue:[ |
|
2828 |
self nextPutAllEscaped:keep. |
|
2829 |
]. |
|
2830 |
^ outStream contents. |
|
2831 |
||
2832 |
" |
|
2833 |
HTMLDocGenerator new manPageFor:'cvs' |
|
2834 |
" |
|
2835 |
! |
|
2836 |
||
2837 |
noManPageForCommand:aCommand usingManCommand:manCommand |
|
2838 |
^ ' |
|
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
2839 |
No manual page for "<code><b>' , aCommand , '</b></code>" available. |
1249 | 2840 |
<BR> |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
2841 |
(The failed command was: "<code>' , manCommand , '"</code>.) |
1249 | 2842 |
'. |
575 | 2843 |
! ! |
2844 |
||
1249 | 2845 |
!HTMLDocGenerator methodsFor:'helpers'! |
2846 |
||
1257
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2847 |
anchorFor:href info:infoMessageOrNil text:text name:nameOrNil |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2848 |
|infoPart namePart| |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2849 |
|
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2850 |
infoPart := namePart := ''. |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2851 |
|
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2852 |
infoMessageOrNil notNil ifTrue:[ |
1332
8838fb9735b0
added an onMouseOver to generate info (does not work yet ?)
Claus Gittinger <cg@exept.de>
parents:
1331
diff
changeset
|
2853 |
infoPart := self infoParameterFor:infoMessageOrNil. |
1257
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2854 |
]. |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2855 |
nameOrNil notNil ifTrue:[ |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2856 |
namePart := 'NAME="' , nameOrNil , '" '. |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2857 |
]. |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2858 |
^ '<A HREF="' , href , '" ' |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2859 |
, namePart |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2860 |
, infoPart |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2861 |
, '>' , text |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2862 |
,'</A>'. |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2863 |
|
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2864 |
" |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2865 |
self new anchorFor:'foo' info:'bla' text:'text' name:nil |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2866 |
" |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2867 |
! |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
2868 |
|
1249 | 2869 |
anchorForHTMLAction:actionString info:infoMessageOrNil text:text |
1250 | 2870 |
^ self |
2871 |
anchorForHTMLAction:actionString |
|
2872 |
info:infoMessageOrNil |
|
2873 |
text:text |
|
2874 |
name:nil |
|
1249 | 2875 |
|
1250 | 2876 |
" |
2877 |
self new anchorForHTMLAction:'foo' info:'bla' text:'text' |
|
2878 |
" |
|
2879 |
! |
|
2880 |
||
2881 |
anchorForHTMLAction:actionString info:infoMessageOrNil text:text name:nameOrNil |
|
2882 |
|infoPart namePart| |
|
2883 |
||
2884 |
infoPart := namePart := ''. |
|
2885 |
||
1249 | 2886 |
infoMessageOrNil notNil ifTrue:[ |
1332
8838fb9735b0
added an onMouseOver to generate info (does not work yet ?)
Claus Gittinger <cg@exept.de>
parents:
1331
diff
changeset
|
2887 |
infoPart := self infoParameterFor:infoMessageOrNil. |
1249 | 2888 |
]. |
1250 | 2889 |
nameOrNil notNil ifTrue:[ |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
2890 |
namePart := 'name="' , nameOrNil , '" '. |
1250 | 2891 |
]. |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
2892 |
^ '<a href="' , self pathToTopOfDocumentation , '/misc/onlyInSTX2.html" ' |
1250 | 2893 |
, namePart |
1249 | 2894 |
, infoPart |
1250 | 2895 |
, 'ACTION="html:' |
1249 | 2896 |
, actionString |
2897 |
, '">' , text |
|
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
2898 |
,'</a>'. |
1249 | 2899 |
|
2900 |
" |
|
2901 |
self new anchorForHTMLAction:'foo' info:'bla' text:'text' |
|
2902 |
" |
|
2903 |
! |
|
2904 |
||
2905 |
anchorForHTMLDocAction:actionString info:infoMessageOrNil text:text |
|
2906 |
^ self |
|
1250 | 2907 |
anchorForHTMLDocAction:actionString |
2908 |
info:infoMessageOrNil |
|
2909 |
text:text |
|
2910 |
name:nil |
|
1249 | 2911 |
|
2912 |
" |
|
2913 |
self new anchorForHTMLDocAction:'foo' info:'bla' text:'text' |
|
2914 |
" |
|
2915 |
! |
|
2916 |
||
1250 | 2917 |
anchorForHTMLDocAction:actionString info:infoMessageOrNil text:text name:anchorName |
2918 |
^ self |
|
2919 |
anchorForHTMLAction:(self class name , ' ' , actionString) |
|
2920 |
info:infoMessageOrNil |
|
2921 |
text:text |
|
2922 |
name:anchorName |
|
2923 |
||
2924 |
" |
|
2925 |
self new anchorForHTMLDocAction:'foo' info:'bla' text:'text' name:'baz' |
|
2926 |
" |
|
2927 |
! |
|
2928 |
||
1249 | 2929 |
anchorForHTMLDocAction:actionString text:text |
2930 |
^ self anchorForHTMLDocAction:actionString info:nil text:text |
|
2931 |
||
2932 |
" |
|
2933 |
self new anchorForHTMLDocAction:'foo' text:'text' |
|
2934 |
" |
|
2935 |
! |
|
478 | 2936 |
|
3643 | 2937 |
findPathToTopOfDocumentation |
2938 |
<resource: #obsolete> |
|
2939 |
^ self class findPathToTopOfDocumentation |
|
2940 |
! |
|
2941 |
||
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2942 |
generateBODYEnd |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2943 |
generateBodyOnly == true ifFalse:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2944 |
outStream nextPutLine:'</body>'. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2945 |
] |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2946 |
! |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2947 |
|
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2948 |
generateBODYStart |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2949 |
generateBodyOnly == true ifFalse:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2950 |
outStream nextPutLine:'<body>'. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2951 |
] |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2952 |
! |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2953 |
|
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2954 |
generateBODYandHTMLEnd |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2955 |
self generateBODYEnd. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2956 |
self generateHTMLEnd. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2957 |
! |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2958 |
|
1328 | 2959 |
generateBackButton |
2960 |
|backHRef backLabel| |
|
2961 |
||
2962 |
backRef isNil ifTrue:[ |
|
2963 |
backHRef := self pathToLanguageTopOfDocumentation , '/TOP.html'. |
|
2964 |
backLabel := 'top'. |
|
2965 |
] ifFalse:[ |
|
2966 |
backHRef := backRef. |
|
2967 |
backLabel := 'back'. |
|
2968 |
]. |
|
2969 |
backCmd notNil ifTrue:[ |
|
2970 |
self |
|
2971 |
generateUpArrowButtonWithReference:backHRef |
|
2972 |
command:backCmd |
|
2973 |
imagePath:imagePath |
|
2974 |
altLabel:backLabel. |
|
2975 |
self generateHorizontalLine. |
|
2976 |
] ifFalse:[ |
|
2977 |
backHRef ~~ #none ifTrue:[ |
|
2978 |
self |
|
2979 |
generateUpArrowButtonWithReference:backHRef |
|
2980 |
command:nil |
|
2981 |
imagePath:imagePath |
|
2982 |
altLabel:backLabel. |
|
2983 |
self generateHorizontalLine. |
|
2984 |
] |
|
2985 |
]. |
|
2986 |
! |
|
2987 |
||
1250 | 2988 |
generateClassDocReferenceFor:className |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2989 |
self generateClassDocReferenceFor:className text:className |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2990 |
! |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2991 |
|
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
2992 |
generateClassDocReferenceFor:className text:text |
1337
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2993 |
self generateClassDocReferenceFor:className text:text autoloading:nil |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2994 |
! |
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2995 |
|
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2996 |
generateClassDocReferenceFor:className text:text autoloading:autoloadedClass |
2017 | 2997 |
"generates a link to a classes documentation" |
2998 |
||
1337
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2999 |
|href serviceLinkName action| |
1257
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3000 |
|
3643 | 3001 |
self generatingForSTXBrowser ifTrue:[ |
3002 |
action := self class name , ' htmlDocOf:' , className. |
|
3003 |
autoloadedClass notNil ifTrue:[ |
|
3004 |
action := autoloadedClass , ' autoload,', action. |
|
3005 |
]. |
|
3006 |
||
3007 |
href := self |
|
3008 |
anchorForHTMLAction:action |
|
3009 |
info:('Show documentation of ' , className ) |
|
3010 |
text:text. |
|
3011 |
] ifFalse:[ |
|
2017 | 3012 |
"/ page is generated for a real http service; |
3013 |
"/ generate a link to the services classDocOf page, |
|
3014 |
"/ Assumes that the server has a classDoc service running. |
|
1310 | 3015 |
httpRequestOrNil notNil ifTrue:[ |
3016 |
serviceLinkName := httpRequestOrNil serviceLinkName. |
|
3017 |
]. |
|
1257
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3018 |
href := self |
2002 | 3019 |
anchorFor:(serviceLinkName, '/classDocOf,', (HTMLUtilities escape:className) ) |
1257
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3020 |
info:('Show documentation of ' , className ) |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3021 |
text:text |
1257
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3022 |
name:nil |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3023 |
]. |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3024 |
|
1337
5d537c9b1326
references (related information)
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3025 |
outStream nextPutAll:href. |
1250 | 3026 |
! |
3027 |
||
1249 | 3028 |
generateH1:headerLine |
3029 |
outStream nextPutLine:'<h1>'. |
|
3030 |
outStream nextPutLine:headerLine. |
|
3031 |
outStream nextPutLine:'</h1>'. |
|
3032 |
! |
|
3033 |
||
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3034 |
generateHTMLEnd |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3035 |
generateBodyOnly == true ifFalse:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3036 |
outStream nextPutLine:'</html>' |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3037 |
] |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3038 |
! |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3039 |
|
1249 | 3040 |
generateHTMLHeadWithTitle:title |
3643 | 3041 |
|generatedByComment| |
3042 |
||
3043 |
generatedByComment := ('<!!-- generated by ' , self class name , ' ' , thisContext sender selector , ' -->'). |
|
3044 |
||
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3045 |
generateBodyOnly == true ifFalse:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3046 |
outStream |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3047 |
nextPutLine:'<!!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">'; |
3643 | 3048 |
nextPutLine:generatedByComment; |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3049 |
cr; |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3050 |
nextPutLine:'<html>'; |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3051 |
nextPutLine:'<head>'; |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3052 |
nextPutLine:'<title>'; |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3053 |
nextPutLine:title; |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3054 |
nextPutLine:'</title>'; |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3055 |
nextPutLine:'</head>'; |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3056 |
cr. |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3057 |
] ifTrue:[ |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3058 |
outStream |
3643 | 3059 |
nextPutLine:generatedByComment |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3060 |
]. |
1249 | 3061 |
! |
3062 |
||
3063 |
generateHorizontalLine |
|
3064 |
outStream nextPutLine:'<hr>'. |
|
3065 |
! |
|
3066 |
||
4127 | 3067 |
generateMethodDocReferenceFor:selector inClass:className text:text autoloading:autoloadedClass |
3068 |
"generates a link to a classes documentation" |
|
3069 |
||
3070 |
|href serviceLinkName action| |
|
3071 |
||
3072 |
self generatingForSTXBrowser ifTrue:[ |
|
3073 |
action := self class name , ' htmlDocOf:' , className. |
|
3074 |
autoloadedClass notNil ifTrue:[ |
|
3075 |
action := autoloadedClass , ' autoload,', action. |
|
3076 |
]. |
|
3077 |
||
3078 |
href := self |
|
3079 |
anchorForHTMLAction:action |
|
3080 |
info:('Show documentation of ' , className ) |
|
3081 |
text:text. |
|
3082 |
] ifFalse:[ |
|
3083 |
"/ page is generated for a real http service; |
|
3084 |
"/ generate a link to the services classDocOf page, |
|
3085 |
"/ Assumes that the server has a classDoc service running. |
|
3086 |
httpRequestOrNil notNil ifTrue:[ |
|
3087 |
serviceLinkName := httpRequestOrNil serviceLinkName. |
|
3088 |
]. |
|
3089 |
href := self |
|
3090 |
anchorFor:(serviceLinkName, '/classDocOf,', (HTMLUtilities escape:className) ) |
|
3091 |
info:('Show documentation of ' , className ) |
|
3092 |
text:text |
|
3093 |
name:nil |
|
3094 |
]. |
|
3095 |
||
3096 |
outStream nextPutAll:href. |
|
3097 |
! |
|
3098 |
||
2017 | 3099 |
generatePackageDocReferenceFor:packageID text:text |
3100 |
"generates a link to a package documentation" |
|
3101 |
||
3102 |
|href serviceLinkName action| |
|
3103 |
||
3104 |
self generatingForSTXBrowser ifFalse:[ |
|
3644 | 3105 |
self generateDocumentForOfflineReading ifTrue:[ |
3106 |
href := self |
|
3107 |
anchorFor:(pathToTopOfDocumentation, '/packages/', (HTMLUtilities escape:packageID) ) |
|
3108 |
info:('Show documentation of package ' , packageID ) |
|
3109 |
text:text |
|
3110 |
name:nil |
|
3111 |
] ifFalse:[ |
|
3112 |
"/ page is generated for a real http service; |
|
3113 |
"/ generate a link to the services packageDocOf page, |
|
3114 |
"/ Assumes that the server has a classDoc service running. |
|
3115 |
httpRequestOrNil notNil ifTrue:[ |
|
3116 |
serviceLinkName := httpRequestOrNil serviceLinkName. |
|
3117 |
]. |
|
3118 |
href := self |
|
3119 |
anchorFor:(serviceLinkName, '/classListForPackage,', (HTMLUtilities escape:packageID) ) |
|
3120 |
info:('Show documentation of package ' , packageID ) |
|
3121 |
text:text |
|
3122 |
name:nil |
|
3123 |
] |
|
2017 | 3124 |
] ifTrue:[ |
3125 |
action := self class name , ' htmlPackageDocOf: #''' , packageID, ''''. |
|
3126 |
href := self |
|
3127 |
anchorForHTMLAction:action |
|
3128 |
info:('Show documentation of package ' , packageID ) |
|
3129 |
text:text. |
|
3130 |
]. |
|
3131 |
||
3132 |
outStream nextPutAll:href. |
|
3133 |
! |
|
3134 |
||
1249 | 3135 |
generateUpArrowButtonForTop |
3644 | 3136 |
|top| |
3137 |
||
3138 |
self generateDocumentForOfflineReading ifTrue:[ |
|
3139 |
top := '../index.html'. |
|
3140 |
] ifFalse:[ |
|
3141 |
top := (self pathToLanguageTopOfDocumentation , '/TOP.html'). |
|
3142 |
]. |
|
3143 |
||
1249 | 3144 |
self |
3644 | 3145 |
generateUpArrowButtonWithReference:top |
1249 | 3146 |
command:nil |
3147 |
imagePath:nil |
|
3148 |
altLabel:'top' |
|
3149 |
! |
|
3150 |
||
3151 |
generateUpArrowButtonWithReference:backHRef command:backCmd imagePath:imagePath altLabel:altLabel |
|
1255 | 3152 |
|p| |
3153 |
||
3999 | 3154 |
self showUpButton ifFalse:[^ self]. |
3155 |
||
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
3156 |
outStream nextPutAll:'<a class="noprint" href="' , backHRef , '"'. |
1249 | 3157 |
backCmd notNil ifTrue:[ |
3158 |
outStream nextPutAll:' action="html:' , self class name , ' ' , backCmd , '"'. |
|
3159 |
]. |
|
1255 | 3160 |
p := imagePath. |
3161 |
p isNil ifTrue:[ |
|
3162 |
p := self pathToTopOfDocumentation , '/icons' |
|
3163 |
]. |
|
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
3164 |
outStream nextPutLine:'><img src="' , p , '/DocsUpArrow.gif" alt="[' , (altLabel ? 'back') , ']"></a>'. |
1249 | 3165 |
! |
3166 |
||
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3167 |
generatingForSTXBrowser |
3643 | 3168 |
self generateDocumentForOfflineReading ifTrue:[^ false]. |
1258
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3169 |
^ httpRequestOrNil isNil |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3170 |
! |
2efcd7c46179
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1257
diff
changeset
|
3171 |
|
1332
8838fb9735b0
added an onMouseOver to generate info (does not work yet ?)
Claus Gittinger <cg@exept.de>
parents:
1331
diff
changeset
|
3172 |
infoParameterFor:infoMessageOrNil |
8838fb9735b0
added an onMouseOver to generate info (does not work yet ?)
Claus Gittinger <cg@exept.de>
parents:
1331
diff
changeset
|
3173 |
infoMessageOrNil isNil ifTrue:[^ '']. |
8838fb9735b0
added an onMouseOver to generate info (does not work yet ?)
Claus Gittinger <cg@exept.de>
parents:
1331
diff
changeset
|
3174 |
|
1333 | 3175 |
^ |
1332
8838fb9735b0
added an onMouseOver to generate info (does not work yet ?)
Claus Gittinger <cg@exept.de>
parents:
1331
diff
changeset
|
3176 |
'ONMOUSEOVER="window.status=''',infoMessageOrNil,'''; return true" ' , |
1923
57fbb3e512e3
generate valid HTML 4.01 transitional
Stefan Vogel <sv@exept.de>
parents:
1896
diff
changeset
|
3177 |
'ONMOUSEOUT="window.status='' ''; return true" ' |
1332
8838fb9735b0
added an onMouseOver to generate info (does not work yet ?)
Claus Gittinger <cg@exept.de>
parents:
1331
diff
changeset
|
3178 |
! |
8838fb9735b0
added an onMouseOver to generate info (does not work yet ?)
Claus Gittinger <cg@exept.de>
parents:
1331
diff
changeset
|
3179 |
|
1308
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3180 |
methodCommentOf:aMethod |
3625 | 3181 |
"extract the very first comment from the method" |
3182 |
||
1308
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3183 |
|comment mClass mSel parseTree matcher| |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3184 |
|
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3185 |
comment := aMethod comment. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3186 |
comment notNil ifTrue:[^ comment]. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3187 |
|
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3188 |
mClass := aMethod mclass. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3189 |
mClass isNil ifTrue:[^ nil]. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3190 |
|
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3191 |
mSel := aMethod selector. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3192 |
mSel isNil ifTrue:[^ nil]. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3193 |
|
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3194 |
"/ generate a comment if its a getter, setter or similar |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3195 |
ParseTreeSearcher notNil ifTrue:[ |
1336 | 3196 |
aMethod messagesSent isEmpty ifTrue:[ |
1351 | 3197 |
parseTree := mClass parseTreeFor:mSel. |
3198 |
parseTree notNil ifTrue: [ |
|
3199 |
(mClass allInstanceVariableNames) do:[:eachVar | |
|
1336 | 3200 |
matcher := ParseTreeSearcher getterMethod:eachVar. |
1979 | 3201 |
(matcher executeTree: parseTree initialAnswer:false) ifTrue:[ |
1336 | 3202 |
^ 'Return the instance variable ' , eachVar, '.'. |
3203 |
]. |
|
1351 | 3204 |
|
1336 | 3205 |
matcher := ParseTreeSearcher setterMethod:eachVar. |
1979 | 3206 |
(matcher executeTree: parseTree initialAnswer:false) ifTrue:[ |
1336 | 3207 |
^ 'Set the instance variable ' , eachVar, '.'. |
3208 |
]. |
|
1308
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3209 |
]. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3210 |
]. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3211 |
]. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3212 |
]. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3213 |
|
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3214 |
"/ (mSuperClass := mClass superclass) notNil ifTrue:[ |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3215 |
"/self halt. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3216 |
"/ ]. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3217 |
|
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3218 |
^ nil. |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3219 |
! |
08d6a08eee80
reflection to generate the comment for getters/setters
Claus Gittinger <cg@exept.de>
parents:
1289
diff
changeset
|
3220 |
|
3625 | 3221 |
methodExampleCommentsOf:aMethod |
3222 |
"extract the very last comment from the method" |
|
3223 |
||
3224 |
|comments partOfSelector| |
|
3225 |
||
3226 |
comments := aMethod parserClass methodCommentsFromSource:aMethod source. |
|
3227 |
comments size <= 1 ifTrue:[^ nil]. |
|
3228 |
||
3229 |
"/ look for comments which make up valid source code in the method's language |
|
3230 |
||
3231 |
partOfSelector := aMethod selector. |
|
3232 |
(partOfSelector includes:$:) ifTrue:[ |
|
3233 |
partOfSelector := partOfSelector copyTo:(partOfSelector indexOf:$:) |
|
3234 |
]. |
|
3235 |
comments := (comments from:2) |
|
3236 |
select:[:each | |
|
3237 |
(each includesString:partOfSelector) |
|
3238 |
and:[ |
|
3239 |
|rslt| |
|
3240 |
||
3241 |
rslt := [ aMethod parserClass parseExpression:each ] on:Error do:#Error. |
|
3242 |
rslt ~~ #Error. |
|
3243 |
]. |
|
3244 |
]. |
|
3245 |
^ comments. |
|
3246 |
! |
|
3247 |
||
1249 | 3248 |
nextPutAllEscaped:aStringOrCharacter |
3249 |
outStream nextPutAll:(self withSpecialHTMLCharactersEscaped:aStringOrCharacter) |
|
3250 |
! |
|
3251 |
||
3252 |
nextPutBold:aStringOrCharacter |
|
3253 |
outStream nextPutAll:'<b>'. |
|
3254 |
self nextPutAllEscaped:aStringOrCharacter. |
|
3255 |
outStream nextPutAll:'</b>'. |
|
3256 |
! |
|
3257 |
||
3258 |
nextPutItalic:aStringOrCharacter |
|
3259 |
outStream nextPutAll:'<i>'. |
|
3260 |
self nextPutAllEscaped:aStringOrCharacter. |
|
3261 |
outStream nextPutAll:'</i>'. |
|
3262 |
! |
|
3263 |
||
1974 | 3264 |
shownSubclassesOf:aClass |
3265 |
|subs| |
|
3266 |
||
3267 |
subs := aClass subclasses. |
|
3268 |
subs := subs select:[:cls | |def| |
|
2205
6a7e8629edd5
changed: #shownSubclassesOf:
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
3269 |
def := cls projectDefinitionClass. |
1974 | 3270 |
def isNil or:[def showClassDocumentationOf:cls]]. |
3271 |
subs := subs asOrderedCollection sort:[:a :b | a name < b name]. |
|
3272 |
^ subs |
|
3273 |
||
3274 |
"Created: / 05-11-2007 / 17:22:27 / cg" |
|
3275 |
! |
|
3276 |
||
1249 | 3277 |
withSpecialHTMLCharactersEscaped:aStringOrCharacter |
3915 | 3278 |
|string| |
3279 |
||
3280 |
string := aStringOrCharacter isString ifTrue:[aStringOrCharacter] ifFalse:[aStringOrCharacter asString]. |
|
3281 |
^ HTMLUtilities escapeCharacterEntities:string |
|
1249 | 3282 |
|
3283 |
" |
|
3284 |
self new withSpecialHTMLCharactersEscaped:'foo>' |
|
3285 |
self new withSpecialHTMLCharactersEscaped:$< |
|
3286 |
self new withSpecialHTMLCharactersEscaped:$A |
|
3287 |
" |
|
2327
99495bed5445
changed: #withSpecialHTMLCharactersEscaped:
Claus Gittinger <cg@exept.de>
parents:
2252
diff
changeset
|
3288 |
|
99495bed5445
changed: #withSpecialHTMLCharactersEscaped:
Claus Gittinger <cg@exept.de>
parents:
2252
diff
changeset
|
3289 |
"Modified: / 13-04-2011 / 23:11:16 / cg" |
478 | 3290 |
! ! |
3291 |
||
1255 | 3292 |
!HTMLDocGenerator methodsFor:'pathnames'! |
3293 |
||
1257
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3294 |
pathToDocumentationFile:relativeHref |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3295 |
|top| |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3296 |
|
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3297 |
top := self pathToLanguageTopOfDocumentation. |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3298 |
(top asFilename construct:relativeHref) exists ifTrue:[ |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3299 |
"unix format: used as URL" |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3300 |
^ top , '/' , relativeHref |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3301 |
]. |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3302 |
^ self pathToEnglishTopOfDocumentation , '/' , relativeHref |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3303 |
! |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3304 |
|
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3305 |
pathToEnglishTopOfDocumentation |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3306 |
"/ always unix-name convention (used as an URL) |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3307 |
^ self pathToTopOfDocumentation , '/english' |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3308 |
! |
af5c892477b7
classDocGeneration for webServer
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
3309 |
|
1255 | 3310 |
pathToLanguageTopOfDocumentation |
3311 |
|languageSpecificDocDirectory fn| |
|
3312 |
||
3313 |
pathToLanguageTopOfDocumentation isNil ifTrue:[ |
|
3314 |
pathToLanguageTopOfDocumentation := self pathToTopOfDocumentation. |
|
3315 |
languageSpecificDocDirectory := self class languageSpecificDocDirectory. |
|
3316 |
fn := pathToLanguageTopOfDocumentation asFilename construct:languageSpecificDocDirectory. |
|
3317 |
(fn exists and:[fn isDirectory]) ifTrue:[ |
|
3318 |
"/ always unix-name convention (used as an URL) |
|
3319 |
pathToLanguageTopOfDocumentation := pathToLanguageTopOfDocumentation , '/' , languageSpecificDocDirectory. |
|
3320 |
]. |
|
3321 |
]. |
|
3322 |
^ pathToLanguageTopOfDocumentation |
|
3323 |
! |
|
3324 |
||
3325 |
pathToTopOfDocumentation |
|
3326 |
pathToTopOfDocumentation isNil ifTrue:[ |
|
3643 | 3327 |
pathToTopOfDocumentation := self class findPathToTopOfDocumentation |
1255 | 3328 |
]. |
3329 |
^ pathToTopOfDocumentation |
|
3330 |
! ! |
|
3331 |
||
498 | 3332 |
!HTMLDocGenerator class methodsFor:'documentation'! |
478 | 3333 |
|
3334 |
version |
|
3915 | 3335 |
^ '$Header$' |
2178
af7b05dfeaae
changed: #languageSpecificDocDirectory
Claus Gittinger <cg@exept.de>
parents:
2055
diff
changeset
|
3336 |
! |
af7b05dfeaae
changed: #languageSpecificDocDirectory
Claus Gittinger <cg@exept.de>
parents:
2055
diff
changeset
|
3337 |
|
af7b05dfeaae
changed: #languageSpecificDocDirectory
Claus Gittinger <cg@exept.de>
parents:
2055
diff
changeset
|
3338 |
version_CVS |
3915 | 3339 |
^ '$Header$' |
478 | 3340 |
! ! |
3232
de4bd4dcb49f
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
2865
diff
changeset
|
3341 |