Socket
Socket
Sign inDemoInstall

dgeni-packages

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dgeni-packages - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

52

jsdoc/processors/doctrine-tag-parser.js
var _ = require('lodash');
var doctrine = require('doctrine');
var log = require('winston');
// A simple container of parsed tags with helpers
var Tags = function(content) {
var parsed = doctrine.parse(content);
this.tags = parsed.tags;
var Tags = function(content, tags) {
// Sloppy implies support for jsdoc3 and closure compiler style types
// Recoverable allows us to collect up information about the bad tags
var parsed = doctrine.parse(content, { sloppy: true, recoverable: true, tags: tags });
// Filter out the bad tags into a separate collection
var badTags = this.badTags = [];
this.tags = _.filter(parsed.tags, function(tag) {
if ( tag.errors ) {
badTags.push(tag);
}
return !tag.errors;
});
// Extract the description if necessary

@@ -35,2 +48,3 @@ if ( parsed.description ) {

getType: function(tag) {
try {
var isOptional = tag.type.type === 'OptionalType';

@@ -54,6 +68,29 @@ var mainType = isOptional ? tag.type.expression : tag.type;

};
} catch(e) {
console.log(e);
console.log(tag);
throw e;
}
}
};
function formatBadTagErrorMessage(doc) {
var message = 'Bad tags found in doc "' + doc.id + '" from file "' + doc.file + '" line ' + doc.startingLine + '\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>');
message += ' - Bad tag: "' + title + '" - "' + description + '"\n';
_.forEach(badTag.errors, function(error) {
message += ' * ' + error + '\n';
});
});
return message + '\n';
}
var tags;
var plugin = module.exports = {

@@ -64,7 +101,14 @@ name: 'doctrine-tag-parser',

runBefore: ['tags-parsed'],
init: function(config) {
tags = _.pluck(config.get('processing.tagDefinitions'), 'name');
log.debug('Tags to parse:', tags);
},
process: function parseDocsWithDoctrine(docs) {
_.forEach(docs, function(doc) {
doc.tags = new Tags(doc.content);
doc.tags = new Tags(doc.content, tags);
if ( doc.tags.badTags.length > 0 ) {
log.warn(formatBadTagErrorMessage(doc));
}
});
}
};

4

package.json
{
"name": "dgeni-packages",
"version": "0.2.2",
"version": "0.2.3",
"description": "A collection of dgeni packages for generating documentation from source code",

@@ -36,3 +36,3 @@ "scripts": {

"winston": "~0.7.2",
"doctrine": "~0.2.0",
"doctrine": "~0.3.0",
"graceful-fs": "~2.0.1",

@@ -39,0 +39,0 @@ "q": "~1.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc