changeset 1258 | 2efcd7c46179 |
parent 1257 | af5c892477b7 |
child 1260 | 42e4284bf0ca |
1257:af5c892477b7 | 1258:2efcd7c46179 |
---|---|
14 |
14 |
15 "{ Package: 'stx:libhtml' }" |
15 "{ Package: 'stx:libhtml' }" |
16 |
16 |
17 Object subclass:#HTMLDocGenerator |
17 Object subclass:#HTMLDocGenerator |
18 instanceVariableNames:'outStream pathToTopOfDocumentation |
18 instanceVariableNames:'outStream pathToTopOfDocumentation |
19 pathToLanguageTopOfDocumentation httpRequestOrNil' |
19 pathToLanguageTopOfDocumentation httpRequestOrNil |
20 generateBodyOnly' |
|
20 classVariableNames:'' |
21 classVariableNames:'' |
21 poolDictionaries:'' |
22 poolDictionaries:'' |
22 category:'System-Documentation' |
23 category:'System-Documentation' |
23 ! |
24 ! |
24 |
25 |
227 " |
228 " |
228 ! ! |
229 ! ! |
229 |
230 |
230 !HTMLDocGenerator methodsFor:'accessing'! |
231 !HTMLDocGenerator methodsFor:'accessing'! |
231 |
232 |
233 generateBodyOnly:something |
|
234 "set the value of the instance variable 'generateBodyOnly' (automatically generated)" |
|
235 |
|
236 generateBodyOnly := something. |
|
237 ! |
|
238 |
|
232 httpRequest:aRequest |
239 httpRequest:aRequest |
233 httpRequestOrNil := aRequest. |
240 httpRequestOrNil := aRequest. |
234 ! |
241 ! |
235 |
242 |
236 pathToLanguageTopOfDocumentation:something |
243 pathToLanguageTopOfDocumentation:something |
244 |
251 |
245 pathToTopOfDocumentation := something. |
252 pathToTopOfDocumentation := something. |
246 ! ! |
253 ! ! |
247 |
254 |
248 !HTMLDocGenerator methodsFor:'document generation'! |
255 !HTMLDocGenerator methodsFor:'document generation'! |
256 |
|
257 generateExampleEnd |
|
258 self generatingForSTXBrowser ifFalse:[ |
|
259 outStream nextPutLine:'</font>'. |
|
260 ^ self |
|
261 ]. |
|
262 outStream nextPutLine:'</a>'. |
|
263 ! |
|
264 |
|
265 generateExampleStart |
|
266 self generatingForSTXBrowser ifFalse:[ |
|
267 outStream nextPutLine:'<font color=#7F0000>'. |
|
268 ^ self |
|
269 ]. |
|
270 outStream nextPutLine:'<a INFO="execute the example" type="example" showresult>'. |
|
271 ! |
|
272 |
|
273 generateExamples:examples |
|
274 |inExample| |
|
275 |
|
276 inExample := false. |
|
277 outStream nextPutLine:'<h2><a name="EXAMPLES" href="#I_EXAMPLES">Examples:</A></h2>'. |
|
278 outStream nextPutLine:'<BR>'. |
|
279 outStream nextPutLine:'<code><pre>'. |
|
280 examples do:[:line | |
|
281 line withoutSeparators = '[exBegin]' ifTrue:[ |
|
282 inExample ifTrue:[ |
|
283 self generateExampleEnd. |
|
284 ]. |
|
285 self generateExampleStart. |
|
286 inExample := true. |
|
287 ] ifFalse:[ |
|
288 line withoutSeparators = '[exEnd]' ifTrue:[ |
|
289 inExample ifTrue:[ |
|
290 self generateExampleEnd. |
|
291 ]. |
|
292 inExample := false. |
|
293 ] ifFalse:[ |
|
294 outStream nextPutLine:line |
|
295 ] |
|
296 ]. |
|
297 ]. |
|
298 inExample ifTrue:[ |
|
299 self generateExampleEnd. |
|
300 ]. |
|
301 outStream nextPutLine:'</pre></code>'. |
|
302 self generateHorizontalLine. |
|
303 ! |
|
249 |
304 |
250 htmlClassCategoryList |
305 htmlClassCategoryList |
251 "generate a formatted list of all available class categories as |
306 "generate a formatted list of all available class categories as |
252 an HTML string. Each category will be a hyperlink to another |
307 an HTML string. Each category will be a hyperlink to another |
253 autogenerated page, containing the classes per category. |
308 autogenerated page, containing the classes per category. |
261 |
316 |
262 outStream := s := '' writeStream. |
317 outStream := s := '' writeStream. |
263 |
318 |
264 self generateHTMLHeadWithTitle:'Class Categories:'. |
319 self generateHTMLHeadWithTitle:'Class Categories:'. |
265 |
320 |
266 s nextPutLine:'<body>'. |
321 self generateBODYStart. |
322 |
|
267 self generateUpArrowButtonForTop. |
323 self generateUpArrowButtonForTop. |
268 self generateHorizontalLine. |
324 self generateHorizontalLine. |
269 self generateH1:'Class Categories:'. |
325 self generateH1:'Class Categories:'. |
270 s nextPutLine:'<ul>'. |
326 s nextPutLine:'<ul>'. |
271 |
327 |
386 prev := nm. |
442 prev := nm. |
387 ]. |
443 ]. |
388 |
444 |
389 s nextPutAll:' |
445 s nextPutAll:' |
390 </ul> |
446 </ul> |
391 |
|
392 </body> |
|
393 </html> |
|
394 '. |
447 '. |
448 self generateBODYandHTMLEnd. |
|
395 |
449 |
396 ^ s contents |
450 ^ s contents |
397 |
451 |
398 " |
452 " |
399 HTMLDocGenerator new htmlClassCategoryList |
453 HTMLDocGenerator new htmlClassCategoryList |
479 self generateClassDocReferenceFor:className. |
533 self generateClassDocReferenceFor:className. |
480 ]. |
534 ]. |
481 |
535 |
482 s nextPutAll:' |
536 s nextPutAll:' |
483 </ul> |
537 </ul> |
484 </body> |
|
485 </html> |
|
486 '. |
538 '. |
539 self generateBODYandHTMLEnd. |
|
487 |
540 |
488 ^ s contents |
541 ^ s contents |
489 |
542 |
490 "Created: / 23.4.1996 / 15:31:55 / cg" |
543 "Created: / 23.4.1996 / 15:31:55 / cg" |
491 "Modified: / 30.10.1997 / 13:21:32 / cg" |
544 "Modified: / 30.10.1997 / 13:21:32 / cg" |
810 ]. |
863 ]. |
811 |
864 |
812 outStream := s := '' writeStream. |
865 outStream := s := '' writeStream. |
813 |
866 |
814 self generateHTMLHeadWithTitle:('Class: ' , className). |
867 self generateHTMLHeadWithTitle:('Class: ' , className). |
815 |
868 self generateBODYStart. |
816 s nextPutLine:'<body>'. |
|
817 |
869 |
818 backRef isNil ifTrue:[ |
870 backRef isNil ifTrue:[ |
819 backHRef := self pathToLanguageTopOfDocumentation , '/TOP.html'. |
871 backHRef := self pathToLanguageTopOfDocumentation , '/TOP.html'. |
820 backLabel := 'top'. |
872 backLabel := 'top'. |
821 ] ifFalse:[ |
873 ] ifFalse:[ |
1155 |nm| |
1207 |nm| |
1156 |
1208 |
1157 nm := cls name. |
1209 nm := cls name. |
1158 s nextPutAll:' '. |
1210 s nextPutAll:' '. |
1159 cls isLoaded ifFalse:[ |
1211 cls isLoaded ifFalse:[ |
1160 s nextPutLine:(self |
1212 self |
1161 anchorForHTMLAction: |
1213 generateClassDocReferenceFor:nm |
1162 (nm , ' autoload. ',self class name,' htmlDocOf:' , nm ) |
1214 text:nm |
1163 info: |
1215 autoloading:nm |
1164 ( 'Show documentation of ' , nm ) |
|
1165 text: |
|
1166 nm). |
|
1167 ] ifTrue:[ |
1216 ] ifTrue:[ |
1168 self generateClassDocReferenceFor:nm. |
1217 self generateClassDocReferenceFor:nm. |
1169 ]. |
1218 ]. |
1170 ]. |
1219 ]. |
1171 s nextPutLine:'</pre>'. |
1220 s nextPutLine:'</pre>'. |
1184 nm := cls nameWithoutPrefix. |
1233 nm := cls nameWithoutPrefix. |
1185 fullName := cls name. |
1234 fullName := cls name. |
1186 s nextPutAll:' '. |
1235 s nextPutAll:' '. |
1187 (cls owningClass isLoaded not |
1236 (cls owningClass isLoaded not |
1188 or:[cls owningClass wasAutoloaded]) ifTrue:[ |
1237 or:[cls owningClass wasAutoloaded]) ifTrue:[ |
1189 s nextPutLine:(self |
1238 self |
1190 anchorForHTMLAction: |
1239 generateClassDocReferenceFor:fullName |
1191 (cls owningClass name , ' autoload. ',self class name,' htmlDocOf:' , fullName ) |
1240 text:nm |
1192 info: |
1241 autoloading:cls owningClass name |
1193 ( 'Show documentation of ' , fullName ) |
|
1194 text: |
|
1195 nm). |
|
1196 ] ifFalse:[ |
1242 ] ifFalse:[ |
1197 self generateClassDocReferenceFor:fullName text:nm. |
1243 self generateClassDocReferenceFor:fullName text:nm. |
1198 ]. |
1244 ]. |
1199 ]. |
1245 ]. |
1200 s nextPutLine:'</pre>'. |
1246 s nextPutLine:'</pre>'. |
1219 |
1265 |
1220 "/ |
1266 "/ |
1221 "/ add examples if there are any |
1267 "/ add examples if there are any |
1222 "/ |
1268 "/ |
1223 examples notNil ifTrue:[ |
1269 examples notNil ifTrue:[ |
1224 s nextPutLine:'<h2><a name="EXAMPLES" href="#I_EXAMPLES">Examples:</A></h2>'. |
1270 self generateExamples:examples. |
1225 s nextPutLine:'<BR>'. |
1271 ]. |
1226 s nextPutLine:'<code><pre>'. |
1272 |
1227 examples do:[:line | |
1273 self generateBODYandHTMLEnd. |
1228 line withoutSeparators = '[exBegin]' ifTrue:[ |
|
1229 s nextPutLine:'<a INFO="execute the example" type="example" showresult>'. |
|
1230 ] ifFalse:[ |
|
1231 line withoutSeparators = '[exEnd]' ifTrue:[ |
|
1232 s nextPutLine:'</a>'. |
|
1233 ] ifFalse:[ |
|
1234 s nextPutLine:line |
|
1235 ] |
|
1236 ]. |
|
1237 ]. |
|
1238 s nextPutLine:'</pre></code>'. |
|
1239 self generateHorizontalLine. |
|
1240 ]. |
|
1241 |
|
1242 |
|
1243 s nextPutLine:'</body>'; nextPutLine:'</html>'. |
|
1244 |
1274 |
1245 wasLoaded ifFalse:[ |
1275 wasLoaded ifFalse:[ |
1246 aClass unload |
1276 aClass unload |
1247 ]. |
1277 ]. |
1248 |
1278 |
1277 sel := self withSpecialHTMLCharactersEscaped:selector. |
1307 sel := self withSpecialHTMLCharactersEscaped:selector. |
1278 |
1308 |
1279 outStream := s := '' writeStream. |
1309 outStream := s := '' writeStream. |
1280 |
1310 |
1281 self generateHTMLHeadWithTitle:('Implementations of: ' , sel). |
1311 self generateHTMLHeadWithTitle:('Implementations of: ' , sel). |
1282 s nextPutLine:'<body>'. |
1312 self generateBODYStart. |
1313 |
|
1283 self generateUpArrowButtonForTop. |
1314 self generateUpArrowButtonForTop. |
1284 self generateHorizontalLine. |
1315 self generateHorizontalLine. |
1285 self generateH1:sel. |
1316 self generateH1:sel. |
1286 |
1317 |
1287 s nextPutLine:'<dl>'. |
1318 s nextPutLine:'<dl>'. |
1306 classRef:true. |
1337 classRef:true. |
1307 s nextPutLine:'<p>'. |
1338 s nextPutLine:'<p>'. |
1308 ]. |
1339 ]. |
1309 |
1340 |
1310 s nextPutLine:'</dl>'. |
1341 s nextPutLine:'</dl>'. |
1311 s nextPutLine:'</body>'. |
1342 self generateBODYandHTMLEnd. |
1312 s nextPutLine:'</html>'. |
|
1313 |
1343 |
1314 ^ s contents |
1344 ^ s contents |
1315 |
1345 |
1316 "Created: / 22.4.1996 / 20:03:31 / cg" |
1346 "Created: / 22.4.1996 / 20:03:31 / cg" |
1317 "Modified: / 30.10.1998 / 22:15:30 / cg" |
1347 "Modified: / 30.10.1998 / 22:15:30 / cg" |
1406 |s| |
1436 |s| |
1407 |
1437 |
1408 s := outStream := '' writeStream. |
1438 s := outStream := '' writeStream. |
1409 |
1439 |
1410 self generateHTMLHeadWithTitle:title. |
1440 self generateHTMLHeadWithTitle:title. |
1411 |
1441 self generateBODYStart. |
1412 s nextPutLine:'<body>'. |
1442 |
1413 self generateUpArrowButtonForTop. |
1443 self generateUpArrowButtonForTop. |
1414 self generateHorizontalLine. |
1444 self generateHorizontalLine. |
1415 self generateH1:title. |
1445 self generateH1:title. |
1416 s nextPutLine:'<ul>'. |
1446 s nextPutLine:'<ul>'. |
1417 |
1447 |
1428 text: |
1458 text: |
1429 selString). |
1459 selString). |
1430 ]. |
1460 ]. |
1431 |
1461 |
1432 s nextPutLine:'</ul>'. |
1462 s nextPutLine:'</ul>'. |
1433 s nextPutLine:'</body>'. |
1463 self generateBODYandHTMLEnd. |
1434 s nextPutLine:'</html>'. |
|
1435 |
1464 |
1436 ^ s contents |
1465 ^ s contents |
1437 |
1466 |
1438 "Created: / 22.4.1996 / 20:03:31 / cg" |
1467 "Created: / 22.4.1996 / 20:03:31 / cg" |
1439 "Modified: / 30.10.1997 / 13:26:34 / cg" |
1468 "Modified: / 30.10.1997 / 13:26:34 / cg" |
2056 |
2085 |
2057 "Created: 25.4.1996 / 14:16:01 / cg" |
2086 "Created: 25.4.1996 / 14:16:01 / cg" |
2058 "Modified: 11.1.1997 / 13:03:38 / cg" |
2087 "Modified: 11.1.1997 / 13:03:38 / cg" |
2059 ! |
2088 ! |
2060 |
2089 |
2090 generateBODYEnd |
|
2091 generateBodyOnly == true ifFalse:[ |
|
2092 outStream nextPutLine:'</body>'. |
|
2093 ] |
|
2094 ! |
|
2095 |
|
2096 generateBODYStart |
|
2097 generateBodyOnly == true ifFalse:[ |
|
2098 outStream nextPutLine:'<body>'. |
|
2099 ] |
|
2100 ! |
|
2101 |
|
2102 generateBODYandHTMLEnd |
|
2103 self generateBODYEnd. |
|
2104 self generateHTMLEnd. |
|
2105 ! |
|
2106 |
|
2061 generateClassDocReferenceFor:className |
2107 generateClassDocReferenceFor:className |
2108 self generateClassDocReferenceFor:className text:className |
|
2109 ! |
|
2110 |
|
2111 generateClassDocReferenceFor:className text:text |
|
2062 |href| |
2112 |href| |
2063 |
2113 |
2064 httpRequestOrNil notNil ifTrue:[ |
2114 self generatingForSTXBrowser ifFalse:[ |
2065 href := self |
2115 href := self |
2066 anchorFor:('Server.classDocOf.', className ) |
2116 anchorFor:('Server.classDocOf.', className ) |
2067 info:('Show documentation of ' , className ) |
2117 info:('Show documentation of ' , className ) |
2068 text:className |
2118 text:text |
2069 name:nil |
2119 name:nil |
2070 ] ifFalse:[ |
2120 ] ifTrue:[ |
2071 href := self |
2121 href := self |
2072 anchorForHTMLDocAction: |
2122 anchorForHTMLDocAction: |
2073 ('htmlDocOf:', className ) |
2123 ('htmlDocOf:', className ) |
2074 info: |
2124 info: |
2075 ('Show documentation of ' , className ) |
2125 ('Show documentation of ' , className ) |
2076 text: |
2126 text: |
2077 className. |
2127 text. |
2078 ]. |
2128 ]. |
2079 |
2129 |
2080 outStream nextPutLine:href. |
2130 outStream nextPutLine:href. |
2081 ! |
2131 ! |
2082 |
2132 |
2083 generateClassDocReferenceFor:aClassName text:text |
2133 generateClassDocReferenceFor:className text:text autoloading:autoloadedClass |
2084 outStream |
2134 |href| |
2085 nextPutAll:(self |
2135 |
2086 anchorForHTMLDocAction: |
2136 self generatingForSTXBrowser ifFalse:[ |
2087 ('htmlDocOf:', aClassName ) |
2137 href := self |
2088 info: |
2138 anchorFor:('Server.classDocOf.', className ) |
2089 ( 'Show documentation of ' , aClassName ) |
2139 info:('Show documentation of ' , className ) |
2090 text: |
2140 text:text |
2091 text). |
2141 name:nil |
2142 ] ifTrue:[ |
|
2143 href := self |
|
2144 anchorForHTMLAction: |
|
2145 (autoloadedClass , ' autoload. ', self class name , ' htmlDocOf:' , className ) |
|
2146 info: |
|
2147 ('Show documentation of ' , className ) |
|
2148 text: |
|
2149 text. |
|
2150 ]. |
|
2151 |
|
2152 outStream nextPutLine:href. |
|
2092 ! |
2153 ! |
2093 |
2154 |
2094 generateH1:headerLine |
2155 generateH1:headerLine |
2095 outStream nextPutLine:'<h1>'. |
2156 outStream nextPutLine:'<h1>'. |
2096 outStream nextPutLine:headerLine. |
2157 outStream nextPutLine:headerLine. |
2097 outStream nextPutLine:'</h1>'. |
2158 outStream nextPutLine:'</h1>'. |
2098 ! |
2159 ! |
2099 |
2160 |
2161 generateHTMLEnd |
|
2162 generateBodyOnly == true ifFalse:[ |
|
2163 outStream nextPutLine:'</html>' |
|
2164 ] |
|
2165 ! |
|
2166 |
|
2100 generateHTMLHeadWithTitle:title |
2167 generateHTMLHeadWithTitle:title |
2101 outStream |
2168 generateBodyOnly == true ifFalse:[ |
2102 nextPutLine:'<!!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">'; |
2169 outStream |
2103 nextPutLine:('<!!-- generated by ' , self class name , ' ' , thisContext sender selector , ' -->'); |
2170 nextPutLine:'<!!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">'; |
2104 cr; |
2171 nextPutLine:('<!!-- generated by ' , self class name , ' ' , thisContext sender selector , ' -->'); |
2105 nextPutLine:'<html>'; |
2172 cr; |
2106 nextPutLine:'<head>'; |
2173 nextPutLine:'<html>'; |
2107 nextPutLine:'<title>'; |
2174 nextPutLine:'<head>'; |
2108 nextPutLine:title; |
2175 nextPutLine:'<title>'; |
2109 nextPutLine:'</title>'; |
2176 nextPutLine:title; |
2110 nextPutLine:'</head>'; |
2177 nextPutLine:'</title>'; |
2111 cr. |
2178 nextPutLine:'</head>'; |
2179 cr. |
|
2180 ] ifTrue:[ |
|
2181 outStream |
|
2182 nextPutLine:('<!!-- generated by ' , self class name , ' ' , thisContext sender selector , ' -->') |
|
2183 ]. |
|
2112 ! |
2184 ! |
2113 |
2185 |
2114 generateHorizontalLine |
2186 generateHorizontalLine |
2115 outStream nextPutLine:'<hr>'. |
2187 outStream nextPutLine:'<hr>'. |
2116 ! |
2188 ! |
2133 p := imagePath. |
2205 p := imagePath. |
2134 p isNil ifTrue:[ |
2206 p isNil ifTrue:[ |
2135 p := self pathToTopOfDocumentation , '/icons' |
2207 p := self pathToTopOfDocumentation , '/icons' |
2136 ]. |
2208 ]. |
2137 outStream nextPutLine:'> <IMG NOPRINT SRC="' , p , '/DocsUpArrow.gif" ALT="[' , (altLabel ? 'back') , ']"></A>'. |
2209 outStream nextPutLine:'> <IMG NOPRINT SRC="' , p , '/DocsUpArrow.gif" ALT="[' , (altLabel ? 'back') , ']"></A>'. |
2210 ! |
|
2211 |
|
2212 generatingForSTXBrowser |
|
2213 ^ httpRequestOrNil isNil |
|
2138 ! |
2214 ! |
2139 |
2215 |
2140 nextPutAllEscaped:aStringOrCharacter |
2216 nextPutAllEscaped:aStringOrCharacter |
2141 outStream nextPutAll:(self withSpecialHTMLCharactersEscaped:aStringOrCharacter) |
2217 outStream nextPutAll:(self withSpecialHTMLCharactersEscaped:aStringOrCharacter) |
2142 ! |
2218 ! |
2219 ! ! |
2295 ! ! |
2220 |
2296 |
2221 !HTMLDocGenerator class methodsFor:'documentation'! |
2297 !HTMLDocGenerator class methodsFor:'documentation'! |
2222 |
2298 |
2223 version |
2299 version |
2224 ^ '$Header: /cvs/stx/stx/libbasic3/HTMLDocGenerator.st,v 1.48 2003-04-24 12:15:57 cg Exp $' |
2300 ^ '$Header: /cvs/stx/stx/libbasic3/HTMLDocGenerator.st,v 1.49 2003-04-24 12:59:06 cg Exp $' |
2225 ! ! |
2301 ! ! |