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