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