summaryrefslogtreecommitdiff
path: root/iwidgets/doc/mkitclman
blob: cbcd1dbb72e946657554bcec6a5a176884984b72 (plain)
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#!/bin/sh
# \
    exec itkwish "$0" ${1+"$@"}
#
# mkitclman "4 Dec 1995"
# mkitclman - generate a man page from an itcl class
#
# SYNOPSIS
#   mkitclman classfile
#
# DESCRIPTION
#   Reads an [incr Tcl] or [incr Tk] class file as input, and outputs nroff.
#   mkitclman generates a standard format used for [incr Widget] classes. It
#   locates the class name, inheritance to one level, widget specific options,
#   and widget specific methods. Areas that the script cannot handle it 
#   places and uppercased name delimited by leading and trailing '_' characters.
#
#   [incr Tcl/Tk] 2.0 is the supported class format. 
#
# CAVEATS
#   mkitlcman does not work with normal Tk or Tcl script files. 
#   It expects only one class per file. In addition, it does not work on
#   namespace files.

proc init { } {
	global _className
	global _inheritClass
    global _publicMethod
    global _publicVariable
    global _protectedMethod
    global _protectedVariable
    global _privateMethod
    global _privateVariable
	global _options

	set _className {}
	set _inheritClass {}

}
proc namespace { args } {
	global _className

	set _className [lindex $args 0]
	set classBody [lindex $args 1]

	eval $classBody
}
proc class { args } {
	global _className

	set _className [lindex $args 0]
	set classBody [lindex $args 1]

	eval $classBody
}
proc itk_option { action switch args } {
	global _options

	if { $action == "define" } {
		set _options($switch) $args
	}
}
proc inherit { inheritClass } {
	global _inheritClass
	set _inheritClass $inheritClass
}

# default is public method
proc method { name args } {
	global _publicMethod

	set _publicMethod($name) $args
}

# pick up arrays later...
proc common { name args } {
	global _commonVariable

	# set to defaults
	set _commonVariable($name) $args
}

proc public { type args } {
	global _publicMethod
	global _publicVariable

	switch $type {
		method {
			set _publicMethod([lindex $args 0]) [lindex $args 1]
		}
		variable {
			# _publicVariable(varName) = defaultValue
			set _publicVariable([lindex $args 0]) [lindex $args 1]
		}
	}
}

proc protected { type args } {
	global _protectedMethod
	global _protectedVariable

	switch $type {
		method {
			# _protectedMethod(methodName) = argList
			set _protectedMethod([lindex $args 0]) [lrange $args 1 end]
		}
		variable {
			# _protectedVariable(varName) = defaultValue
			set _protectedVariable([lindex $args 0]) [lindex $args 1]
		}
	}
}

proc private { type args } {
	global _privateMethod
	global _privateVariable

	switch $type {
		method {
			# _privateMethod(methodName) = argList
			set _privateMethod([lindex $args 0]) [lrange $args 1 end]
		}
		variable {
			# _privateVariable(varName) = defaultValue
			set _privateVariable([lindex $args 0]) [lindex $args 1]
		}
	}
}

proc body { args } {
}

proc configbody { args } {
}

proc destructor { args } {
}
proc constructor { args } {
}

proc gen { } {
	global _className
    global _classBody
	global _inheritClass
    global _publicMethod
    global _publicVariable
    global _protectedMethod
    global _protectedVariable
    global _privateMethod
    global _privateVariable
    global _methodSection
    global _optionSection
	global _manpage
	global _optionManFmt
	global _methodManFmt
	global _method
	global _options
	global _optionSwitch
	global _optionName
	global _optionClass

	if { $_inheritClass != {} } {
		set _inheritClass "$_inheritClass <-"
	}
	set _optionManFmt {}
	set _methodManFmt {}
	set _methodArgs {}
	foreach pbv [lsort [array names _publicVariable]]  {
		set _optionSwitch "-$pbv"
		set _optionName $pbv
		set _optionClass "[string toupper [string index $pbv 0]][string range $pbv 1 end]"
		lappend _optionManFmt [subst -nobackslash -nocommand $_optionSection]
	}

	foreach opt [lsort [array names _options]] {
		set _optionSwitch $opt
		set _optionName [lindex $_options($opt) 0]
		set _optionClass [lindex $_options($opt) 1]
		lappend _optionManFmt [subst -nobackslash -nocommand $_optionSection]
	}
	foreach pbm [lsort [array names _publicMethod]] {
		set _method $pbm
		eval set _methodArgs [list $_publicMethod($pbm)]
		lappend _methodManFmt [subst -nobackslash -nocommand $_methodSection]
	}
	foreach ptm [lsort [array names _protectedMethod]] {
	}
	foreach ptv [lsort [array names _protectedVariable]] {
	}
	foreach pvm [lsort [array names _privateMethod]] {
	}
	foreach pvv [lsort [array names _privateVariable]] {
	}

	set _methodManFmt [join $_methodManFmt " "]
	set _optionManFmt [join $_optionManFmt " "]

	set _manpage [subst -nobackslash -nocommand $_manpage]

	puts $_manpage
}

set _manpage {
'\"
'\" Copyright (c) _AUTHOR_
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
'\" @(#) $_className.n
'/"
.so man.macros
.HS $_className iwid
.BS
'\" Note:  do not modify the .SH NAME line immediately below!
'\"
'\"
.SH NAME
$_className \- _NAME_DESCRIPTION_
.SH SYNOPSIS
\fB$_className\fI \fIpathName\fR ?\fIoptions\fR?
.SH "INHERITANCE"
$_inheritClass $_className
.SH "STANDARD OPTIONS"
.LP
.nf
.ta 4c 8c 12c
_STANDARD_OPTIONS_
.fi
.LP
See the "options" manual entry for details on the standard options.
.SH "ASSOCIATED OPTIONS"
.LP
.nf
.ta 4c 8c 12c
_ASSOCIATED_OPTIONS_
.fi
.LP
See the "_ASSOCIATED_WIDGET_" widget manual entry for details on the above
associated options.
.SH "INHERITED OPTIONS"
.LP
.nf
.ta 4c 8c 12c
_INHERITED_OPTIONS_
.fi
.LP
See the "_INHERITED_WIDGET_" class manual entry for details on the inherited options.
.SH "WIDGET-SPECIFIC OPTIONS"
.LP
$_optionManFmt
.BE
.SH DESCRIPTION
.PP
_DESCRIPTION_
.SH "METHODS"
.PP
The \fB$_className\fR command creates a new Tcl command whose
name is \fIpathName\fR.  This
command may be used to invoke various
operations on the widget.  It has the following general form:
.DS C
\fIpathName option \fR?\fIarg arg ...\fR?
.DE
\fIOption\fR and the \fIarg\fRs
determine the exact behavior of the command.  The following
commands are possible for $_className widgets:
.SH "ASSOCIATED METHODS"
.LP
.nf
.ta 4c 8c 12c
_ASSOCIATED_METHODS_
.fi
.LP
See the "_ASSOCIATED_WIDGET_" manual entry for details on the standard methods.
.SH "WIDGET-SPECIFIC METHODS"
$_methodManFmt
.SH "COMPONENTS"
.LP
.nf
Name:   \fB_COMPONENT_NAME_\fR
Class:  \fB_COMPONENT_CLASS_\fR
.fi
.IP
_COMPONENT_DESCRIPTION_
See the "_COMPONENT_TYPE_" widget manual entry for details on the _COMPONENT_NAME_ component item.
.fi
.SH EXAMPLE
.DS
_EXAMPLE_CODE_
.DE
.SH AUTHOR
_AUTHOR_
.SH KEYWORDS
_KEYWORDS_
}

set _optionSection {
.nf
Name:	\fB$_optionName\fR
Class:	\fB$_optionClass\fR
Command-Line Switch:	\fB$_optionSwitch\fR
.fi
.IP
_OPTION_DESCRIPTION_
.LP
}

set _methodSection {
.TP
\fIpathName\fR \fB$_method\fR \fI$_methodArgs\fR
_METHOD_DESCRIPTION_
}

# Add these two lines up into the man page above to enable

init
source [lindex $argv 0]
gen
exit