dgeni-packages
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -0,1 +1,6 @@ | ||
## 0.3.1 03/02/2014 | ||
* fix(tagParser): don't break on bad-tags 560eff7b | ||
## 0.3.0 02/28/2014 | ||
@@ -2,0 +7,0 @@ |
@@ -36,2 +36,10 @@ var _ = require('lodash'); | ||
var storeTag = function(tag) { | ||
_.forEach(tagProcessors, function(tagProcessor) { | ||
tagProcessor(tag); | ||
}); | ||
tags.addTag(tag); | ||
}; | ||
// Extract the description block | ||
@@ -73,3 +81,3 @@ do { | ||
if ( !inCode && match && tagDefMap[match[1]] ) { | ||
tags.addTag(current); | ||
storeTag(current); | ||
current = new Tag(tagDefMap[match[1]], match[1], match[2], startingLine + lineNumber); | ||
@@ -83,11 +91,7 @@ } else { | ||
if ( current ) { | ||
tags.addTag(current); | ||
storeTag(current); | ||
} | ||
_.forEach(tagProcessors, function(tagProcessor) { | ||
tagProcessor(tags); | ||
}); | ||
return tags; | ||
}; | ||
}; |
@@ -37,8 +37,11 @@ var _ = require('lodash'); | ||
*/ | ||
module.exports = function(tags) { | ||
_.forEach(tags.tags, function(tag) { | ||
if ( tag.tagDef.canHaveName ) { | ||
module.exports = function(tag) { | ||
if ( tag.tagDef.canHaveName ) { | ||
try { | ||
extractName(tag); | ||
} catch(e) { | ||
tag.errors = tag.errors || []; | ||
tag.errors.push(e); | ||
} | ||
}); | ||
} | ||
}; |
@@ -7,6 +7,4 @@ var _ = require('lodash'); | ||
*/ | ||
module.exports = function(tags) { | ||
_.forEach(tags.tags, function(tag) { | ||
tag.description = tag.description.trim(); | ||
}); | ||
module.exports = function(tag) { | ||
tag.description = tag.description.trim(); | ||
}; |
@@ -1,7 +0,25 @@ | ||
var _ = require('lodash'); | ||
var log = require('winston'); | ||
// Much of this code was inspired by or simply copied from the JSDOC project. | ||
// See https://github.com/jsdoc3/jsdoc/blob/c9b0237c12144cfa48abe5fccd73ba2a1d46553a/lib/jsdoc/tag/type.js | ||
var catharsis = require('catharsis'); | ||
var TYPE_EXPRESSION_START = /\{[^@]/; | ||
/** | ||
* Process the type information in the tags | ||
* @param {TagCollection} tags The collection of tags to process | ||
*/ | ||
module.exports = function(tag) { | ||
try { | ||
if ( tag.tagDef.canHaveType ) { | ||
extractTypeExpression(tag); | ||
} | ||
} catch(e) { | ||
tag.errors = tag.errors || []; | ||
tag.errors.push(e); | ||
} | ||
}; | ||
/** | ||
* Extract a type expression from the tag text. | ||
@@ -56,21 +74,2 @@ * | ||
/** | ||
* Process the type information in the tags | ||
* @param {TagCollection} tags The collection of tags to process | ||
*/ | ||
module.exports = function(tags) { | ||
_.forEach(tags.tags, function(tag) { | ||
try { | ||
if ( tag.tagDef.canHaveType ) { | ||
extractTypeExpression(tag); | ||
} | ||
} catch(e) { | ||
log.error('Error processing tag type expression in "' + tag.tagName + '", at line ' + tag.startingLine); | ||
throw e; | ||
} | ||
}); | ||
}; | ||
/** @private */ | ||
@@ -77,0 +76,0 @@ function getTypeStrings(parsedType) { |
@@ -7,11 +7,17 @@ var _ = require('lodash'); | ||
function formatBadTagErrorMessage(doc) { | ||
var message = 'Bad tags found in doc "' + doc.id + '" from file "' + doc.file + '" line ' + doc.startingLine + '\n'; | ||
var id = (doc.id || doc.name); | ||
id = id ? '"' + id + '" ' : ''; | ||
var message = 'Invalid tags found in doc, starting at line ' + doc.startingLine + ', from file "' + doc.file + '"\n'; | ||
_.forEach(doc.tags.badTags, function(badTag) { | ||
var title = badTag.title || '<missing>'; | ||
var description = | ||
badTag.name || | ||
(_.isString(badTag.description) ? (badTag.description.substr(0, 20) + '...') : '<missing>'); | ||
//console.log(badTag); | ||
var description = (_.isString(badTag.description) && (badTag.description.substr(0, 20) + '...')); | ||
if ( badTag.name ) { | ||
description = badTag.name + ' ' + description; | ||
} | ||
if ( badTag.typeExpression ) { | ||
description = '{' + badTag.typeExpression + '} ' + description; | ||
} | ||
message += ' - Bad tag: "' + title + '" - "' + description + '"\n'; | ||
message += 'Line: ' + badTag.startingLine + ': @' + badTag.tagName + ' ' + description + '\n'; | ||
_.forEach(badTag.errors, function(error) { | ||
@@ -18,0 +24,0 @@ message += ' * ' + error + '\n'; |
var Tag = require('../../../lib/Tag'); | ||
var TagCollection = require('../../../lib/TagCollection'); | ||
var nameProcessor = require('../../../lib/tagProcessors/nameProcessor'); | ||
@@ -7,3 +6,3 @@ | ||
var tagDef, tags; | ||
var tagDef; | ||
@@ -15,4 +14,2 @@ beforeEach(function() { | ||
}; | ||
tags = new TagCollection(); | ||
}); | ||
@@ -23,4 +20,3 @@ | ||
var tag = new Tag(tagDef, 'someTag', ' paramName - Some description \n Some more description', 0); | ||
tags.addTag(tag); | ||
nameProcessor(tags); | ||
nameProcessor(tag); | ||
expect(tag.name).toEqual('paramName'); | ||
@@ -32,4 +28,3 @@ expect(tag.description).toEqual('Some description \n Some more description'); | ||
var tag = new Tag(tagDef, 'someTag', '[someName]', 0); | ||
tags.addTag(tag); | ||
nameProcessor(tags); | ||
nameProcessor(tag); | ||
expect(tag.name).toEqual('someName'); | ||
@@ -41,4 +36,3 @@ expect(tag.optional).toEqual(true); | ||
var tag = new Tag(tagDef, 'someTag', '[someName=someDefault]', 0); | ||
tags.addTag(tag); | ||
nameProcessor(tags); | ||
nameProcessor(tag); | ||
expect(tag.name).toEqual('someName'); | ||
@@ -52,4 +46,3 @@ expect(tag.optional).toEqual(true); | ||
var tag = new Tag(tagDef, 'someTag', 'paramName|aliasName some description', 0); | ||
tags.addTag(tag); | ||
nameProcessor(tags); | ||
nameProcessor(tag); | ||
expect(tag.name).toEqual('paramName'); | ||
@@ -56,0 +49,0 @@ expect(tag.alias).toEqual('aliasName'); |
@@ -6,5 +6,5 @@ var trimProcessor = require('../../../lib/tagProcessors/trimProcessor'); | ||
it("should trim newlines from the end of the description", function() { | ||
var tags = [{ name: 'info', description: 'myId\n\nsome other text \n \n'}]; | ||
trimProcessor({tags: tags}); | ||
expect(tags[0].description).toEqual('myId\n\nsome other text'); | ||
var tag = { name: 'info', description: 'myId\n\nsome other text \n \n'}; | ||
trimProcessor(tag); | ||
expect(tag.description).toEqual('myId\n\nsome other text'); | ||
}); | ||
@@ -11,0 +11,0 @@ |
var Tag = require('../../../lib/Tag'); | ||
var TagCollection = require('../../../lib/TagCollection'); | ||
var typeProcessor = require('../../../lib/tagProcessors/typeProcessor'); | ||
@@ -7,3 +6,3 @@ | ||
var tagDef, tags; | ||
var tagDef; | ||
@@ -15,4 +14,2 @@ beforeEach(function() { | ||
}; | ||
tags = new TagCollection(); | ||
}); | ||
@@ -22,4 +19,3 @@ | ||
var tag = new Tag(tagDef, 'someTag', ' {{a: number, b: string, c}} \n paramName - Some description', 0); | ||
tags.addTag(tag); | ||
typeProcessor(tags); | ||
typeProcessor(tag); | ||
expect(tag.typeExpression).toEqual('{a: number, b: string, c}'); | ||
@@ -30,4 +26,3 @@ }); | ||
var tag = new Tag(tagDef, 'someTag', ' {weirdObject."with\\}AnnoyingProperty"} \n paramName - Some description', 0); | ||
tags.addTag(tag); | ||
typeProcessor(tags); | ||
typeProcessor(tag); | ||
expect(tag.typeExpression).toEqual('weirdObject."with}AnnoyingProperty"'); | ||
@@ -38,4 +33,3 @@ }); | ||
var tag = new Tag(tagDef, 'someTag', ' { Function|Array<String>= } \n paramName - Some description', 0); | ||
tags.addTag(tag); | ||
typeProcessor(tags); | ||
typeProcessor(tag); | ||
expect(tag.typeExpression).toEqual('Function|Array<String>='); | ||
@@ -46,4 +40,3 @@ }); | ||
var tag = new Tag(tagDef, 'someTag', ' { Function|Array<String>= } \n paramName - Some description', 0); | ||
tags.addTag(tag); | ||
typeProcessor(tags); | ||
typeProcessor(tag); | ||
expect(tag.description).toEqual('paramName - Some description'); | ||
@@ -54,4 +47,3 @@ }); | ||
var tag = new Tag(tagDef, 'someTag', '{string=} paramName - some description', 0); | ||
tags.addTag(tag); | ||
typeProcessor(tags); | ||
typeProcessor(tag); | ||
expect(tag.optional).toEqual(true); | ||
@@ -58,0 +50,0 @@ }); |
{ | ||
"name": "dgeni-packages", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "A collection of dgeni packages for generating documentation from source code", | ||
@@ -33,2 +33,3 @@ "scripts": { | ||
"dependencies": { | ||
"dgeni": "~0.2.0", | ||
"canonical-path": "0.0.2", | ||
@@ -35,0 +36,0 @@ "lodash": "~2.4.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133736
11
105
2970
+ Addeddgeni@~0.2.0