/usr/share/gnu-smalltalk/scripts/GenDoc.st is in gnu-smalltalk-common 3.2.4-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | "======================================================================
|
| Smalltalk documentation publisher (utility script)
|
|
======================================================================"
"======================================================================
|
| Copyright 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
| Written by Paolo Bonzini.
|
| This file is part of GNU Smalltalk.
|
| GNU Smalltalk is free software; you can redistribute it and/or modify it
| under the terms of the GNU General Public License as published by the Free
| Software Foundation; either version 2, or (at your option) any later version.
|
| GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
| FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
| details.
|
| You should have received a copy of the GNU General Public License along with
| GNU Smalltalk; see the file COPYING. If not, write to the Free Software
| Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
======================================================================"
"Load the prerequisites"
PackageLoader fileInPackage: #ClassPublisher!
| package location publisher files classes classPatterns loader defaultNamespace warnings |
classPatterns := OrderedCollection new.
warnings := Set new.
defaultNamespace := Smalltalk.
helpString :=
'Usage:
gst-doc [ flag ... ] class ...
Options:
-I --image-file=FILE look for classes in the given image
-p --package=PKG look for classes in the given package
-f --file=FILE look for classes in the given file
-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
-F --output-format=KIND use the given publisher (HTML or default=Texinfo)
-h --help show this message
-v --verbose print extra information while processing
--version print version information and exit
'.
[
loader := STInST.STClassLoader new.
Namespace current: Smalltalk.
"Parse the command-line arguments."
Smalltalk
arguments: '-h|--help --version -p|--package: -f|--file: -n|--namespace:
-I|--image-file: -o|--output: --kernel-directory: -F|--output-format:
-v|-V|--verbose'
do: [ :opt :arg |
opt = 'help' ifTrue: [
helpString displayOn: stdout.
ObjectMemory quit: 0 ].
opt = 'version' ifTrue: [
('gst-doc - %1' % {Smalltalk version}) displayNl.
ObjectMemory quit: 0 ].
opt = 'output' ifTrue: [
location isNil ifFalse: [
self error: '--output specified multiple times' ].
location := arg ].
opt = 'namespace' ifTrue: [
defaultNamespace := Smalltalk.
(arg subStrings: $.) do:
[:each |
| key |
key := each asSymbol.
(defaultNamespace includesKey: key)
ifFalse: [defaultNamespace addSubspace: key].
defaultNamespace := defaultNamespace at: key].
loader currentNamespace: defaultNamespace ].
opt = 'package' ifTrue: [
package := PackageLoader packageAt: arg.
loader currentNamespace: package createNamespace.
files := package fullPathsOf: package fileIns.
files do: [ :each |
loader
parseSmalltalkStream: each readStream
with: STInST.GSTFileInParser ].
loader currentNamespace: defaultNamespace ].
opt = 'file' ifTrue: [
loader
parseSmalltalkStream: arg asFile readStream
with: STInST.GSTFileInParser ].
opt = 'output-format' ifTrue: [
publisher isNil ifFalse: [
self error: '--output-format specified multiple times' ].
arg asLowercase = 'html'
ifTrue: [ publisher := STInST.HTMLDocPublisher ]
ifFalse: [
arg asLowercase = 'texinfo'
ifTrue: [ publisher:= STInST.TexinfoDocPublisher ]
ifFalse: [ self error: 'unknown --output-format arg' ] ] ].
opt = 'verbose' ifTrue: [
OutputVerbosity := 1.
FileStream verbose: true ].
opt isNil ifTrue: [ classPatterns add: arg ] ]
ifError: [
helpString displayOn: stderr.
ObjectMemory quit: 1 ].
publisher isNil ifTrue: [ publisher := STInST.TexinfoDocPublisher ].
classPatterns isEmpty
ifTrue: [
classes := loader loadedClasses.
classes isEmpty
ifTrue: [ self error: 'specify -p, -f, or a class name' ] ]
ifFalse: [
allClasses :=
loader loadedClasses,
(Class allSubclasses collect: [ :each | each instanceClass ]).
classes := IdentitySet new.
classPatterns do: [ :pat || ns |
(pat last: 2) = '.*'
ifTrue: [
ns := pat allButLast: 2.
classes addAll:
(allClasses select: [ :each |
(each environment nameIn: Smalltalk) = ns ]) ]
ifFalse: [
classes addAll:
(allClasses select: [ :each |
pat match: (each nameIn: Smalltalk) ]) ] ] ].
location isNil
ifTrue: [
Transcript message: stderr -> #nextPutAllFlush:.
publisher publishAll: classes ]
ifFalse: [
publisher publishAll: classes toLocation: location ]
]
on: Warning
do: [ :ex |
(warnings includes: ex messageText) ifFalse: [
warnings add: ex messageText.
('gst-doc: warning: ', ex messageText, '
') displayOn: Transcript ].
ex resume ]
on: Error
do: [ :ex |
('gst-doc: ', ex messageText, '
') displayOn: stderr.
"ex pass." ObjectMemory quit: 1 ]!
|