System.Data.SQLite

Check-in [4e474edb97]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix line/paragraph handling. Add support for line prefix.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | vtabDocComments
Files: files | file ages | folders
SHA1: 4e474edb9711edfe3e539546d7abf0bc7cb7ea1d
User & Date: mistachkin 2015-10-18 01:51:12.080
Context
2015-10-18
01:56
Consistently handle the special case of the first line, even when it seems impossible. check-in: 2e0349b541 user: mistachkin tags: vtabDocComments
01:51
Fix line/paragraph handling. Add support for line prefix. check-in: 4e474edb97 user: mistachkin tags: vtabDocComments
00:20
Work in progress on a tool to update the embedded doc comments for the ISQLiteNativeModule interface. check-in: 44c116ca23 user: mistachkin tags: vtabDocComments
Changes
Unified Diff Ignore Whitespace Patch
Changes to Doc/vtab.tcl.
18
19
20
21
22
23
24






25
26
27
28
29
30
31
proc writeFile { fileName data } {
  set file_id [open $fileName {WRONLY CREAT TRUNC}]
  fconfigure $file_id -encoding binary -translation binary
  puts -nonewline $file_id $data
  close $file_id
  return ""
}







proc englishToList { value } {
  set result [list]

  foreach element [split $value "\t\n ,"] {
    if {[string tolower $element] ni [list "" and or]} then {
      lappend result $element







>
>
>
>
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
proc writeFile { fileName data } {
  set file_id [open $fileName {WRONLY CREAT TRUNC}]
  fconfigure $file_id -encoding binary -translation binary
  puts -nonewline $file_id $data
  close $file_id
  return ""
}

proc escapeSubSpec { data } {
  regsub -all -- {&} $data {\\\&} data
  regsub -all -- {\\(\d+)} $data {\\\\\1} data
  return $data
}

proc englishToList { value } {
  set result [list]

  foreach element [split $value "\t\n ,"] {
    if {[string tolower $element] ni [list "" and or]} then {
      lappend result $element
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
  foreach remove [list \
      {<a name=".*?">} {<a href=".*?">} {</a>} {<b>} {</b>} \
      {<dd>} {</dd>} {<dl>} {</dl>} {<dt>} {</dt>} {<li>} \
      {</li>} {<ol>} {</ol>} {<p>} {</p>} {<ul>} {</ul>}] {
    regsub -all -- $remove $result "" result

    if {[string length [string trim $result]] == 0} then {
      puts "STOP with no content, original line = $line"
      return ""
    }
  }

  regsub -all -- {<br>} $result \n result
  regsub -all -- {&ne;} $result {\&#8800;} result
  regsub -all -- {&#91(?:;)?} $result {[} result
  regsub -all -- {&#93(?:;)?} $result {]} result
  regsub -all -- {<( |\"|\d|=)} $result {\&lt;\1} result
  regsub -all -- {( |\"|\d|=)>} $result {\1\&gt;} result
  regsub -all -- {<blockquote><pre>} $result <code> result
  regsub -all -- {</pre></blockquote>} $result </code> result
  regsub -all -- {<blockquote>} $result <code> result
  regsub -all -- {</blockquote>} $result </code> result

  return $result
}

proc extractMethod { name lines pattern indexVarName methodsVarName } {
  upvar 1 $indexVarName index
  upvar 1 $methodsVarName methods

  set paragraph 0
  set length [llength $lines]

  while {$index < $length} {
    set line [lindex $lines $index]

    if {[regexp -- $pattern $line]} then {
      break; # stop on this line for outer loop.
    } else {
      set trimLine [string trim $line]; set data ""

      if {$paragraph > 0 && [string length $trimLine] == 0} then {
        # blank line, close paragraph.
        append data \n </para>; incr paragraph -1
      } elseif {[string range $trimLine 0 2] eq "<p>"} then {
        # open paragraph ... maybe one line?
        if {[string range $trimLine end-3 end] eq "</p>"} then {
          set newLine [processLine $line]

          if {[string length $newLine] > 0} then {
            # one line paragraph, wrap.
            if {[info exists methods($name)]} then {
              append data \n
            }

            append data <para> \n $newLine \n </para>
          }
        } else {
          if {[info exists methods($name)]} then {
            append data \n
          }

          append data <para>

          set newLine [processLine $line]

          if {[string length $newLine] > 0} then {
            # open paragraph, add line to it.





            append data $newLine

          }

          incr paragraph
        }
      } else {
        set newLine [processLine $line]

        if {[string length $newLine] > 0} then {
          if {[info exists methods($name)]} then {

            append data \n
          }

          append data $newLine

        }
      }

      if {[string length $data] > 0} then {
        append methods($name) $data
      }

      incr index; # consume this line for outer loop.
    }
  }
}

#
# NOTE: This is the entry point for this script.
#
set path [file normalize [file dirname [info script]]]

set coreDocPath [file join $path Extra Core]
set interfacePath [file join [file dirname $path] System.Data.SQLite]






set inputFileName [file join $coreDocPath vtab.html]
set outputFileName [file join $interfacePath ISQLiteNativeModule.cs]







set methodPattern {^<h3>2\.\d+ The (.*) Method(?:s)?</h3>$}

set start false
array set methods {}
set lines [split [readFile $inputFileName] \n]
set length [llength $lines]

for {set index 0} {$index < $length} {} {
  set line [lindex $lines $index]

  if {$start} then {
    if {[regexp -- {^<a name=".*"></a>$} $line]} then {
      incr index; continue
    }

    if {[regexp -- $methodPattern $line dummy capture]} then {
      foreach method [englishToList $capture] {
        set methodIndex [expr {$index + 1}]

        extractMethod $method $lines $methodPattern methodIndex methods

      }

      set index $methodIndex
    } else {
      incr index
    }
  } elseif {[regexp -- {^<h2>2\.0 Virtual Table Methods</h2>$} $line]} then {
    set start true; incr index
  } else {
    incr index
  }
}

# "        /// <summary>"
# "        /// </summary>"
# exit 0







<


















|
















|







<
|
<
|
|


<
|
<
<
<





>
>
>
>
>
|
>









>
|
|
|
|
>



















>

>
>
>
>
|


>
>
>
>
>
>
|
>
|
<
<
<

|







|


>
|
>













<
<

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
  foreach remove [list \
      {<a name=".*?">} {<a href=".*?">} {</a>} {<b>} {</b>} \
      {<dd>} {</dd>} {<dl>} {</dl>} {<dt>} {</dt>} {<li>} \
      {</li>} {<ol>} {</ol>} {<p>} {</p>} {<ul>} {</ul>}] {
    regsub -all -- $remove $result "" result

    if {[string length [string trim $result]] == 0} then {

      return ""
    }
  }

  regsub -all -- {<br>} $result \n result
  regsub -all -- {&ne;} $result {\&#8800;} result
  regsub -all -- {&#91(?:;)?} $result {[} result
  regsub -all -- {&#93(?:;)?} $result {]} result
  regsub -all -- {<( |\"|\d|=)} $result {\&lt;\1} result
  regsub -all -- {( |\"|\d|=)>} $result {\1\&gt;} result
  regsub -all -- {<blockquote><pre>} $result <code> result
  regsub -all -- {</pre></blockquote>} $result </code> result
  regsub -all -- {<blockquote>} $result <code> result
  regsub -all -- {</blockquote>} $result </code> result

  return $result
}

proc extractMethod { name lines pattern prefix indexVarName methodsVarName } {
  upvar 1 $indexVarName index
  upvar 1 $methodsVarName methods

  set paragraph 0
  set length [llength $lines]

  while {$index < $length} {
    set line [lindex $lines $index]

    if {[regexp -- $pattern $line]} then {
      break; # stop on this line for outer loop.
    } else {
      set trimLine [string trim $line]; set data ""

      if {$paragraph > 0 && [string length $trimLine] == 0} then {
        # blank line, close paragraph.
        append data \n $prefix </para>; incr paragraph -1
      } elseif {[string range $trimLine 0 2] eq "<p>"} then {
        # open paragraph ... maybe one line?
        if {[string range $trimLine end-3 end] eq "</p>"} then {
          set newLine [processLine $line]

          if {[string length $newLine] > 0} then {
            # one line paragraph, wrap.

            append data \n $prefix <para>

            append data \n $prefix $newLine
            append data \n $prefix </para>
          }
        } else {

          append data \n $prefix <para>




          set newLine [processLine $line]

          if {[string length $newLine] > 0} then {
            # open paragraph, add line to it.
            if {[info exists methods($name)]} then {
              # non-first line, leading line separator.
              append data \n $prefix $newLine
            } else {
              # first line, no leading line separator.
              append data $prefix $newLine
            }
          }

          incr paragraph
        }
      } else {
        set newLine [processLine $line]

        if {[string length $newLine] > 0} then {
          if {[info exists methods($name)]} then {
            # non-first line, leading line separator.
            append data \n $prefix $newLine
          } else {
            # first line, no leading line separator.
            append data $prefix $newLine
          }
        }
      }

      if {[string length $data] > 0} then {
        append methods($name) $data
      }

      incr index; # consume this line for outer loop.
    }
  }
}

#
# NOTE: This is the entry point for this script.
#
set path [file normalize [file dirname [info script]]]

set coreDocPath [file join $path Extra Core]
set interfacePath [file join [file dirname $path] System.Data.SQLite]
set inputFileName [file join $coreDocPath vtab.html]

if {![file exists $inputFileName]} then {
  puts "input file \"$inputFileName\" does not exist"
  exit 1
}

set outputFileName [file join $interfacePath ISQLiteNativeModule.cs]

if {![file exists $outputFileName]} then {
  puts "output file \"$outputFileName\" does not exist"
  exit 1
}

set lines [split [string map [list \r\n \n] [readFile $inputFileName]] \n]
set patterns(method) {^<h3>2\.\d+ The (.*) Method(?:s)?</h3>$}
set prefix "        /// "
set start false; array set methods {}




for {set index 0} {$index < [llength $lines]} {} {
  set line [lindex $lines $index]

  if {$start} then {
    if {[regexp -- {^<a name=".*"></a>$} $line]} then {
      incr index; continue
    }

    if {[regexp -- $patterns(method) $line dummy capture]} then {
      foreach method [englishToList $capture] {
        set methodIndex [expr {$index + 1}]

        extractMethod \
            $method $lines $patterns(method) $prefix methodIndex methods
      }

      set index $methodIndex
    } else {
      incr index
    }
  } elseif {[regexp -- {^<h2>2\.0 Virtual Table Methods</h2>$} $line]} then {
    set start true; incr index
  } else {
    incr index
  }
}



# exit 0