From 28e6ba3c80df967482314a4448825fc0d0bc70e6 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sat, 22 Aug 2015 05:13:17 +0200 Subject: [PATCH] showcase: generate ngdocs --- angularjs/showcase/gulpfile.js | 47 +++++++++++++++++++--- angularjs/showcase/package.json | 1 + angularjs/showcase/server/server.config.js | 2 +- angularjs/showcase/server/server.js | 13 +++++- .../src/showcase/app/welcome/welcome.controller.js | 9 ++++- .../src/showcase/app/welcome/welcome.module.js | 4 +- .../src/showcase/app/welcome/welcome.route.js | 11 ++++- 7 files changed, 74 insertions(+), 13 deletions(-) diff --git a/angularjs/showcase/gulpfile.js b/angularjs/showcase/gulpfile.js index 16d191b..c8fb00d 100644 --- a/angularjs/showcase/gulpfile.js +++ b/angularjs/showcase/gulpfile.js @@ -321,6 +321,31 @@ gulp.task('templatecache', ['clean'], function() { * @ngdoc function * * @description + * Generate documentation + * + * @returns {stream} + */ +gulp.task('ngdocs', function() { + var gulpDocs = require('gulp-ngdocs'); + var options = { + html5Mode: true, + startPage: '/api/app', + title: 'Showcase' + }; + return gulpDocs.sections({ + api: { + glob:['src/**/*.js', '!src/**/*.spec.js'], + api: true, + title: 'API Documentation' + }}) + .pipe(gulpDocs.process(options)) + .pipe(gulp.dest('./docs')); +}); + +/** + * @ngdoc function + * + * @description * Inject files in a sorted sequence at a specified inject label. * * @param {Array|string} source Source files (glob patterns) @@ -350,15 +375,17 @@ function inject(source, label) { function server(environment) { var nodeOptions = { script: serverConfig.script, - delayTime: 1, env: { - 'NODE_ENV': environment ? environment : 'development' + 'NODE_ENV': environment ? environment : 'development', + 'VERBOSE': args.verbose ? true : false }, - watch: [serverConfig.directory] + verbose: args.verbose ? true : false, + watch: [serverConfig.directory], + delay: 250 // 250ms }; return plugins.nodemon(nodeOptions) - .on('restart', ['vet'], function(ev) { + .on('restart', function(ev) { log('HTTP server restarted'); log('files changed:\n' + ev); }) @@ -456,11 +483,21 @@ function synchronization(environment) { gulp.start('build', done); })); break; + case 'ngdocs': + plugins.watch(jsFiles, { + name: 'Files synchronization', + verbose: true, + readDelay: 250 + }, plugins.batch(function (events, done) { + // TODO: gulp.start going to be deprecated in gulp 4.0.0 version. Alternatives? + gulp.start('ngdocs', done); + })); + break; default: plugins.watch(jsFiles, { name: 'Files synchronization', verbose: true, - readDelay: 200 + readDelay: 250 }, plugins.batch(function (events, done) { // TODO: gulp.start going to be deprecated in gulp 4.0.0 version. Alternatives? gulp.start('wireup', done); diff --git a/angularjs/showcase/package.json b/angularjs/showcase/package.json index e14a7ef..3c06611 100644 --- a/angularjs/showcase/package.json +++ b/angularjs/showcase/package.json @@ -29,6 +29,7 @@ "gulp-minify-css": "~1.2.0", "gulp-minify-html": "~1.0.4", "gulp-ng-annotate": "~1.1.0", + "gulp-ngdocs": "~0.2.13", "gulp-nodemon": "~2.0.3", "gulp-order": "~1.1.1", "gulp-print": "~1.1.0", diff --git a/angularjs/showcase/server/server.config.js b/angularjs/showcase/server/server.config.js index d0b022a..6616a66 100644 --- a/angularjs/showcase/server/server.config.js +++ b/angularjs/showcase/server/server.config.js @@ -5,7 +5,7 @@ module.exports = function() { index: main + 'index.html', port: 9000, script: 'server/server.js', - directory: 'server/' + directory: './server/' }; return config; diff --git a/angularjs/showcase/server/server.js b/angularjs/showcase/server/server.js index 917c263..c9a0b14 100644 --- a/angularjs/showcase/server/server.js +++ b/angularjs/showcase/server/server.js @@ -7,9 +7,12 @@ var logger = require('morgan'); var config = require('./server.config')(); var port = config.port; var environment = process.env.NODE_ENV; +var verbose = process.env.VERBOSE; app.use(favicon(__dirname + '/favicon.ico')); -app.use(logger('dev')); +if (verbose && verbose === true) { + app.use(logger('dev')); +} switch (environment) { case 'production': @@ -20,6 +23,14 @@ switch (environment) { // Deep linking app.use('/*', express.static('./build/index.html')); break; + case 'ngdocs': + console.log('ngdocs mode'); + + app.use(express.static('./docs')); + + // Deep linking + app.use('/*', express.static('./docs')); + break; default: console.log('development mode'); diff --git a/angularjs/showcase/src/showcase/app/welcome/welcome.controller.js b/angularjs/showcase/src/showcase/app/welcome/welcome.controller.js index c4651cf..dacf8b5 100644 --- a/angularjs/showcase/src/showcase/app/welcome/welcome.controller.js +++ b/angularjs/showcase/src/showcase/app/welcome/welcome.controller.js @@ -11,11 +11,16 @@ // Welcome.$inject = ['$location']; /** - * @ngdoc object - * @name app.welcome.$Welcome + * @ngdoc controller + * @name app.welcome.controller:Welcome * * @requires $location * + *

+ *
+ * {@link https://docs.angularjs.org/api/ng/service/$location $location} + *

+ * * @description * Welcome controller. */ diff --git a/angularjs/showcase/src/showcase/app/welcome/welcome.module.js b/angularjs/showcase/src/showcase/app/welcome/welcome.module.js index 6d13da4..2115c9f 100644 --- a/angularjs/showcase/src/showcase/app/welcome/welcome.module.js +++ b/angularjs/showcase/src/showcase/app/welcome/welcome.module.js @@ -3,7 +3,7 @@ /** * @ngdoc overview - * @name ui.router.util + * @name app.welcome * * @requires app.core * @@ -11,7 +11,7 @@ * # app.welcome * * ## Module welcome. - * Module in charge of displaying a nice welcome page. + * Module in charge of displaying a nice welcome page. LOL ROLF */ angular.module('app.welcome', [ 'app.core' diff --git a/angularjs/showcase/src/showcase/app/welcome/welcome.route.js b/angularjs/showcase/src/showcase/app/welcome/welcome.route.js index eaba189..a765caa 100644 --- a/angularjs/showcase/src/showcase/app/welcome/welcome.route.js +++ b/angularjs/showcase/src/showcase/app/welcome/welcome.route.js @@ -6,12 +6,19 @@ .config(configure); /** - * @ngdoc object - * @name app.welcome.$configure + * @ngdoc service + * @name app.welcome.configure * * @requires $stateProvider * @requires $urlRouterProvider * + *

+ *
+ * {@link http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$stateProvider $stateProvider}
+ * {@link http://angular-ui.github.io/ui-router/site/#/api/ui.router.router.$urlRouterProvider $urlRouterProvider} + *

+ * + * * @description * Router configuration for welcome application. */ -- 2.1.4