chore(docs): docs search index gulp task

This commit is contained in:
Tim Lancina
2015-09-11 16:25:46 -05:00
parent 887da9c216
commit 12d7e82b94
2 changed files with 16 additions and 7 deletions

View File

@ -22,6 +22,7 @@
"del": "~1.1.1", "del": "~1.1.1",
"dgeni": "^0.4.1", "dgeni": "^0.4.1",
"dgeni-packages": "^0.10.18", "dgeni-packages": "^0.10.18",
"event-stream": "^3.3.1",
"glob": "^5.0.14", "glob": "^5.0.14",
"gulp": "~3.8.10", "gulp": "~3.8.10",
"gulp-autoprefixer": "^2.3.0", "gulp-autoprefixer": "^2.3.0",
@ -37,11 +38,14 @@
"gulp-typescript": "^2.7.7", "gulp-typescript": "^2.7.7",
"gulp-util": "^3.0.6", "gulp-util": "^3.0.6",
"gulp-watch": "^4.2.4", "gulp-watch": "^4.2.4",
"htmlparser2": "^3.8.3",
"js-yaml": "^3.4.2",
"karma": "^0.12.31", "karma": "^0.12.31",
"karma-chrome-launcher": "^0.1.7", "karma-chrome-launcher": "^0.1.7",
"karma-jasmine": "^0.3.5", "karma-jasmine": "^0.3.5",
"lazypipe": "^0.2.3", "lazypipe": "^0.2.3",
"lodash": "^2.4.1", "lodash": "^2.4.1",
"lunr": "^0.5.12",
"minimist": "^1.1.3", "minimist": "^1.1.3",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"node-html-encoder": "0.0.2", "node-html-encoder": "0.0.2",

View File

@ -33,6 +33,14 @@ module.exports = function(gulp, flags) {
gulp.task('docs.index', function() { 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() { var idx = lunr(function() {
this.field('path'); this.field('path');
this.field('title', {boost: 10}); this.field('title', {boost: 10});
@ -49,22 +57,19 @@ module.exports = function(gulp, flags) {
refId++; refId++;
} }
var docPath = buildConfig.dist + '/ionic-site'; var docPath = 'dist/ionic-site/docs/v2';
gutil.log('Reading docs from', gutil.colors.cyan(docPath)); gutil.log('Reading docs from', gutil.colors.cyan(docPath));
return gulp.src([ return gulp.src([
docPath + '/docs/{components,guide,api,overview}/**/*.{md,html,markdown}', docPath + '/{guide,api,overview, what-is,utilities,ui,theming,native}/**/*.{md,html,markdown}',
docPath + '/docs/index.html', docPath + '/index.md',
docPath + '/getting-started/index.html',
docPath + '/tutorials/**/*.{md,html,markdown}',
docPath + '/_posts/**/*.{md,html,markdown}'
]) ])
.pipe(es.map(function(file, callback) { .pipe(es.map(function(file, callback) {
//docs for gulp file objects: https://github.com/wearefractal/vinyl //docs for gulp file objects: https://github.com/wearefractal/vinyl
var contents = file.contents.toString(); //was buffer var contents = file.contents.toString(); //was buffer
// Grab relative path from ionic-site root // 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 // Read out the yaml portion of the Jekyll file
var yamlStartIndex = contents.indexOf('---'); var yamlStartIndex = contents.indexOf('---');