Skip to content

Commit ef01195

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 661a6d6 commit ef01195

22 files changed

+174
-3
lines changed

templates/coffeescript/app.coffee

Lines changed: 9 additions & 1 deletion
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.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
412
.config ($routeProvider) ->
513
$routeProvider
@@ -8,4 +16,4 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) {
816
controller: 'MainCtrl'
917
.otherwise
1018
redirectTo: '/'
11-
<% } %>
19+
<% } %>

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/Gruntfile.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ module.exports = function (grunt) {
3434
coffeeTest: {
3535
files: ['test/spec/{,*/}*.{coffee,litcoffee,coffee.md}'],
3636
tasks: ['newer:coffee:test', 'karma']
37+
},
38+
js: {
39+
files: ['.tmp/scripts/{,*/}*.js'],
40+
tasks: ['ngdocs'],
41+
options: {
42+
livereload: true
43+
}
3744
},<% } else { %>
3845
js: {
3946
files: ['<%%= yeoman.app %>/scripts/{,*/}*.js'],
40-
tasks: ['newer:jshint:all'],
47+
tasks: ['ngdocs', 'newer:jshint:all'],
4148
options: {
4249
livereload: true
4350
}
@@ -352,6 +359,16 @@ module.exports = function (grunt) {
352359
cwd: '<%%= yeoman.app %>/styles',
353360
dest: '.tmp/styles/',
354361
src: '{,*/}*.css'
362+
},
363+
ngdocs: {
364+
expand: true,
365+
cwd: '<%%= yeoman.app %>/docs',
366+
dest: '.tmp/docs/',
367+
src: [
368+
'*.{ico,png,txt}',
369+
'.htaccess',
370+
'*.html',
371+
]
355372
}
356373
},
357374

@@ -408,6 +425,13 @@ module.exports = function (grunt) {
408425
configFile: 'karma.conf.js',
409426
singleRun: true
410427
}
428+
},
429+
ngdocs: {
430+
options: {
431+
dest: '.tmp/docs',
432+
html5Mode: false
433+
},
434+
api: ['<% if (coffee) { %>.tmp<% } else { %><%%= yeoman.app %><% } %>/scripts/{,*/}*.js'],
411435
}
412436
});
413437

@@ -422,6 +446,7 @@ module.exports = function (grunt) {
422446
'bower-install',
423447
'concurrent:server',
424448
'autoprefixer',
449+
'ngdocs',
425450
'connect:livereload',
426451
'watch'
427452
]);
@@ -448,6 +473,7 @@ module.exports = function (grunt) {
448473
'autoprefixer',
449474
'concat',
450475
'ngmin',
476+
'ngdocs',
451477
'copy:dist',
452478
'cdnify',
453479
'cssmin',

templates/common/_package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"grunt-usemin": "~2.0.0",
2828
"jshint-stylish": "~0.1.3",
2929
"load-grunt-tasks": "~0.2.0",
30-
"time-grunt": "~0.2.1"
30+
"time-grunt": "~0.2.1",
31+
"grunt-ngdocs": "~0.1.7"
3132
},
3233
"engines": {
3334
"node": ">=0.10.0"

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.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
412
.config(function ($routeProvider) {
513
$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)