@@ -13,28 +13,24 @@ module.exports.buildDashDocSet = function (input) {
1313
1414 var zip = new admzip ( ) ,
1515 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' ) ;
1718
1819 input . uid = module . exports . formatStringForUID ( input . title ) ;
1920
2021 input . files . forEach ( function ( file ) {
2122
2223 file . methods . forEach ( function ( method ) {
2324
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+ ) ;
3229
3330 } ) ;
3431
3532 } ) ;
3633
37-
3834 zip . addFile (
3935 input . title + '.docset/Contents/Info.plist' ,
4036 require ( '../templates/dash/plist.hbs' ) ( input )
@@ -61,15 +57,11 @@ module.exports.buildDashDocSet = function (input) {
6157
6258 file . methods . forEach ( function ( method ) {
6359
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+ } ) ;
7365
7466 } ) ;
7567
@@ -92,7 +84,7 @@ module.exports.buildDashDocSet = function (input) {
9284
9385} ;
9486
95- module . exports . findPackage = function ( input ) {
87+ module . exports . findPackagePath = function ( input ) {
9688
9789 var pkg ,
9890 stat ;
@@ -117,6 +109,16 @@ module.exports.findPackage = function (input) {
117109
118110} ;
119111
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+
120122module . exports . formatStringForUID = function ( content ) {
121123
122124 content = String ( content ) . toLowerCase ( ) ;
@@ -130,31 +132,66 @@ module.exports.formatStringForUID = function (content) {
130132
131133module . exports . parseData = function ( data , file ) {
132134
133- data . forEach ( function ( method ) {
135+ var methods = [ ] ;
134136
135- if ( method . ctx ) {
137+ data . forEach ( function ( item ) {
136138
137- method . ctx . uid = file + '-' + module . exports . formatStringForUID ( method . ctx . string ) ;
139+ var method = { } ;
138140
139- }
141+ if ( ! item . ignore && item . ctx ) {
142+
143+ method . uid = module . exports . formatStringForUID ( file + '-' + item . ctx . string ) ;
140144
141- if ( method . tags ) {
145+ method . isPrivate = item . isPrivate ;
146+ method . type = item . ctx . type ;
147+ method . name = module . exports . formatStringForName ( item . ctx . string ) ;
142148
143- method . tags . forEach ( function ( tag ) {
149+ method . description = item . description . summary ;
150+ method . body = item . description . body ;
144151
145- if ( tag . name && tag . optional ) {
152+ method . tags = { } ;
153+ method . tags . example = [ ] ;
146154
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 ) ;
148183
149184 }
150185
151186 } ) ;
152187
188+ methods . push ( method ) ;
189+
153190 }
154191
155192 } ) ;
156193
157- return data ;
194+ return methods ;
158195
159196} ;
160197
0 commit comments