@@ -13,28 +13,24 @@ module.exports.buildDashDocSet = function (input) {
13
13
14
14
var zip = new admzip ( ) ,
15
15
tempdb = temp . openSync ( 'temp.sqlite' ) ,
16
- db = new sqlite3 . Database ( tempdb . path ) ;
16
+ db = new sqlite3 . Database ( tempdb . path ) ,
17
+ template = require ( '../templates/dash/method.hbs' ) ;
17
18
18
19
input . uid = module . exports . formatStringForUID ( input . title ) ;
19
20
20
21
input . files . forEach ( function ( file ) {
21
22
22
23
file . methods . forEach ( function ( method ) {
23
24
24
- if ( ! method . ignore && method . ctx ) {
25
-
26
- zip . addFile (
27
- input . title + '.docset/Contents/Resources/Documents/' + method . ctx . uid + '.html' ,
28
- require ( '../templates/dash/method.hbs' ) ( method )
29
- ) ;
30
-
31
- }
25
+ zip . addFile (
26
+ input . title + '.docset/Contents/Resources/Documents/' + method . uid + '.html' ,
27
+ template ( method )
28
+ ) ;
32
29
33
30
} ) ;
34
31
35
32
} ) ;
36
33
37
-
38
34
zip . addFile (
39
35
input . title + '.docset/Contents/Info.plist' ,
40
36
require ( '../templates/dash/plist.hbs' ) ( input )
@@ -61,15 +57,11 @@ module.exports.buildDashDocSet = function (input) {
61
57
62
58
file . methods . forEach ( function ( method ) {
63
59
64
- if ( ! method . ignore && method . ctx ) {
65
-
66
- db . run ( 'INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ($name, $type, $path);' , {
67
- $name : hbs . helpers . formatName ( method . ctx . string ) ,
68
- $type : method . ctx . type . replace ( / ^ [ a - z ] / , function ( match ) { return match . toUpperCase ( ) ; } ) ,
69
- $path : method . ctx . uid + '.html'
70
- } ) ;
71
-
72
- }
60
+ db . run ( 'INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ($name, $type, $path);' , {
61
+ $name : method . name ,
62
+ $type : method . type . replace ( / ^ [ a - z ] / , function ( match ) { return match . toUpperCase ( ) ; } ) ,
63
+ $path : method . uid + '.html'
64
+ } ) ;
73
65
74
66
} ) ;
75
67
@@ -92,7 +84,7 @@ module.exports.buildDashDocSet = function (input) {
92
84
93
85
} ;
94
86
95
- module . exports . findPackage = function ( input ) {
87
+ module . exports . findPackagePath = function ( input ) {
96
88
97
89
var pkg ,
98
90
stat ;
@@ -117,6 +109,16 @@ module.exports.findPackage = function (input) {
117
109
118
110
} ;
119
111
112
+ module . exports . formatStringForName = function ( content ) {
113
+
114
+ content = String ( content ) ;
115
+
116
+ content = content . replace ( / \. p r o t o t y p e / g, '' ) ;
117
+
118
+ return content ;
119
+
120
+ } ;
121
+
120
122
module . exports . formatStringForUID = function ( content ) {
121
123
122
124
content = String ( content ) . toLowerCase ( ) ;
@@ -130,31 +132,66 @@ module.exports.formatStringForUID = function (content) {
130
132
131
133
module . exports . parseData = function ( data , file ) {
132
134
133
- data . forEach ( function ( method ) {
135
+ var methods = [ ] ;
134
136
135
- if ( method . ctx ) {
137
+ data . forEach ( function ( item ) {
136
138
137
- method . ctx . uid = file + '-' + module . exports . formatStringForUID ( method . ctx . string ) ;
139
+ var method = { } ;
138
140
139
- }
141
+ if ( ! item . ignore && item . ctx ) {
142
+
143
+ method . uid = module . exports . formatStringForUID ( file + '-' + item . ctx . string ) ;
140
144
141
- if ( method . tags ) {
145
+ method . isPrivate = item . isPrivate ;
146
+ method . type = item . ctx . type ;
147
+ method . name = module . exports . formatStringForName ( item . ctx . string ) ;
142
148
143
- method . tags . forEach ( function ( tag ) {
149
+ method . description = item . description . summary ;
150
+ method . body = item . description . body ;
144
151
145
- if ( tag . name && tag . optional ) {
152
+ method . tags = { } ;
153
+ method . tags . example = [ ] ;
146
154
147
- tag . name = tag . name . replace ( / ^ \[ | \] $ / g, '' ) ;
155
+ item . tags . forEach ( function ( tag_data ) {
156
+
157
+ var tag = { } ;
158
+
159
+ if ( method . tags [ tag_data . type ] === undefined ) {
160
+
161
+ method . tags [ tag_data . type ] = [ ] ;
162
+
163
+ }
164
+
165
+ if ( tag_data . types && tag_data . types . length ) {
166
+
167
+ if ( tag_data . name ) {
168
+
169
+ tag . name = tag_data . name . replace ( / ^ \[ | \] $ / g, '' ) ;
170
+ tag . isOptional = tag_data . optional ;
171
+
172
+ }
173
+
174
+ tag . types = tag_data . types ;
175
+
176
+ tag . description = tag_data . description ;
177
+
178
+ method . tags [ tag_data . type ] . push ( tag ) ;
179
+
180
+ } else if ( tag_data . string ) {
181
+
182
+ method . tags [ tag_data . type ] . push ( tag_data . string ) ;
148
183
149
184
}
150
185
151
186
} ) ;
152
187
188
+ methods . push ( method ) ;
189
+
153
190
}
154
191
155
192
} ) ;
156
193
157
- return data ;
194
+ return methods ;
158
195
159
196
} ;
160
197
0 commit comments