aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/www/mkapidoc.tcl
diff options
context:
space:
mode:
authordan miller2007-10-20 02:49:29 +0000
committerdan miller2007-10-20 02:49:29 +0000
commite36d23a85ebff914d74bb541558c2b6082b78edb (patch)
tree54b58fdf162e78af64055282a6035c8d2443389d /libraries/sqlite/unix/sqlite-3.5.1/www/mkapidoc.tcl
parent* Fixed an issue whereby avatar chat distances were being calculated against ... (diff)
downloadopensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.zip
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.gz
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.bz2
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.xz
sqlite source (unix build) added to libraries
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/www/mkapidoc.tcl')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/www/mkapidoc.tcl176
1 files changed, 176 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/www/mkapidoc.tcl b/libraries/sqlite/unix/sqlite-3.5.1/www/mkapidoc.tcl
new file mode 100644
index 0000000..723f84a
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/www/mkapidoc.tcl
@@ -0,0 +1,176 @@
1#!/usr/bin/tclsh
2#
3# Run this script redirecting the sqlite3.h file as standard
4# inputs and this script will generate API documentation.
5#
6set rcsid {$Id: mkapidoc.tcl,v 1.2 2007/06/20 09:09:48 danielk1977 Exp $}
7source common.tcl
8header {C/C++ Interface For SQLite Version 3}
9puts {
10<h2 class=pdf_section>C/C++ Interface For SQLite Version 3</h2>
11}
12
13# Scan standard input to extract the information we need
14# to build the documentation.
15#
16set title {}
17set type {}
18set body {}
19set code {}
20set phase 0
21set content {}
22while {![eof stdin]} {
23 set line [gets stdin]
24 if {$phase==0} {
25 # Looking for the CAPI3REF: keyword
26 if {[regexp {^\*\* CAPI3REF: +(.*)} $line all tx]} {
27 set title $tx
28 set phase 1
29 }
30 } elseif {$phase==1} {
31 if {[string range $line 0 1]=="**"} {
32 set lx [string trim [string range $line 3 end]]
33 if {[regexp {^CATEGORY: +([a-z]*)} $lx all cx]} {
34 set type $cx
35 } elseif {[regexp {^KEYWORDS: +(.*)} $lx all kx]} {
36 foreach k $kx {
37 set keyword($k) 1
38 }
39 } else {
40 append body $lx\n
41 }
42 } elseif {[string range $line 0 1]=="*/"} {
43 set phase 2
44 }
45 } elseif {$phase==2} {
46 if {$line==""} {
47 set kwlist [lsort [array names keyword]]
48 unset -nocomplain keyword
49 set key $type:$kwlist
50 lappend content [list $key $title $type $kwlist $body $code]
51 set title {}
52 set keywords {}
53 set type {}
54 set body {}
55 set code {}
56 set phase 0
57 } else {
58 if {[regexp {^#define (SQLITE_[A-Z0-9_]+)} $line all kx]} {
59 set type constant
60 set keyword($kx) 1
61 } elseif {[regexp {^typedef .* (sqlite[0-9a-z_]+);} $line all kx]} {
62 set type datatype
63 set keyword($kx) 1
64 } elseif {[regexp {^[a-z].*[ *](sqlite3_[a-z0-9_]+)\(} $line all kx]} {
65 set type function
66 set keyword($kx) 1
67 }
68 append code $line\n
69 }
70 }
71}
72
73# Output HTML that displays the given list in N columns
74#
75proc output_list {N lx} {
76 puts {<table width="100%" cellpadding="5"><tr>}
77 set len [llength $lx]
78 set n [expr {($len + $N - 1)/$N}]
79 for {set i 0} {$i<$N} {incr i} {
80 set start [expr {$i*$n}]
81 set end [expr {($i+1)*$n}]
82 puts {<td valign="top"><ul>}
83 for {set j $start} {$j<$end} {incr j} {
84 set entry [lindex $lx $j]
85 if {$entry!=""} {
86 foreach {link label} $entry break
87 puts "<li><a href=\"#$link\">$label</a></li>"
88 }
89 }
90 puts {</ul></td>}
91 }
92 puts {</tr></table>}
93}
94
95# Do a table of contents for objects
96#
97set objlist {}
98foreach c $content {
99 foreach {key title type keywords body code} $c break
100 if {$type!="datatype"} continue
101 set keywords [lsort $keywords]
102 set k [lindex $keywords 0]
103 foreach kw $keywords {
104 lappend objlist [list $k $kw]
105 }
106}
107puts {<h2>Datatypes:</h2>}
108output_list 3 $objlist
109puts {<hr>}
110
111# Do a table of contents for constants
112#
113set clist {}
114foreach c $content {
115 foreach {key title type keywords body code} $c break
116 if {$type!="constant"} continue
117 set keywords [lsort $keywords]
118 set k [lindex $keywords 0]
119 foreach kw $keywords {
120 lappend clist [list $k $kw]
121 }
122}
123puts {<h2>Constants:</h2>}
124set clist [lsort -index 1 $clist]
125output_list 3 $clist
126puts {<hr>}
127
128
129# Do a table of contents for functions
130#
131set funclist {}
132foreach c $content {
133 foreach {key title type keywords body code} $c break
134 if {$type!="function"} continue
135 set keywords [lsort $keywords]
136 set k [lindex $keywords 0]
137 foreach kw $keywords {
138 lappend funclist [list $k $kw]
139 }
140}
141puts {<h2>Functions:</h2>}
142set funclist [lsort -index 1 $funclist]
143output_list 3 $funclist
144puts {<hr>}
145
146# Resolve links
147#
148proc resolve_links {args} {
149 set tag [lindex $args 0]
150 regsub -all {[^a-zA-Z0-9_]} $tag {} tag
151 set x "<a href=\"#$tag\">"
152 if {[llength $args]>2} {
153 append x [lrange $args 2 end]</a>
154 } else {
155 append x [lindex $args 0]</a>
156 }
157 return $x
158}
159
160# Output all the records
161#
162foreach c [lsort $content] {
163 foreach {key title type keywords body code} $c break
164 foreach k $keywords {
165 puts "<a name=\"$k\"></a>"
166 }
167 puts "<h2>$title</h2>"
168 puts "<blockquote><pre>"
169 puts "$code"
170 puts "</pre></blockquote>"
171 regsub -all "\n\n+" $body {</p>\1<p>} body
172 regsub -all {\[} <p>$body</p> {[resolve_links } body
173 set body [subst -novar -noback $body]
174 puts "$body"
175 puts "<hr>"
176}