Skip to content

Commit 998faf2

Browse files
committed
Update gulpfile to allow generating docs with demo and deploy to ghpages
1 parent 08e9d27 commit 998faf2

File tree

4 files changed

+75
-8
lines changed

4 files changed

+75
-8
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
node_modules/
22
bower_components/
33
coverage/
4+
docs
45
typings/
56
tmp
67
.publish

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
## Wiki
99
See the [wiki](https://github.com/Microsoft/PowerBI-JavaScript/wiki) for more details about embedding, service configuration, setting default page, page navigation, dynamically applying filters, and more.
1010

11+
## Code Docs
12+
See the [code docs](https://microsoft.github.io/PowerBI-JavaScript) for detailed information about classes, interfaces, types, etc.
13+
1114
## Demo
12-
### [https://microsoft.github.io/PowerBI-JavaScript](https://microsoft.github.io/PowerBI-JavaScript)
15+
See the [live demo](https://microsoft.github.io/PowerBI-JavaScript/demo) for sample application using the powerbi-client library in scenarios such as page navigation, applying filters, updating settings, and more.
1316

1417
## Installation
1518

gulpfile.js

+66-7
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ var ghPages = require('gulp-gh-pages'),
1010
tslint = require("gulp-tslint"),
1111
ts = require('gulp-typescript'),
1212
flatten = require('gulp-flatten'),
13-
rimraf = require('rimraf'),
13+
fs = require('fs'),
14+
del = require('del'),
15+
moment = require('moment'),
1416
merge = require('merge2'),
1517
karma = require('karma'),
18+
typedoc = require('gulp-typedoc'),
1619
webpack = require('webpack');
1720
webpackStream = require('webpack-stream'),
1821
webpackConfig = require('./webpack.config'),
@@ -25,11 +28,48 @@ var package = require('./package.json');
2528
var webpackBanner = package.name + " v" + package.version + " | (c) 2016 Microsoft Corporation " + package.license;
2629
var gulpBanner = "/*! " + webpackBanner + " */\n";
2730

28-
gulp.task('ghpages', function() {
29-
return gulp.src(['./demo/**/*'])
30-
.pipe(ghPages({
31-
force: true
32-
}));
31+
gulp.task('ghpages', 'Deploy documentation to gh-pages', ['nojekyll'], function () {
32+
return gulp.src(['./docs/**/*'], {
33+
dot: true
34+
})
35+
.pipe(ghPages({
36+
force: true,
37+
message: 'Update ' + moment().format('LLL')
38+
}));
39+
});
40+
41+
gulp.task("docs", 'Compile documentation from src code', function () {
42+
return gulp
43+
.src(["src/**/*.ts"])
44+
.pipe(typedoc({
45+
mode: 'modules',
46+
includeDeclarations: true,
47+
48+
// Output options (see typedoc docs)
49+
out: "./docs",
50+
json: "./docs/json/" + package.name + ".json",
51+
52+
// TypeDoc options (see typedoc docs)
53+
ignoreCompilerErrors: true,
54+
version: true
55+
}))
56+
;
57+
});
58+
59+
gulp.task('copydemotodocs', 'Copy the demo to the docs', function () {
60+
return gulp.src(["demo/**/*"])
61+
.pipe(gulp.dest("docs/demo"))
62+
;
63+
});
64+
65+
gulp.task('nojekyll', 'Add .nojekyll file to docs directory', function (done) {
66+
fs.writeFile('./docs/.nojekyll', '', function (error) {
67+
if (error) {
68+
throw error;
69+
}
70+
71+
done();
72+
});
3373
});
3474

3575
gulp.task('watch', 'Watches for changes', ['lint'], function () {
@@ -65,6 +105,16 @@ gulp.task('build', 'Runs a full build', function (done) {
65105
);
66106
});
67107

108+
gulp.task('build:docs', 'Build docs folder', function (done) {
109+
return runSequence(
110+
'clean:docs',
111+
'docs',
112+
'nojekyll',
113+
'copydemotodocs',
114+
done
115+
);
116+
});
117+
68118
gulp.task('config', 'Update config version with package version', function () {
69119
return gulp.src(['./src/config.ts'], {base: "./"})
70120
.pipe(replace(/version: '([^']+)'/, `version: '${package.version}'`))
@@ -78,7 +128,16 @@ gulp.task('header', 'Add header to distributed files', function () {
78128
});
79129

80130
gulp.task('clean', 'Cleans destination folder', function(done) {
81-
rimraf('./dist/', done);
131+
return del([
132+
'./dist/**/*'
133+
]);
134+
});
135+
136+
gulp.task('clean:docs', 'Clean docs directory', function () {
137+
return del([
138+
'docs/**/*',
139+
'docs'
140+
]);
82141
});
83142

84143
gulp.task('lint:ts', 'Lints all TypeScript', function() {

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"author": "Microsoft",
3131
"license": "MIT",
3232
"devDependencies": {
33+
"del": "^2.2.2",
3334
"es6-promise": "^3.2.1",
3435
"gulp": "^3.9.0",
3536
"gulp-concat": "^2.6.0",
@@ -42,6 +43,7 @@
4243
"gulp-replace": "^0.5.4",
4344
"gulp-sourcemaps": "^1.6.0",
4445
"gulp-tslint": "^4.3.4",
46+
"gulp-typedoc": "^2.0.0",
4547
"gulp-typescript": "^2.12.1",
4648
"gulp-uglify": "^1.5.1",
4749
"ignore-loader": "^0.1.1",
@@ -58,11 +60,13 @@
5860
"karma-phantomjs-launcher": "^1.0.0",
5961
"karma-spec-reporter": "0.0.23",
6062
"merge2": "^1.0.1",
63+
"moment": "^2.14.1",
6164
"phantomjs-prebuilt": "^2.1.3",
6265
"rimraf": "^2.5.1",
6366
"run-sequence": "^1.1.5",
6467
"ts-loader": "^0.8.1",
6568
"tslint": "^3.6.0",
69+
"typedoc": "^0.4.4",
6670
"typescript": "^1.8.10",
6771
"typings": "^1.3.2",
6872
"webpack": "^1.12.14",

0 commit comments

Comments
 (0)