diff --git a/README.md b/README.md
index 6bfae56..dfcd55a 100644
--- a/README.md
+++ b/README.md
@@ -111,6 +111,14 @@ Produces `src/module/the-hero-constant.js`:
```javascript
'use strict';
+/**
+ * @ngdoc service
+ * @name module.constant:TheHero
+ *
+ * @description
+ *
+ *
+ */
angular
.module('module')
.constant('TheHero', 0);
@@ -149,6 +157,15 @@ Produces `src/module/micro-controller.js`:
```javascript
'use strict';
+/**
+ * @ngdoc object
+ * @name module.controller:MicroCtrl
+ * @requires $scope
+ *
+ * @description
+ *
+ *
+ */
angular
.module('module')
.controller('MicroCtrl', function ($scope) {
@@ -190,6 +207,23 @@ Produces `src/module/fancy-button-directive.js`:
```javascript
'use strict';
+/**
+ * @ngdoc directive
+ * @name module.directive:fancyButton
+ * @restrict EA
+ * @element
+ *
+ * @description
+ * Change the element's text to fancyButton\nscope\nattrs
+ *
+ * @example
+
+
+
+
+
+ *
+ */
angular
.module('module')
.directive('fancyButton', function () {
@@ -248,9 +282,17 @@ Produces `src/module/cake-factory.js`:
```javascript
'use strict';
+/**
+ * @ngdoc service
+ * @name module.factory:Cake
+ *
+ * @description
+ *
+ *
+ */
angular
.module('module')
- .factory('Cake', function() {
+ .factory('Cake', function () {
var CakeBase = {};
CakeBase.someValue = 'Cake';
CakeBase.someMethod = function () {
@@ -297,6 +339,17 @@ Produces `src/module/coffee-filter.js`:
```javascript
'use strict';
+/**
+ * @ngdoc filter
+ * @name module.filter:coffee
+ *
+ * @description
+ *
+ *
+ * @param {Array} input The array of numbers to filter
+ * @returns {Array} The filtered array
+ *
+ */
angular
.module('module')
.filter('coffee', function () {
@@ -339,6 +392,14 @@ Produces `src/top/top.js`:
```javascript
'use strict';
+/* @ngdoc object
+ * @name top
+ * @requires $stateProvider
+ *
+ * @description
+ *
+ *
+ */
angular
.module('top', [
'ui.router'
@@ -362,15 +423,23 @@ Updates `src/app.js`:
```javascript
'use strict';
+/* @ngdoc object
+ * @name track
+ * @requires $urlRouterProvider
+ *
+ * @description
+ *
+ *
+ */
angular
- .module('module', [
+ .module('track', [
'ui.router',
'home',
'top'
]);
angular
- .module('module')
+ .module('track')
.config(function ($urlRouterProvider) {
$urlRouterProvider.otherwise('/home');
});
@@ -389,6 +458,14 @@ Updates `src/top/top.js`:
```javascript
'use strict';
+/* @ngdoc object
+ * @name top
+ * @requires $stateProvider
+ *
+ * @description
+ *
+ *
+ */
angular
.module('top', [
'ui.router',
@@ -436,6 +513,15 @@ Produces `src/module/bacon-provider.js`:
```javascript
'use strict';
+/**
+ * @ngdoc service
+ * @name module.provider:Bacon
+ * @function
+ *
+ * @description
+ *
+ *
+ */
angular
.module('module')
.provider('Bacon', function () {
@@ -480,6 +566,16 @@ Updates `src/module/module.js`:
```javascript
'use strict';
+/* @ngdoc object
+ * @name module
+ * @requires $stateProvider
+ *
+ * @description
+ *
+ *
+ * @ngInject
+ *
+ */
angular
.module('module', [
'ui.router'
@@ -493,11 +589,11 @@ angular
url: '/module',
templateUrl: 'module/module.tpl.html',
controller: 'ModuleCtrl'
- })
- .state('yourPlace', {
- url: '/yourPlace',
- templateUrl: 'module/your-place.tpl.html',
- controller: 'YourPlaceCtrl'
+ })
+ .state('yourPlace', {
+ url: '/yourPlace',
+ templateUrl: 'module/your-place.tpl.html',
+ controller: 'YourPlaceCtrl'
});
});
```
@@ -525,6 +621,15 @@ Produces `src/module/cheap-or-good-service.js`:
```javascript
'use strict';
+/**
+ * @ngdoc service
+ * @name module.service:CheapOrGood
+ * @function
+ *
+ * @description
+ *
+ *
+ */
angular
.module('module')
.service('CheapOrGood', function () {
@@ -570,6 +675,14 @@ Produces `src/module/morals-value.js`:
```javascript
'use strict';
+/**
+ * @ngdoc service
+ * @name module.constant:Morals
+ *
+ * @description
+ *
+ *
+ */
angular
.module('module')
.value('Morals', 0);
@@ -678,6 +791,14 @@ This will generate controllers like:
```javascript
'use strict';
+/**
+ * @ngdoc object
+ * @name home.controller:HomeCtrl
+ *
+ * @description
+ *
+ *
+ */
angular
.module('home')
.controller('HomeCtrl', function () {
@@ -712,6 +833,16 @@ It'll also modify the state's controller like:
```javascript
'use strict';
+/* @ngdoc object
+ * @name home
+ * @requires $stateProvider
+ *
+ * @description
+ *
+ *
+ * @ngInject
+ *
+ */
angular
.module('home', [
'ui.router'
@@ -745,7 +876,17 @@ If enabled, the app source code will pass functions, such as:
```javascript
'use strict';
-/* @ngInject */
+/**
+ * @ngdoc object
+ * @name home.controller:HomeCtrl
+ * @function
+ *
+ * @description
+ *
+ *
+ * @ngInject
+ *
+ */
function HomeCtrl() {
this.ctrlName = 'HomeCtrl';
}
@@ -766,16 +907,29 @@ If enabled, the app source code will have named functions, such as:
```javascript
'use strict';
+/**
+ * @ngdoc service
+ * @name module.factory:Cake
+ * @function
+ *
+ * @description
+ *
+ *
+ * @ngInject
+ *
+ */
+function Cake() {
+ var CakeBase = {};
+ CakeBase.someValue = 'Cake';
+ CakeBase.someMethod = function someMethod() {
+ return 'Cake';
+ };
+ return CakeBase;
+}
+
angular
.module('module')
- .factory('Cake', function Cake() {
- var CakeBase = {};
- CakeBase.someValue = 'Cake';
- CakeBase.someMethod = function someMethod() {
- return 'Cake';
- };
- return CakeBase;
- });
+ .factory('Cake', Cake);
```
### License
diff --git a/app/templates/_app.js b/app/templates/_app.js
index 60a6837..d5fb32e 100644
--- a/app/templates/_app.js
+++ b/app/templates/_app.js
@@ -1,11 +1,30 @@
'use strict';<% if (passFunc) { %>
-/* @ngInject */
+/* @ngdoc object
+ * @name <%= moduleName %>
+ * @requires $urlRouterProvider
+ *
+ * @description
+ *
+ *
+ * @ngInject
+ *
+ */
function config($urlRouterProvider) {
$urlRouterProvider.otherwise('/home');
}<% } %>
-angular
+<% if (!passFunc) { %>/* @ngdoc object
+ * @name <%= moduleName %>
+ * @requires $urlRouterProvider
+ *
+ * @description
+ *
+ *
+ * @ngInject
+ *
+ */
+<% } %>angular
.module('<%= moduleName %>', [
'ui.router'
]);
diff --git a/constant/templates/_constant.js b/constant/templates/_constant.js
index 8fe9b19..d44a442 100644
--- a/constant/templates/_constant.js
+++ b/constant/templates/_constant.js
@@ -1,5 +1,13 @@
'use strict';
+/**
+ * @ngdoc service
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.constant:<%= upperCamel %>
+ *
+ * @description
+ *
+ *
+ */
angular
.module('<% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>')
.constant('<%= upperCamel %>', 0);
\ No newline at end of file
diff --git a/controller/templates/_controller.js b/controller/templates/_controller.js
index 35ab73b..f1b1c93 100644
--- a/controller/templates/_controller.js
+++ b/controller/templates/_controller.js
@@ -1,11 +1,31 @@
'use strict';<% if (passFunc) { %>
-/* @ngInject */
+/**
+ * @ngdoc object
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.controller:<%= ctrlName %><% if(!controllerAs) { %>
+ * @requires $scope <% } %>
+ * @function
+ *
+ * @description
+ *
+ *
+ * @ngInject
+ *
+ */
function <%= ctrlName %>(<% if (!controllerAs) { %>$scope<% } %>) {
<% if (controllerAs) { %>this.ctrlName = '<%= ctrlName %>';<% } else { %>$scope.ctrlName = '<%= ctrlName %>';<% } %>
}<% } %>
-angular
+<% if (!passFunc) { %>/**
+ * @ngdoc object
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.controller:<%= ctrlName %><% if(!controllerAs) { %>
+ * @requires $scope <% } %>
+ *
+ * @description
+ *
+ *
+ */
+<% } %>angular
.module('<% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>')<% if (passFunc) { %>
.controller('<%= ctrlName %>', <%= ctrlName %>);<% } else { %>
.controller('<%= ctrlName %>', function <% if (namedFunc) { %><%= ctrlName %><% } %>(<% if (!controllerAs) { %>$scope<% } %>) {
diff --git a/directive/templates/_directive.js b/directive/templates/_directive.js
index 0a22032..418aa8c 100644
--- a/directive/templates/_directive.js
+++ b/directive/templates/_directive.js
@@ -1,6 +1,25 @@
'use strict';<% if (passFunc) { %>
-/* @ngInject */
+/**
+ * @ngdoc directive
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.directive:<%= lowerCamel %>
+ * @restrict EA
+ * @element
+ * @function
+ *
+ * @description
+ * Change the element's text to <%= lowerCamel %>\nscope\nattrs
+ *
+ * @example
+
+
+ <<%= hyphenName %>><%= hyphenName %>>
+
+
+ *
+ * @ngInject
+ *
+ */
function <%= lowerCamel %>() {
return {
restrict: 'EA',
@@ -13,7 +32,24 @@ function <%= lowerCamel %>() {
};
}<% } %>
-angular
+<% if (!passFunc) { %>/**
+ * @ngdoc directive
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.directive:<%= lowerCamel %>
+ * @restrict EA
+ * @element
+ *
+ * @description
+ * Change the element's text to <%= lowerCamel %>\nscope\nattrs
+ *
+ * @example
+
+
+ <<%= hyphenName %>><%= hyphenName %>>
+
+
+ *
+ */
+<% } %>angular
.module('<% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>')<% if (passFunc) { %>
.directive('<%= lowerCamel %>', <%= lowerCamel %>);<% } else { %>
.directive('<%= lowerCamel %>', function <% if (namedFunc) { %><%= lowerCamel %><% } %>() {
diff --git a/factory/templates/_factory.js b/factory/templates/_factory.js
index 36af8ab..49d6773 100644
--- a/factory/templates/_factory.js
+++ b/factory/templates/_factory.js
@@ -1,6 +1,16 @@
'use strict';<% if (passFunc) { %>
-/* @ngInject */
+/**
+ * @ngdoc service
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.factory:<%= upperCamel %>
+ * @function
+ *
+ * @description
+ *
+ *
+ * @ngInject
+ *
+ */
function <%= upperCamel %>() {
var <%= upperCamel %>Base = {};
<%= upperCamel %>Base.someValue = '<%= upperCamel %>';
@@ -10,7 +20,15 @@ function <%= upperCamel %>() {
return <%= upperCamel %>Base;
}<% } %>
-angular
+<% if (!passFunc) { %>/**
+ * @ngdoc service
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.factory:<%= upperCamel %>
+ *
+ * @description
+ *
+ *
+ */
+<% } %>angular
.module('<% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>')<% if (passFunc) { %>
.factory('<%= upperCamel %>', <%= upperCamel %>);<% } else { %>
.factory('<%= upperCamel %>', function <% if (namedFunc) { %><%= upperCamel %><% } %>() {
diff --git a/filter/templates/_filter.js b/filter/templates/_filter.js
index 66d77b0..3e73b78 100644
--- a/filter/templates/_filter.js
+++ b/filter/templates/_filter.js
@@ -1,6 +1,18 @@
'use strict';<% if (passFunc) { %>
-/* @ngInject */
+/**
+ * @ngdoc filter
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.filter:<%= lowerCamel %>
+ *
+ * @description
+ *
+ *
+ * @param {Array} input The array of numbers to filter
+ * @returns {Array} The filtered array
+ *
+ * @ngInject
+ *
+ */
function <%= lowerCamel %>() {
return function (input) {
var temp = [];
@@ -13,7 +25,18 @@ function <%= lowerCamel %>() {
};
}<% } %>
-angular
+<% if (!passFunc) { %>/**
+ * @ngdoc filter
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.filter:<%= lowerCamel %>
+ *
+ * @description
+ *
+ *
+ * @param {Array} input The array of numbers to filter
+ * @returns {Array} The filtered array
+ *
+ */
+<% } %>angular
.module('<% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>')<% if (passFunc) { %>
.filter('<%= lowerCamel %>', <%= lowerCamel %>);<% } else { %>
.filter('<%= lowerCamel %>', function <% if (namedFunc) { %><%= lowerCamel %><% } %>() {
diff --git a/genBase/index.js b/genBase/index.js
index 4ae90af..3e91ff8 100644
--- a/genBase/index.js
+++ b/genBase/index.js
@@ -37,6 +37,7 @@ Generator.prototype.getConfig = function getConfig() {
var config = {
appName: utils.getAppName(this.config.path),
ctrlName: utils.ctrlName(this.name),
+ humanName: utils.humanName(this.name),
hyphenName: utils.hyphenName(this.name),
lowerCamel: utils.lowerCamel(this.name),
upperCamel: utils.upperCamel(this.name),
diff --git a/module/templates/_app.js b/module/templates/_app.js
index 4453aa6..a059514 100644
--- a/module/templates/_app.js
+++ b/module/templates/_app.js
@@ -1,6 +1,15 @@
'use strict';<% if (passFunc) { %>
-/* @ngInject */
+/* @ngdoc object
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>
+ * @requires $stateProvider
+ *
+ * @description
+ *
+ *
+ * @ngInject
+ *
+ */
function config($stateProvider) {
$stateProvider
.state('<%= moduleName %>', {
@@ -10,7 +19,15 @@ function config($stateProvider) {
});
}<% } %>
-angular
+<% if (!passFunc) { %>/* @ngdoc object
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>
+ * @requires $stateProvider
+ *
+ * @description
+ *
+ *
+ */
+<% } %>angular
.module('<% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>', [
'ui.router'
]);
diff --git a/package.json b/package.json
index 50ef05b..fc00332 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "generator-ng-poly",
- "version": "0.0.14",
+ "version": "0.0.15",
"description": "Yeoman generator for AngularJS and Polymer apps. A work in progress.",
"license": "MIT",
"main": "app/index.js",
diff --git a/provider/templates/_provider.js b/provider/templates/_provider.js
index d8a9958..21d4886 100644
--- a/provider/templates/_provider.js
+++ b/provider/templates/_provider.js
@@ -1,6 +1,15 @@
'use strict';<% if (passFunc) { %>
-/* @ngInject */
+/**
+ * @ngdoc service
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.provider:<%= upperCamel %>
+ * @function
+ *
+ * @description
+ *
+ * @ngInject
+ *
+ */
function <%= upperCamel %>() {
return {
$get: function () {
@@ -9,7 +18,16 @@ function <%= upperCamel %>() {
};
}<% } %>
-angular
+<% if (!passFunc) { %>/**
+ * @ngdoc service
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.provider:<%= upperCamel %>
+ * @function
+ *
+ * @description
+ *
+ *
+ */
+<% } %>angular
.module('<% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>')<% if (passFunc) { %>
.provider('<%= upperCamel %>', <%= upperCamel %>);<% } else { %>
.provider('<%= upperCamel %>', function <% if (namedFunc) { %><%= upperCamel %><% } %>() {
diff --git a/service/templates/_service.js b/service/templates/_service.js
index 003fb3d..5cf0399 100644
--- a/service/templates/_service.js
+++ b/service/templates/_service.js
@@ -1,6 +1,15 @@
'use strict';<% if (passFunc) { %>
-/* @ngInject */
+/**
+ * @ngdoc service
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.service:<%= upperCamel %>
+ * @function
+ *
+ * @description
+ *
+ * @ngInject
+ *
+ */
function <%= upperCamel %>() {
function <%= upperCamel %>Base() {}
<%= upperCamel %>Base.prototype.get = function <% if (namedFunc) { %>get<% } %>() {
@@ -10,7 +19,16 @@ function <%= upperCamel %>() {
return new <%= upperCamel %>Base();
}<% } %>
-angular
+<% if (!passFunc) { %>/**
+ * @ngdoc service
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.service:<%= upperCamel %>
+ * @function
+ *
+ * @description
+ *
+ *
+ */
+<% } %>angular
.module('<% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>')<% if (passFunc) { %>
.service('<%= upperCamel %>', <%= upperCamel %>);<% } else { %>
.service('<%= upperCamel %>', function <% if (namedFunc) { %><%= upperCamel %><% } %>() {
diff --git a/test/test-route-addition.js b/test/test-route-addition.js
index d9557c4..4a213bf 100644
--- a/test/test-route-addition.js
+++ b/test/test-route-addition.js
@@ -80,7 +80,7 @@ describe('route generator', function () {
'markup': 'html',
'appScript': 'js',
'controllerAs': true,
- 'passFunc': true,
+ 'passFunc': false,
'namedFunc': true,
'testScript': 'js',
'testDir': 'src',
diff --git a/test/test-utils.js b/test/test-utils.js
index e99e916..4b7849d 100644
--- a/test/test-utils.js
+++ b/test/test-utils.js
@@ -41,6 +41,24 @@ describe('ng-poly generator', function () {
});
});
+ describe('humanize name', function () {
+ it('should transform name with hyphens', function () {
+ assert(utils.humanName('test-name') === 'Test name');
+ });
+
+ it('should transform upper camel name', function () {
+ assert(utils.humanName('TestName') === 'Test name');
+ });
+
+ it('should transform underscore', function () {
+ assert(utils.humanName('test_name') === 'Test name');
+ });
+
+ it('should transform mixed', function () {
+ assert(utils.humanName('Test_name-fancy') === 'Test name fancy');
+ });
+ });
+
describe('hyphen name', function () {
it('should transform name with hyphens', function () {
assert(utils.hyphenName('test-name') === 'test-name');
diff --git a/utils/index.js b/utils/index.js
index dbc09a0..bd46964 100644
--- a/utils/index.js
+++ b/utils/index.js
@@ -13,6 +13,10 @@ function upperCamel(name) {
return _.classify(_.slugify(_.humanize(name)));
}
+function humanName(name) {
+ return _.humanize(name);
+}
+
function hyphenName(name) {
return _.slugify(_.humanize(name));
}
@@ -70,6 +74,7 @@ function moduleExists(yoRcAbsolutePath, modulePath) {
module.exports = {
lowerCamel: lowerCamel,
upperCamel: upperCamel,
+ humanName: humanName,
hyphenName: hyphenName,
ctrlName: ctrlName,
getAppName: getAppName,
diff --git a/value/templates/_value.js b/value/templates/_value.js
index 373f9e7..70e5b6e 100644
--- a/value/templates/_value.js
+++ b/value/templates/_value.js
@@ -1,5 +1,13 @@
'use strict';
+/**
+ * @ngdoc service
+ * @name <% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>.constant:<%= upperCamel %>
+ *
+ * @description
+ *
+ *
+ */
angular
.module('<% if (parentModuleName) { %><%= parentModuleName %>.<% } %><%= moduleName %>')
.value('<%= upperCamel %>', 0);
\ No newline at end of file