os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tools/checkLibraryDoc.tcl
First public contribution.
1 # checkLibraryDoc.tcl --
3 # This script attempts to determine what APIs exist in the source base that
4 # have not been documented. By grepping through all of the doc/*.3 man
5 # pages, looking for "Pkg_*" (e.g., Tcl_ or Tk_), and comparing this list
6 # against the list of Pkg_ APIs found in the source (e.g., tcl8.2/*/*.[ch])
8 # 1) APIs in Source not in Docs.
9 # 2) APIs in Docs not in Source.
10 # 3) Internal APIs and structs.
11 # 4) Misc APIs and structs that we are not documenting.
12 # 5) Command APIs (e.g., Tcl_ArrayObjCmd.)
13 # 6) Proc pointers (e.g., Tcl_CloseProc.)
15 # Note: Each list is "a best guess" approximation. If developers write
16 # non-standard code, this script will produce erroneous results. Each
17 # list should be carefully checked for accuracy.
19 # Copyright (c) 1998-1999 by Scriptics Corporation.
20 # All rights reserved.
22 # RCS: @(#) $Id: checkLibraryDoc.tcl,v 1.7 2002/01/15 17:55:30 dgp Exp $
25 lappend auto_path "c:/program\ files/tclpro1.2/win32-ix86/bin"
26 #lappend auto_path "/home/surles/cvs/tclx8.0/tcl/unix"
27 if {[catch {package require Tclx}]} {
28 puts "error: could not load TclX. Please set TCL_LIBRARY."
32 # A list of structs that are known to be undocumented.
91 # Misc junk that appears in the comments of the source. This just
92 # allows us to filter comments that "fool" the script.
95 Tcl_Create\[Obj\]Command \
101 # Main entry point to this script.
107 set len [llength $argv]
108 if {($len != 2) && ($len != 3)} {
109 puts "usage: $argv0 pkgName pkgDir \[outFile\]"
110 puts " pkgName == Tcl,Tk"
111 puts " pkgDir == /home/surles/cvs/tcl8.2"
115 set pkg [lindex $argv 0]
116 set dir [lindex $argv 1]
117 if {[llength $argv] == 3} {
118 set file [open [lindex $argv 2] w]
123 foreach {c d} [compare [grepCode $dir $pkg] [grepDocs $dir $pkg]] {}
124 filter $c $d $dir $pkg $file
126 if {$file != "stdout"} {
132 # Intersect the two list and write out the sets of APIs in one
133 # list that is not in the other.
135 proc compare {list1 list2} {
136 set inter [intersect3 $list1 $list2]
137 return [list [lindex $inter 0] [lindex $inter 2]]
140 # Filter the lists into the six lists we report on. Then write
141 # the results to the file.
143 proc filter {code docs dir pkg {outFile stdout}} {
146 # A list of Tcl command APIs. These are not documented.
147 # This list should just be verified for accuracy.
151 # A list of proc pointer structs. These are not documented.
152 # This list should just be verified for accuracy.
156 # A list of internal declarations. These are not documented.
157 # This list should just be verified for accuracy.
159 set decls [grepDecl $dir $pkg]
161 # A list of misc. procedure declarations that are not documented.
162 # This list should just be verified for accuracy.
164 set misc [grepMisc $dir $pkg]
166 set pat1 ".*(${pkg}_\[A-z0-9]+).*$"
168 # A list of APIs in the source, not in the docs.
169 # This list should just be verified for accuracy.
172 if {[string match *Cmd $x]} {
173 if {[string match ${pkg}* $x]} {
176 } elseif {[string match *Proc $x]} {
177 if {[string match ${pkg}* $x]} {
180 } elseif {[lsearch -exact $decls $x] >= 0} {
182 } elseif {[lsearch -exact $misc $x] >= 0} {
189 dump $apis "APIs in Source not in Docs." $outFile
190 dump $docs "APIs in Docs not in Source." $outFile
191 dump $decls "Internal APIs and structs." $outFile
192 dump $misc "Misc APIs and structs that we are not documenting." $outFile
193 dump $cmds "Command APIs." $outFile
194 dump $procs "Proc pointers." $outFile
198 # Print the list of APIs if the list is not null.
200 proc dump {list title file} {
204 puts $file "---------------------------------------------------------"
211 # Grep into "dir/*/*.[ch]" looking for APIs that match $pkg_*.
212 # (e.g., Tcl_Exit). Return a list of APIs.
214 proc grepCode {dir pkg} {
215 set apis [myGrep "${pkg}_\.\*" "${dir}/\*/\*\.\[ch\]"]
216 set pat1 ".*(${pkg}_\[A-z0-9]+).*$"
219 if {[regexp -- $pat1 $a main n1]} {
220 set result([string trim $n1]) 1
223 return [lsort [array names result]]
226 # Grep into "dir/doc/*.3" looking for APIs that match $pkg_*.
227 # (e.g., Tcl_Exit). Return a list of APIs.
229 proc grepDocs {dir pkg} {
230 set apis [myGrep "\\fB${pkg}_\.\*\\fR" "${dir}/doc/\*\.3"]
231 set pat1 ".*(${pkg}_\[A-z0-9]+)\\\\fR.*$"
234 if {[regexp -- $pat1 $a main n1]} {
235 set result([string trim $n1]) 1
238 return [lsort [array names result]]
241 # Grep into "generic/pkgIntDecls.h" looking for APIs that match $pkg_*.
242 # (e.g., Tcl_Export). Return a list of APIs.
244 proc grepDecl {dir pkg} {
245 set file [file join $dir generic "[string tolower $pkg]IntDecls.h"]
246 set apis [myGrep "^EXTERN.*\[ \t\]${pkg}_.*" $file]
247 set pat1 ".*(${pkg}_\[A-z0-9]+).*$"
250 if {[regexp -- $pat1 $a main n1]} {
251 set result([string trim $n1]) 1
254 return [lsort [array names result]]
257 # Grep into "*/*.[ch]" looking for APIs that match $pkg_Db*.
258 # (e.g., Tcl_DbCkalloc). Return a list of APIs.
260 proc grepMisc {dir pkg} {
264 set apis [myGrep "^EXTERN.*\[ \t\]${pkg}_Db.*" "${dir}/\*/\*\.\[ch\]"]
265 set pat1 ".*(${pkg}_\[A-z0-9]+).*$"
268 if {[regexp -- $pat1 $a main n1]} {
269 set dbg([string trim $n1]) 1
274 eval {lappend result} $StructList
275 eval {lappend result} [lsort [array names dbg]]
276 eval {lappend result} $CommentList
280 proc myGrep {searchPat globPat} {
282 foreach file [glob -nocomplain $globPat] {
283 set file [open $file r]
284 set data [read $file]
286 foreach line [split $data "\n"] {
287 if {[regexp "^.*${searchPat}.*\$" $line]} {