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