From 12d7e82b94dd38a0622c54630885e87f3aa6c499 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Fri, 11 Sep 2015 16:25:46 -0500 Subject: [PATCH] chore(docs): docs search index gulp task --- package.json | 4 ++++ scripts/docs/gulp-tasks.js | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index d9b22287ce..e56309c1a0 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "del": "~1.1.1", "dgeni": "^0.4.1", "dgeni-packages": "^0.10.18", + "event-stream": "^3.3.1", "glob": "^5.0.14", "gulp": "~3.8.10", "gulp-autoprefixer": "^2.3.0", @@ -37,11 +38,14 @@ "gulp-typescript": "^2.7.7", "gulp-util": "^3.0.6", "gulp-watch": "^4.2.4", + "htmlparser2": "^3.8.3", + "js-yaml": "^3.4.2", "karma": "^0.12.31", "karma-chrome-launcher": "^0.1.7", "karma-jasmine": "^0.3.5", "lazypipe": "^0.2.3", "lodash": "^2.4.1", + "lunr": "^0.5.12", "minimist": "^1.1.3", "mkdirp": "^0.5.1", "node-html-encoder": "0.0.2", diff --git a/scripts/docs/gulp-tasks.js b/scripts/docs/gulp-tasks.js index df4635d339..99400d68fd 100644 --- a/scripts/docs/gulp-tasks.js +++ b/scripts/docs/gulp-tasks.js @@ -33,6 +33,14 @@ module.exports = function(gulp, flags) { gulp.task('docs.index', function() { + var lunr = require('lunr'); + var gutil = require('gulp-util'); + var es = require('event-stream'); + var yaml = require('js-yaml'); + var htmlparser = require('htmlparser2'); + var mkdirp = require('mkdirp'); + var fs = require('fs'); + var idx = lunr(function() { this.field('path'); this.field('title', {boost: 10}); @@ -49,22 +57,19 @@ module.exports = function(gulp, flags) { refId++; } - var docPath = buildConfig.dist + '/ionic-site'; + var docPath = 'dist/ionic-site/docs/v2'; gutil.log('Reading docs from', gutil.colors.cyan(docPath)); return gulp.src([ - docPath + '/docs/{components,guide,api,overview}/**/*.{md,html,markdown}', - docPath + '/docs/index.html', - docPath + '/getting-started/index.html', - docPath + '/tutorials/**/*.{md,html,markdown}', - docPath + '/_posts/**/*.{md,html,markdown}' + docPath + '/{guide,api,overview, what-is,utilities,ui,theming,native}/**/*.{md,html,markdown}', + docPath + '/index.md', ]) .pipe(es.map(function(file, callback) { //docs for gulp file objects: https://github.com/wearefractal/vinyl var contents = file.contents.toString(); //was buffer // Grab relative path from ionic-site root - var relpath = file.path.replace(RegExp('^.*?' + docPath + '/'), ''); + var relpath = file.path.replace(RegExp('^.*?' + docPath.replace('/docs/v2', '') + '/'), ''); // Read out the yaml portion of the Jekyll file var yamlStartIndex = contents.indexOf('---');