make @returns type non-optional

This commit is contained in:
Igor Minar 2010-11-17 12:13:04 -08:00
parent ff7c738c21
commit 4c69d694d7
4 changed files with 13 additions and 23 deletions

View file

@ -208,12 +208,12 @@ function propertyTag(doc, name, value) {
}
function returnsTag(doc, name, value) {
var match = value.match(/^({(\S+)}\s*)?(.*)?/);
var match = value.match(/^{(\S+)}\s+(.*)?/);
if (match) {
var tag = {
type: match[2],
description: match[3] || false
type: match[1],
description: match[2] || false
};
} else {
throw "[" + doc.raw.file + ":" + doc.raw.line +

View file

@ -161,24 +161,14 @@ describe('collect', function(){
});
describe('@returns', function() {
it('should parse @returns', function() {
expect(function() {TAG.returns(doc, 'returns', '');})
.not.toThrow();
});
it('should parse @returns with type', function() {
TAG.returns(doc, 'returns', '{string}');
expect(doc.returns.type).toEqual('string');
});
it('should parse @returns with description', function() {
TAG.returns(doc, 'returns', 'descrip tion');
expect(doc.returns.description).toEqual('descrip tion');
it('should not parse @returns without type', function() {
expect(function() {TAG.returns(doc, 'returns', 'lala');})
.toThrow();
});
it('should parse @returns with type and description', function() {
TAG.returns(doc, 'returns', '{string} description');
expect(doc.returns).toEqual({type: 'string', description: 'description'});
TAG.returns(doc, 'returns', '{string} descrip tion');
expect(doc.returns).toEqual({type: 'string', description: 'descrip tion'});
});
});

View file

@ -38,7 +38,7 @@ angularFormatter.json = formatter(toJson, fromJson);
* @description
* Use boolean formatter if you wish to store the data as boolean.
*
* @returns Convert to `true` unless user enters (blank), `f`, `false`, `0`, `no`, `[]`.
* @returns {boolean} Converts to `true` unless user enters (blank), `f`, `false`, `0`, `no`, `[]`.
*
* @example
* Enter truthy text:
@ -62,7 +62,7 @@ angularFormatter['boolean'] = formatter(toString, toBoolean);
* @description
* Use number formatter if you wish to convert the user entered string to a number.
*
* @returns parse string to number.
* @returns {number} Number from the parsed string.
*
* @example
* Enter valid number:
@ -89,9 +89,9 @@ angularFormatter.number = formatter(toString, function(obj){
* @name angular.formatter.list
*
* @description
* Use number formatter if you wish to convert the user entered string to a number.
* Use list formatter if you wish to convert the user entered string to an array.
*
* @returns parse string to number.
* @returns {Array} Array parsed from the entered string.
*
* @example
* Enter a list of items:

View file

@ -994,7 +994,7 @@ angularServiceInject('$cookieStore', function($store) {
* Returns the value of given cookie key
*
* @param {string} key
* @returns Cookie value
* @returns {Object} Deserialized cookie value
*/
get: function(/**string*/key) {
return fromJson($store[key]);