Skip to content

Commit 956aea7

Browse files
feat(gen) add grunt-ngdoc
Add jsdoc to generated text and add grunt-ngdocs generated documentation to /docs. Add grunt-ngdocs to package.json & Gruntfile.js. Basic support in js & coffee templates. Watch for changes in files & autoreload docs after regeneration. Init work at yeoman#550
1 parent 06a34d0 commit 956aea7

21 files changed

+172
-1
lines changed

templates/coffeescript/app.coffee

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
'use strict'
22

3+
=======
4+
###*
5+
* @ngdoc overview
6+
* @name <%= scriptAppName %>
7+
* @description
8+
* # <%= scriptAppName %>
9+
*
10+
* Main module of the application.
11+
###
312
angular
413
.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
514
.config ($routeProvider) ->

templates/coffeescript/controller.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict'
22

3+
###*
4+
* @ngdoc function
5+
* @name <%= scriptAppName %>.controller:<%= classedName %>Ctrl
6+
* @description
7+
* # <%= classedName %>Ctrl
8+
* Controller of the <%= scriptAppName %>
9+
###
310
angular.module('<%= scriptAppName %>')
411
.controller '<%= classedName %>Ctrl', ($scope) ->
512
$scope.awesomeThings = [

templates/coffeescript/decorator.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict'
22

3+
###*
4+
* @ngdoc function
5+
* @name <%= scriptAppName %>.decorator:<%= classedName %>
6+
* @description
7+
* # <%= classedName %>Ctrl
8+
* Decorator of the <%= scriptAppName %>
9+
###
310
angular.module("<%= scriptAppName %>").config ($provide) ->
411
$provide.decorator "<%= cameledName %>", ($delegate) ->
512
# decorate the $delegate

templates/coffeescript/directive.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict'
22

3+
###*
4+
* @ngdoc directive
5+
* @name <%= scriptAppName %>.directive:<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Directive to replace content with custom text.
9+
###
310
angular.module('<%= scriptAppName %>')
411
.directive('<%= cameledName %>', ->
512
template: '<div></div>'

templates/coffeescript/filter.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
'use strict'
22

3+
###*
4+
* @ngdoc filter
5+
* @name <%= scriptAppName %>.filter:<%= cameledName %>
6+
* @function
7+
* @description
8+
* # <%= cameledName %>
9+
* Filter to change your value.
10+
###
311
angular.module('<%= scriptAppName %>')
412
.filter '<%= cameledName %>', ->
513
(input) ->
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
'use strict'
22

3+
###*
4+
* @ngdoc service
5+
* @name <%= scriptAppName %>.<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Constat in the <%= scriptAppName %>.
9+
###
310
angular.module('<%= scriptAppName %>')
411
.constant '<%= cameledName %>', 42

templates/coffeescript/service/factory.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict'
22

3+
###*
4+
* @ngdoc service
5+
* @name <%= scriptAppName %>.<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Factory in the <%= scriptAppName %>.
9+
###
310
angular.module('<%= scriptAppName %>')
411
.factory '<%= cameledName %>', ->
512
# Service logic

templates/coffeescript/service/provider.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict'
22

3+
###*
4+
* @ngdoc service
5+
* @name <%= scriptAppName %>.<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Provider in the <%= scriptAppName %>.
9+
###
310
angular.module('<%= scriptAppName %>')
411
.provider '<%= cameledName %>', [->
512

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict'
22

3+
###*
4+
* @ngdoc service
5+
* @name <%= scriptAppName %>.<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Service in the <%= scriptAppName %>.
9+
###
310
angular.module('<%= scriptAppName %>')
411
.service '<%= classedName %>', ->
512
# AngularJS will instantiate a singleton by calling "new" on this function
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
'use strict'
22

3+
###*
4+
* @ngdoc service
5+
* @name <%= scriptAppName %>.<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Value in the <%= scriptAppName %>.
9+
###
310
angular.module('<%= scriptAppName %>')
411
.value '<%= cameledName %>', 42

templates/common/root/_Gruntfile.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,17 @@ module.exports = function (grunt) {
3838
coffeeTest: {
3939
files: ['test/spec/{,*/}*.{coffee,litcoffee,coffee.md}'],
4040
tasks: ['newer:coffee:test', 'karma']
41+
},
42+
js: {
43+
files: ['.tmp/scripts/{,*/}*.js'],
44+
tasks: ['ngdocs'],
45+
options: {
46+
livereload: true
47+
}
4148
},<% } else { %>
4249
js: {
4350
files: ['<%%= yeoman.app %>/scripts/{,*/}*.js'],
44-
tasks: ['newer:jshint:all'],
51+
tasks: ['ngdocs', 'newer:jshint:all'],
4552
options: {
4653
livereload: '<%%= connect.options.livereload %>'
4754
}
@@ -392,6 +399,16 @@ module.exports = function (grunt) {
392399
cwd: '<%%= yeoman.app %>/styles',
393400
dest: '.tmp/styles/',
394401
src: '{,*/}*.css'
402+
},
403+
ngdocs: {
404+
expand: true,
405+
cwd: '<%%= yeoman.app %>/docs',
406+
dest: '.tmp/docs/',
407+
src: [
408+
'*.{ico,png,txt}',
409+
'.htaccess',
410+
'*.html',
411+
]
395412
}
396413
},
397414

@@ -422,6 +439,13 @@ module.exports = function (grunt) {
422439
configFile: 'karma.conf.js',
423440
singleRun: true
424441
}
442+
},
443+
ngdocs: {
444+
options: {
445+
dest: '.tmp/docs',
446+
html5Mode: false
447+
},
448+
api: ['<% if (coffee) { %>.tmp<% } else { %><%%= yeoman.app %><% } %>/scripts/{,*/}*.js'],
425449
}
426450
});
427451

@@ -436,6 +460,7 @@ module.exports = function (grunt) {
436460
'bowerInstall',
437461
'concurrent:server',
438462
'autoprefixer',
463+
'ngdocs',
439464
'connect:livereload',
440465
'watch'
441466
]);
@@ -462,6 +487,7 @@ module.exports = function (grunt) {
462487
'autoprefixer',
463488
'concat',
464489
'ngmin',
490+
'ngdocs',
465491
'copy:dist',
466492
'cdnify',
467493
'cssmin',

templates/javascript/app.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
'use strict';
22

3+
/**
4+
* @ngdoc overview
5+
* @name <%= scriptAppName %>
6+
* @description
7+
* # <%= scriptAppName %>
8+
*
9+
* Main module of the application.
10+
*/
311
angular
412
.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
513
.config(function ($routeProvider) {

templates/javascript/controller.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict';
22

3+
/**
4+
* @ngdoc function
5+
* @name <%= scriptAppName %>.controller:<%= classedName %>Ctrl
6+
* @description
7+
* # <%= classedName %>Ctrl
8+
* Controller of the <%= scriptAppName %>
9+
*/
310
angular.module('<%= scriptAppName %>')
411
.controller('<%= classedName %>Ctrl', function ($scope) {
512
$scope.awesomeThings = [

templates/javascript/decorator.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict';
22

3+
/**
4+
* @ngdoc function
5+
* @name <%= scriptAppName %>.decorator:<%= classedName %>
6+
* @description
7+
* # <%= classedName %>Ctrl
8+
* Decorator of the <%= scriptAppName %>
9+
*/
310
angular.module('<%= scriptAppName %>')
411
.config(function ($provide) {
512
$provide.decorator('<%= cameledName %>', function ($delegate) {

templates/javascript/directive.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict';
22

3+
/**
4+
* @ngdoc directive
5+
* @name <%= scriptAppName %>.directive:<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Directive to replace content with custom text.
9+
*/
310
angular.module('<%= scriptAppName %>')
411
.directive('<%= cameledName %>', function () {
512
return {

templates/javascript/filter.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
'use strict';
22

3+
/**
4+
* @ngdoc filter
5+
* @name <%= scriptAppName %>.filter:<%= cameledName %>
6+
* @function
7+
* @description
8+
* # <%= cameledName %>
9+
* Filter to change your value.
10+
*/
311
angular.module('<%= scriptAppName %>')
412
.filter('<%= cameledName %>', function () {
513
return function (input) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
'use strict';
22

3+
/**
4+
* @ngdoc service
5+
* @name <%= scriptAppName %>.<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Constat in the <%= scriptAppName %>.
9+
*/
310
angular.module('<%= scriptAppName %>')
411
.constant('<%= cameledName %>', 42);

templates/javascript/service/factory.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict';
22

3+
/**
4+
* @ngdoc service
5+
* @name <%= scriptAppName %>.<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Factory in the <%= scriptAppName %>.
9+
*/
310
angular.module('<%= scriptAppName %>')
411
.factory('<%= cameledName %>', function () {
512
// Service logic

templates/javascript/service/provider.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict';
22

3+
/**
4+
* @ngdoc service
5+
* @name <%= scriptAppName %>.<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Provider in the <%= scriptAppName %>.
9+
*/
310
angular.module('<%= scriptAppName %>')
411
.provider('<%= cameledName %>', function () {
512

templates/javascript/service/service.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict';
22

3+
/**
4+
* @ngdoc service
5+
* @name <%= scriptAppName %>.<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Service in the <%= scriptAppName %>.
9+
*/
310
angular.module('<%= scriptAppName %>')
411
.service('<%= classedName %>', function <%= classedName %>() {
512
// AngularJS will instantiate a singleton by calling "new" on this function

templates/javascript/service/value.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
'use strict';
22

3+
/**
4+
* @ngdoc service
5+
* @name <%= scriptAppName %>.<%= cameledName %>
6+
* @description
7+
* # <%= cameledName %>
8+
* Value in the <%= scriptAppName %>.
9+
*/
310
angular.module('<%= scriptAppName %>')
411
.value('<%= cameledName %>', 42);

0 commit comments

Comments
 (0)