Skip to content

Commit

Permalink
feat(gen) add grunt-ngdoc
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marcin-wosinek committed Feb 16, 2014
1 parent 661a6d6 commit ef01195
Show file tree
Hide file tree
Showing 22 changed files with 174 additions and 3 deletions.
10 changes: 9 additions & 1 deletion templates/coffeescript/app.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
'use strict'

###*
* @ngdoc overview
* @name <%= scriptAppName %>
* @description
* # <%= scriptAppName %>
*
* Main module of the application.
###
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
.config ($routeProvider) ->
$routeProvider
Expand All @@ -8,4 +16,4 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) {
controller: 'MainCtrl'
.otherwise
redirectTo: '/'
<% } %>
<% } %>
7 changes: 7 additions & 0 deletions templates/coffeescript/controller.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict'

###*
* @ngdoc function
* @name <%= scriptAppName %>.controller:<%= classedName %>Ctrl
* @description
* # <%= classedName %>Ctrl
* Controller of the <%= scriptAppName %>
###
angular.module('<%= scriptAppName %>')
.controller '<%= classedName %>Ctrl', ($scope) ->
$scope.awesomeThings = [
Expand Down
7 changes: 7 additions & 0 deletions templates/coffeescript/decorator.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict'

###*
* @ngdoc function
* @name <%= scriptAppName %>.decorator:<%= classedName %>
* @description
* # <%= classedName %>Ctrl
* Decorator of the <%= scriptAppName %>
###
angular.module("<%= scriptAppName %>").config ($provide) ->
$provide.decorator "<%= cameledName %>", ($delegate) ->
# decorate the $delegate
Expand Down
7 changes: 7 additions & 0 deletions templates/coffeescript/directive.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict'

###*
* @ngdoc directive
* @name <%= scriptAppName %>.directive:<%= cameledName %>
* @description
* # <%= cameledName %>
* Directive to replace content with custom text.
###
angular.module('<%= scriptAppName %>')
.directive('<%= cameledName %>', ->
template: '<div></div>'
Expand Down
8 changes: 8 additions & 0 deletions templates/coffeescript/filter.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
'use strict'

###*
* @ngdoc filter
* @name <%= scriptAppName %>.filter:<%= cameledName %>
* @function
* @description
* # <%= cameledName %>
* Filter to change your value.
###
angular.module('<%= scriptAppName %>')
.filter '<%= cameledName %>', ->
(input) ->
Expand Down
7 changes: 7 additions & 0 deletions templates/coffeescript/service/constant.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
'use strict'

###*
* @ngdoc service
* @name <%= scriptAppName %>.<%= cameledName %>
* @description
* # <%= cameledName %>
* Constat in the <%= scriptAppName %>.
###
angular.module('<%= scriptAppName %>')
.constant '<%= cameledName %>', 42
7 changes: 7 additions & 0 deletions templates/coffeescript/service/factory.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict'

###*
* @ngdoc service
* @name <%= scriptAppName %>.<%= cameledName %>
* @description
* # <%= cameledName %>
* Factory in the <%= scriptAppName %>.
###
angular.module('<%= scriptAppName %>')
.factory '<%= cameledName %>', ->
# Service logic
Expand Down
7 changes: 7 additions & 0 deletions templates/coffeescript/service/provider.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict'

###*
* @ngdoc service
* @name <%= scriptAppName %>.<%= cameledName %>
* @description
* # <%= cameledName %>
* Provider in the <%= scriptAppName %>.
###
angular.module('<%= scriptAppName %>')
.provider '<%= cameledName %>', [->

Expand Down
7 changes: 7 additions & 0 deletions templates/coffeescript/service/service.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict'

###*
* @ngdoc service
* @name <%= scriptAppName %>.<%= cameledName %>
* @description
* # <%= cameledName %>
* Service in the <%= scriptAppName %>.
###
angular.module('<%= scriptAppName %>')
.service '<%= classedName %>', ->
# AngularJS will instantiate a singleton by calling "new" on this function
7 changes: 7 additions & 0 deletions templates/coffeescript/service/value.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
'use strict'

###*
* @ngdoc service
* @name <%= scriptAppName %>.<%= cameledName %>
* @description
* # <%= cameledName %>
* Value in the <%= scriptAppName %>.
###
angular.module('<%= scriptAppName %>')
.value '<%= cameledName %>', 42
28 changes: 27 additions & 1 deletion templates/common/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ module.exports = function (grunt) {
coffeeTest: {
files: ['test/spec/{,*/}*.{coffee,litcoffee,coffee.md}'],
tasks: ['newer:coffee:test', 'karma']
},
js: {
files: ['.tmp/scripts/{,*/}*.js'],
tasks: ['ngdocs'],
options: {
livereload: true
}
},<% } else { %>
js: {
files: ['<%%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['newer:jshint:all'],
tasks: ['ngdocs', 'newer:jshint:all'],
options: {
livereload: true
}
Expand Down Expand Up @@ -352,6 +359,16 @@ module.exports = function (grunt) {
cwd: '<%%= yeoman.app %>/styles',
dest: '.tmp/styles/',
src: '{,*/}*.css'
},
ngdocs: {
expand: true,
cwd: '<%%= yeoman.app %>/docs',
dest: '.tmp/docs/',
src: [
'*.{ico,png,txt}',
'.htaccess',
'*.html',
]
}
},

Expand Down Expand Up @@ -408,6 +425,13 @@ module.exports = function (grunt) {
configFile: 'karma.conf.js',
singleRun: true
}
},
ngdocs: {
options: {
dest: '.tmp/docs',
html5Mode: false
},
api: ['<% if (coffee) { %>.tmp<% } else { %><%%= yeoman.app %><% } %>/scripts/{,*/}*.js'],
}
});

Expand All @@ -422,6 +446,7 @@ module.exports = function (grunt) {
'bower-install',
'concurrent:server',
'autoprefixer',
'ngdocs',
'connect:livereload',
'watch'
]);
Expand All @@ -448,6 +473,7 @@ module.exports = function (grunt) {
'autoprefixer',
'concat',
'ngmin',
'ngdocs',
'copy:dist',
'cdnify',
'cssmin',
Expand Down
3 changes: 2 additions & 1 deletion templates/common/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"grunt-usemin": "~2.0.0",
"jshint-stylish": "~0.1.3",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.2.1"
"time-grunt": "~0.2.1",
"grunt-ngdocs": "~0.1.7"
},
"engines": {
"node": ">=0.10.0"
Expand Down
8 changes: 8 additions & 0 deletions templates/javascript/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
'use strict';

/**
* @ngdoc overview
* @name <%= scriptAppName %>
* @description
* # <%= scriptAppName %>
*
* Main module of the application.
*/
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
.config(function ($routeProvider) {
$routeProvider
Expand Down
7 changes: 7 additions & 0 deletions templates/javascript/controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict';

/**
* @ngdoc function
* @name <%= scriptAppName %>.controller:<%= classedName %>Ctrl
* @description
* # <%= classedName %>Ctrl
* Controller of the <%= scriptAppName %>
*/
angular.module('<%= scriptAppName %>')
.controller('<%= classedName %>Ctrl', function ($scope) {
$scope.awesomeThings = [
Expand Down
7 changes: 7 additions & 0 deletions templates/javascript/decorator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict';

/**
* @ngdoc function
* @name <%= scriptAppName %>.decorator:<%= classedName %>
* @description
* # <%= classedName %>Ctrl
* Decorator of the <%= scriptAppName %>
*/
angular.module('<%= scriptAppName %>')
.config(function ($provide) {
$provide.decorator('<%= cameledName %>', function ($delegate) {
Expand Down
7 changes: 7 additions & 0 deletions templates/javascript/directive.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict';

/**
* @ngdoc directive
* @name <%= scriptAppName %>.directive:<%= cameledName %>
* @description
* # <%= cameledName %>
* Directive to replace content with custom text.
*/
angular.module('<%= scriptAppName %>')
.directive('<%= cameledName %>', function () {
return {
Expand Down
8 changes: 8 additions & 0 deletions templates/javascript/filter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
'use strict';

/**
* @ngdoc filter
* @name <%= scriptAppName %>.filter:<%= cameledName %>
* @function
* @description
* # <%= cameledName %>
* Filter to change your value.
*/
angular.module('<%= scriptAppName %>')
.filter('<%= cameledName %>', function () {
return function (input) {
Expand Down
7 changes: 7 additions & 0 deletions templates/javascript/service/constant.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
'use strict';

/**
* @ngdoc service
* @name <%= scriptAppName %>.<%= cameledName %>
* @description
* # <%= cameledName %>
* Constat in the <%= scriptAppName %>.
*/
angular.module('<%= scriptAppName %>')
.constant('<%= cameledName %>', 42);
7 changes: 7 additions & 0 deletions templates/javascript/service/factory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict';

/**
* @ngdoc service
* @name <%= scriptAppName %>.<%= cameledName %>
* @description
* # <%= cameledName %>
* Factory in the <%= scriptAppName %>.
*/
angular.module('<%= scriptAppName %>')
.factory('<%= cameledName %>', function () {
// Service logic
Expand Down
7 changes: 7 additions & 0 deletions templates/javascript/service/provider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict';

/**
* @ngdoc service
* @name <%= scriptAppName %>.<%= cameledName %>
* @description
* # <%= cameledName %>
* Provider in the <%= scriptAppName %>.
*/
angular.module('<%= scriptAppName %>')
.provider('<%= cameledName %>', function () {

Expand Down
7 changes: 7 additions & 0 deletions templates/javascript/service/service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict';

/**
* @ngdoc service
* @name <%= scriptAppName %>.<%= cameledName %>
* @description
* # <%= cameledName %>
* Service in the <%= scriptAppName %>.
*/
angular.module('<%= scriptAppName %>')
.service('<%= classedName %>', function <%= classedName %>() {
// AngularJS will instantiate a singleton by calling "new" on this function
Expand Down
7 changes: 7 additions & 0 deletions templates/javascript/service/value.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
'use strict';

/**
* @ngdoc service
* @name <%= scriptAppName %>.<%= cameledName %>
* @description
* # <%= cameledName %>
* Value in the <%= scriptAppName %>.
*/
angular.module('<%= scriptAppName %>')
.value('<%= cameledName %>', 42);

0 comments on commit ef01195

Please sign in to comment.