[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] [PATCH] teach gst-doc to generate HTML documentation
From: |
Thomas Girard |
Subject: |
[Help-smalltalk] [PATCH] teach gst-doc to generate HTML documentation |
Date: |
Sat, 16 Aug 2008 00:17:14 +0200 |
User-agent: |
Mozilla-Thunderbird 2.0.0.16 (X11/20080724) |
Hello,
with the attached patches it is possible to generate HTML documentation
for classes using gst-doc.
For example, the following command:
gst-doc -d HTML -o outputdir 'Smalltalk.*'
will generate HTML documentation into the directory outputdir for all
classes in the Smalltalk namespace.
These patches add #publishAll: toLocation:, where location can be a file
(for Texinfo publisher) or a directory (for HTML publisher). The `-o'
argument can be used to change the default location (stdout for the
Texinfo publisher and `.' for the HTML publisher).
Regards,
Thomas
commit 003e66526150a2aaf9ac66a6ae1dff23d3e914d8
Author: Thomas Girard <address@hidden>
Date: Fri Aug 15 15:11:14 2008 +0200
add `-d' argument to choose the publisher
diff --git a/gst-tool.c b/gst-tool.c
index 8b37cdd..e6e25c1 100644
--- a/gst-tool.c
+++ b/gst-tool.c
@@ -125,7 +125,7 @@ struct tool tools[] = {
{
"gst-doc", "scripts/GenDoc.st",
"-h|--help --version -p|--package: -f|--file: -I|--image-file: \
- -n|--namespace: -o|--output: --kernel-directory:",
+ -n|--namespace: -o|--output: --kernel-directory: -d|--doc:",
NULL
},
{
diff --git a/scripts/GenDoc.st b/scripts/GenDoc.st
index 399940b..4167d97 100644
--- a/scripts/GenDoc.st
+++ b/scripts/GenDoc.st
@@ -34,7 +34,6 @@ PackageLoader fileInPackage: #ClassPublisher!
| package outFile publisher files classes classPatterns loader
defaultNamespace |
classPatterns := OrderedCollection new.
-publisher := STInST.TexinfoDocPublisher.
defaultNamespace := Smalltalk.
helpString :=
@@ -48,6 +47,7 @@ Options:
-n --namespace=NAMESP load files in the given namespace
-o --output=FILE emit documentation in the given file (default=stdout)
--kernel-dir=PATH use the specified kernel directory
+ -d --doc=KIND use the given publisher (HTML or default=Texinfo)
-h --help show this message
--version print version information and exit
'.
@@ -59,7 +59,7 @@ Options:
"Parse the command-line arguments."
Smalltalk
arguments: '-h|--help --version -p|--package: -f|--file:
-n|--namespace:
- -I|--image-file: -o|--output: --kernel-directory:'
+ -I|--image-file: -o|--output: --kernel-directory:
-d|--doc:'
do: [ :opt :arg |
opt = 'help' ifTrue: [
@@ -104,12 +104,24 @@ Options:
parseSmalltalkStream: file
with: STInST.GSTFileInParser ].
+ opt = 'doc' ifTrue: [
+ publisher isNil ifFalse: [
+ self error: '--doc specified multiple times' ].
+ arg = 'HTML'
+ ifTrue: [ publisher := STInST.HTMLDocPublisher ]
+ ifFalse: [
+ arg = 'Texinfo'
+ ifTrue: [ publisher:= STInST.TexinfoDocPublisher ]
+ ifFalse: [ self error: 'unknown --doc arg' ] ] ].
+
opt isNil ifTrue: [ classPatterns add: arg ] ]
ifError: [
helpString displayOn: stderr.
ObjectMemory quit: 1 ].
+ publisher isNil ifTrue: [ publisher := STInST.TexinfoDocPublisher ].
+
classPatterns isEmpty
ifTrue: [
classes := loader fullyDefinedLoadedClasses.
commit da060175537597f32a5e905268b3a8f6b58071c5
Author: Thomas Girard <address@hidden>
Date: Fri Aug 15 15:56:03 2008 +0200
be consistent in extensions, always use .html
diff --git a/packages/stinst/doc/Publish.st b/packages/stinst/doc/Publish.st
index 516cbb2..c2d5100 100644
--- a/packages/stinst/doc/Publish.st
+++ b/packages/stinst/doc/Publish.st
@@ -954,10 +954,10 @@ Alphabetic list of classes:'.
[:each |
| fileName |
fileName := each nameIn: Namespace current.
- ('writing documentation into ' , fileName , '.htm') displayNl.
- self publish: each onFile: fileName , '.htm'.
+ ('writing documentation into ' , fileName , '.html') displayNl.
+ self publish: each onFile: fileName , '.html'.
aFileStream
- nextPutAll: '<A HREF="%1.htm">%1</A>' % {fileName};
+ nextPutAll: '<A HREF="%1.html">%1</A>' % {fileName};
nl].
aFileStream nextPutAll: '</PRE></BODY></HTML>'
]
@@ -977,7 +977,7 @@ Alphabetic list of classes:'.
nextPutAll: indent.
fileName := class nameIn: Namespace current.
aBoolean
- ifTrue: [aFileStream nextPutAll: '<A HREF="' , fileName , '.htm">']
+ ifTrue: [aFileStream nextPutAll: '<A HREF="' , fileName , '.html">']
ifFalse: [aFileStream nextPut: $(].
aFileStream nextPutAll: (class nameIn: Namespace current).
aBoolean
commit d80d3a1fc4a92b15a0894ae5ca5131e294c3b7a2
Author: Thomas Girard <address@hidden>
Date: Fri Aug 15 16:58:06 2008 +0200
add #publishAll: toLocation: and use it
diff --git a/packages/stinst/doc/Publish.st b/packages/stinst/doc/Publish.st
index c2d5100..032c12a 100644
--- a/packages/stinst/doc/Publish.st
+++ b/packages/stinst/doc/Publish.st
@@ -1166,6 +1166,14 @@ DocPublisher subclass: TexinfoDocPublisher [
aFileStream nextPutAll: self footer
]
+ TexinfoDocPublisher class >> publishAll: classArray [
+ self publishAll: classArray on: stdout
+ ]
+
+ TexinfoDocPublisher class >> publishAll: classArray toLocation: aFileName [
+ self publishAll: classArray onFile: aFileName
+ ]
+
TexinfoDocPublisher class >> publish: aClass on: aFileStream [
"Publish aClass, in the format supported by the receiver, on
aFileStream"
diff --git a/scripts/GenDoc.st b/scripts/GenDoc.st
index 4167d97..28aed81 100644
--- a/scripts/GenDoc.st
+++ b/scripts/GenDoc.st
@@ -31,7 +31,7 @@
"Load the prerequisites"
PackageLoader fileInPackage: #ClassPublisher!
-| package outFile publisher files classes classPatterns loader
defaultNamespace |
+| package location publisher files classes classPatterns loader
defaultNamespace |
classPatterns := OrderedCollection new.
defaultNamespace := Smalltalk.
@@ -71,9 +71,9 @@ Options:
ObjectMemory quit: 0 ].
opt = 'output' ifTrue: [
- outFile isNil ifFalse: [
+ location isNil ifFalse: [
self error: '--output specified multiple times' ].
- outFile := arg ].
+ location := arg ].
opt = 'namespace' ifTrue: [
defaultNamespace := Smalltalk.
@@ -145,12 +145,12 @@ Options:
(allClasses select: [ :each |
pat match: (each nameIn: Smalltalk) ]) ] ] ].
- outFile isNil
+ location isNil
ifTrue: [
Transcript message: stderr -> #nextPutAllFlush:.
- publisher publishAll: classes on: stdout ]
+ publisher publishAll: classes ]
ifFalse: [
- publisher publishAll: classes onFile: outFile ]
+ publisher publishAll: classes toLocation: location ]
]
on: Error
do: [ :ex |
commit 9b54f61af407f8d6f50998517e3f883662548ed0
Author: Thomas Girard <address@hidden>
Date: Fri Aug 15 17:18:28 2008 +0200
adapt HTMLDocPublisher to new messages
diff --git a/packages/stinst/doc/Publish.st b/packages/stinst/doc/Publish.st
index 032c12a..fb8ec31 100644
--- a/packages/stinst/doc/Publish.st
+++ b/packages/stinst/doc/Publish.st
@@ -969,6 +969,21 @@ Alphabetic list of classes:'.
[self publishAll: classArray withIndexOn: stream] ensure: [stream close]
]
+ HTMLDocPublisher class >> publishAll: classArray toLocation: dirName [
+ | currentDir |
+ currentDir := Directory working.
+ dirName = '.'
+ ifFalse: [
+ (File isAccessible: dirName) ifFalse: [ Directory create:
dirName ].
+ Directory working: dirName ].
+ self publishAll: classArray withIndexOnFile: 'classes.html'.
+ dirName = '.' ifFalse: [ Directory working: currentDir ]
+ ]
+
+ HTMLDocPublisher class >> publishAll: classArray [
+ self publishAll: classArray toLocation: '.'
+ ]
+
HTMLDocPublisher class >> printTreeClass: class shouldLink: aBoolean on:
aFileStream indent: indent [
<category: 'writing the class tree'>
| fileName |
commit 0ad7bcb6f8380fdbd4fb0a0dcf7ef976b5ce84bd
Author: Thomas Girard <address@hidden>
Date: Fri Aug 15 23:15:50 2008 +0200
add missing new line in generated HTML
diff --git a/packages/stinst/doc/Publish.st b/packages/stinst/doc/Publish.st
index f22b40e..ccf5e19 100644
--- a/packages/stinst/doc/Publish.st
+++ b/packages/stinst/doc/Publish.st
@@ -949,7 +949,7 @@ Automatically yours from GNU Smalltalk''s HTMLDocPublisher!
-->
self printHierarchyOf: sorted on: aFileStream.
aFileStream nextPutAll: '
-Alphabetic list of classes:'.
+Alphabetic list of classes:'; nl.
sorted do:
[:each |
| fileName |
- [Help-smalltalk] [PATCH] teach gst-doc to generate HTML documentation,
Thomas Girard <=