@@ -9,15 +9,11 @@ var argv = require('minimist')(process.argv.slice(2));
9
9
var _ = require ( 'lodash' ) ;
10
10
var buildConfig = require ( './config/build.config.js' ) ;
11
11
var changelog = require ( 'conventional-changelog' ) ;
12
- var dgeni = require ( 'dgeni' ) ;
13
12
var es = require ( 'event-stream' ) ;
14
- var htmlparser = require ( 'htmlparser2' ) ;
15
13
var irc = require ( 'ircb' ) ;
16
- var lunr = require ( 'lunr' ) ;
17
14
var marked = require ( 'marked' ) ;
18
15
var mkdirp = require ( 'mkdirp' ) ;
19
16
var twitter = require ( 'node-twitter-api' ) ;
20
- var yaml = require ( 'js-yaml' ) ;
21
17
22
18
var cp = require ( 'child_process' ) ;
23
19
var fs = require ( 'fs' ) ;
@@ -50,6 +46,11 @@ if (IS_RELEASE_BUILD) {
50
46
*/
51
47
require ( './config/gulp-tasks/test' ) ( gulp , argv ) ;
52
48
49
+ /**
50
+ * Load Docs Tasks
51
+ */
52
+ require ( './config/gulp-tasks/docs' ) ( gulp , argv ) ;
53
+
53
54
if ( argv . dist ) {
54
55
buildConfig . dist = argv . dist ;
55
56
}
@@ -58,53 +59,6 @@ gulp.task('default', ['build']);
58
59
gulp . task ( 'build' , [ 'bundle' , 'sass' ] ) ;
59
60
gulp . task ( 'validate' , [ 'jshint' , 'ddescribe-iit' , 'karma' ] ) ;
60
61
61
- gulp . task ( 'docs' , function ( ) {
62
- var docVersion = argv [ 'doc-version' ] || 'nightly' ;
63
- if ( docVersion != 'nightly' && ! semver . valid ( docVersion ) ) {
64
- console . log ( 'Usage: gulp docs --doc-version=(nightly|versionName)' ) ;
65
- return process . exit ( 1 ) ;
66
- }
67
-
68
- var config = dgeni . loadConfig ( path . join ( __dirname , '/config/docs/docs.config.js' ) ) ;
69
- config . set ( 'currentVersion' , docVersion ) ;
70
- config . set (
71
- 'rendering.outputFolder' ,
72
- argv . dist ? argv . dist : path . resolve ( __dirname , buildConfig . dist , 'ionic-site' )
73
- ) ;
74
-
75
- return dgeni . generator ( config ) ( ) . then ( function ( ) {
76
- gutil . log ( 'Docs for' , gutil . colors . cyan ( docVersion ) , 'generated!' ) ;
77
- } ) ;
78
- } ) ;
79
-
80
- gulp . task ( 'demos' , function ( done ) {
81
- var demoVersion = argv [ 'demo-version' ] || 'nightly' ;
82
- if ( demoVersion != 'nightly' && ! semver . valid ( demoVersion ) ) {
83
- console . log ( 'Usage: gulp docs --doc-version=(nightly|versionName)' ) ;
84
- return process . exit ( 1 ) ;
85
- }
86
-
87
- var config = dgeni . loadConfig ( path . join ( __dirname , '/config/demos/demos.config.js' ) ) ;
88
- config . set ( 'currentVersion' , demoVersion ) ;
89
- config . set ( 'dist' , buildConfig . dist ) ;
90
- config . set (
91
- 'rendering.outputFolder' ,
92
- argv . dist ? argv . dist : path . resolve ( __dirname , buildConfig . dist , 'ionic-demo' )
93
- ) ;
94
-
95
- dgeni . generator ( config ) ( ) . then ( function ( ) {
96
- gutil . log ( 'Demos for' , gutil . colors . cyan ( demoVersion ) , 'generated!' ) ;
97
- gutil . log ( 'Building ionic into demo folder...' ) ;
98
- cp . spawn ( 'node' , [
99
- __dirname + '/node_modules/.bin/gulp' ,
100
- 'build' ,
101
- IS_RELEASE_BUILD ? '--release' : '--no-release' ,
102
- '--dist=' + config . rendering . outputFolder + '/' +
103
- config . rendering . contentsFolder + '/ionic'
104
- ] )
105
- . on ( 'exit' , done ) ;
106
- } ) ;
107
- } ) ;
108
62
109
63
var IS_WATCH = false ;
110
64
gulp . task ( 'watch' , [ 'build' ] , function ( ) {
@@ -288,137 +242,6 @@ gulp.task('release-irc', function(done) {
288
242
} ) ;
289
243
} ) ;
290
244
291
- gulp . task ( 'docs-index' , function ( ) {
292
- var idx = lunr ( function ( ) {
293
- this . field ( 'path' ) ;
294
- this . field ( 'title' , { boost : 10 } ) ;
295
- this . field ( 'body' ) ;
296
- this . ref ( 'id' ) ;
297
- } ) ;
298
- var ref = { } ;
299
- var refId = 0 ;
300
-
301
- function addToIndex ( path , title , layout , body ) {
302
- // Add the data to the indexer and ref object
303
- idx . add ( { 'path' : path , 'body' : body , 'title' : title , id : refId } ) ;
304
- ref [ refId ] = { 'p' : path , 't' : title , 'l' : layout } ;
305
- refId ++ ;
306
- }
307
-
308
- return gulp . src ( [
309
- 'temp/ionic-site/docs/{components,guide,api,overview}/**/*.{md,html,markdown}' ,
310
- 'temp/ionic-site/docs/index.html' ,
311
- 'temp/ionic-site/getting-started/index.html' ,
312
- 'temp/ionic-site/tutorials/**/*.{md,html,markdown}' ,
313
- 'temp/ionic-site/_posts/**/*.{md,html,markdown}'
314
- ] )
315
- . pipe ( es . map ( function ( file , callback ) {
316
- //docs for gulp file objects: https://github.com/wearefractal/vinyl
317
- var contents = file . contents . toString ( ) ; //was buffer
318
-
319
- // Grab relative path from ionic-site root
320
- var relpath = file . path . replace ( / ^ .* ?t e m p \/ i o n i c - s i t e \/ / , '' ) ;
321
-
322
- // Read out the yaml portion of the Jekyll file
323
- var yamlStartIndex = contents . indexOf ( '---' ) ;
324
-
325
- if ( yamlStartIndex === - 1 ) {
326
- return callback ( ) ;
327
- }
328
-
329
- // read Jekyll's page yaml variables at the top of the file
330
- var yamlEndIndex = contents . indexOf ( '---' , yamlStartIndex + 3 ) ; //starting from start
331
- var yamlRaw = contents . substring ( yamlStartIndex + 3 , yamlEndIndex ) ;
332
-
333
- var pageData = yaml . safeLoad ( yamlRaw ) ;
334
- if ( ! pageData . title || ! pageData . layout ) {
335
- return callback ( ) ;
336
- }
337
-
338
- // manually set to not be searchable, or for a blog post, manually set to be searchable
339
- if ( pageData . searchable === false || ( pageData . layout == 'post' && pageData . searchable !== true ) ) {
340
- return callback ( ) ;
341
- }
342
-
343
- // clean up some content so code variables are searchable too
344
- contents = contents . substring ( yamlEndIndex + 3 ) ;
345
- contents = contents . replace ( / < c o d e ? > / gi, '' ) ;
346
- contents = contents . replace ( / < \/ c o d e > / gi, '' ) ;
347
- contents = contents . replace ( / < c o d e ? > < / gi, '' ) ;
348
- contents = contents . replace ( / > < \/ c o d e > / gi, '' ) ;
349
- contents = contents . replace ( / ` < / gi, '' ) ;
350
- contents = contents . replace ( / > ` / gi, '' ) ;
351
-
352
- // create a clean path to the URL
353
- var path = '/' + relpath . replace ( 'index.md' , '' )
354
- . replace ( 'index.html' , '' )
355
- . replace ( '.md' , '.html' )
356
- . replace ( '.markdown' , '.html' ) ;
357
- if ( pageData . layout == 'post' ) {
358
- path = '/blog/' + path . substring ( 19 ) . replace ( '.html' , '/' ) ;
359
- }
360
-
361
- var parser ;
362
- if ( pageData . search_sections === true ) {
363
- // each section within the content should be its own search result
364
- var section = { body : '' , title : '' } ;
365
- var isTitleOpen = false ;
366
-
367
- parser = new htmlparser . Parser ( {
368
- ontext : function ( text ) {
369
- if ( isTitleOpen ) {
370
- section . title += text ; // get the title of this section
371
- } else {
372
- section . body += text . replace ( / { % .* % } / , '' , 'g' ) ; // Ignore any Jekyll expressions
373
- }
374
- } ,
375
- onopentag : function ( name , attrs ) {
376
- if ( name == 'section' && attrs . id ) {
377
- // start building new section data
378
- section = { body : '' , path : path + '#' + attrs . id , title : '' } ;
379
- } else if ( ( name == 'h1' || name == 'h2' || name == 'h3' ) && attrs . class == 'title' ) {
380
- isTitleOpen = true ; // the next text will be this sections title
381
- }
382
- } ,
383
- onclosetag : function ( name ) {
384
- if ( name == 'section' ) {
385
- // section closed, index this section then clear it out
386
- addToIndex ( section . path , section . title , pageData . layout , section . body ) ;
387
- section = { body : '' , title : '' } ;
388
- } else if ( ( name == 'h1' || name == 'h2' || name == 'h3' ) && isTitleOpen ) {
389
- isTitleOpen = false ;
390
- }
391
- }
392
- } ) ;
393
- parser . write ( contents ) ;
394
- parser . end ( ) ;
395
-
396
- } else {
397
- // index the entire page
398
- var body = '' ;
399
- parser = new htmlparser . Parser ( {
400
- ontext : function ( text ) {
401
- body += text . replace ( / { % .* % } / , '' , 'g' ) ; // Ignore any Jekyll expressions
402
- }
403
- } ) ;
404
- parser . write ( contents ) ;
405
- parser . end ( ) ;
406
-
407
- addToIndex ( path , pageData . title , pageData . layout , body ) ;
408
- }
409
-
410
- callback ( ) ;
411
-
412
- } ) ) . on ( 'end' , function ( ) {
413
- // Write out as one json file
414
- mkdirp . sync ( 'temp/ionic-site/data' ) ;
415
- fs . writeFileSync (
416
- 'temp/ionic-site/data/index.json' ,
417
- JSON . stringify ( { 'ref' : ref , 'index' : idx . toJSON ( ) } )
418
- ) ;
419
- } ) ;
420
- } ) ;
421
-
422
245
function notContains ( disallowed ) {
423
246
disallowed = disallowed || [ ] ;
424
247
0 commit comments