Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-docgen-api

Package Overview
Dependencies
Maintainers
1
Versions
271
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-docgen-api - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

17

dist/parse.js

@@ -21,12 +21,11 @@ 'use strict';

function parse(file) {
try {
var source = _fs2.default.readFileSync(file, { encoding: 'utf-8' });
var jscodeReqest = utils.getComponentModuleJSCode(source, file);
var component = utils.getSandbox(jscodeReqest, file).default;
var doc = utils.getDocFile(jscodeReqest, file);
var vueDoc = utils.getVueDoc(doc, component);
return vueDoc;
} catch (e) {
console.log(e);
var source = _fs2.default.readFileSync(file, { encoding: 'utf-8' });
if (source === '') {
throw new Error('The document is empty');
}
var jscodeReqest = utils.getComponentModuleJSCode(source, file);
var component = utils.getSandbox(jscodeReqest, file).default;
var doc = utils.getDocFile(jscodeReqest, file);
var vueDoc = utils.getVueDoc(doc, component);
return vueDoc;
}

@@ -23,6 +23,7 @@ 'use strict';

return docReturn;
} catch (e) {
console.log('error', e);
return;
} catch (err) {
var errorMessage = err.toString();
console.log('\n' + errorMessage + '\n');
throw new Error(err);
}
}

@@ -21,2 +21,4 @@ 'use strict';

var fnNameMatchRegex = /^\s*function\s+([^\(\s]*)\s*/;
function getTypeName(prop) {

@@ -32,2 +34,3 @@ if (!prop) return _variables.UNDEFINED;

function getTypeNameToFunction(object) {
if (object.name.toLowerCase() === 'function') return 'func';
return object.name.toLowerCase();

@@ -48,5 +51,12 @@ }

obj['required'] = prop.required || _variables.EMPTY;
if (prop.default && typeof prop.default !== 'function') {
if (prop.default) {
var value = void 0;
if (typeof prop.default === 'function') {
var func = prop.default.toString().replace(fnNameMatchRegex, 'function');
value = JSON.parse((0, _stringify2.default)(func.replace(/\s\s+/g, ' ')));
} else {
value = (0, _stringify2.default)(prop.default);
}
obj['defaultValue'] = {
value: (0, _stringify2.default)(prop.default),
value: value,
computed: false

@@ -53,0 +63,0 @@ };

@@ -39,7 +39,11 @@ 'use strict';

var evalComponentCode = function evalComponentCode(code) {
var script = new _vm2.default.Script(code, {});
var sand = clone(_sandbox2.default);
var context = new _vm2.default.createContext(sand);
script.runInContext(context);
return sand.exports;
try {
var script = new _vm2.default.Script(code, {});
var sand = clone(_sandbox2.default);
var context = new _vm2.default.createContext(sand);
script.runInContext(context);
return sand.exports;
} catch (err) {
throw new Error('Can not compile the vue component', err);
}
};

@@ -46,0 +50,0 @@

@@ -47,32 +47,36 @@ 'use strict';

function getVueDoc(docFile, component) {
try {
var displayName = getFileNameComponent(docFile);
var displayName = void 0;
var docComponent = void 0;
if (docFile) {
displayName = getFileNameComponent(docFile);
docFile = docFile.filter(function (comment) {
return comment.kind !== 'package';
});
var docComponent = docFile.filter(function (comment) {
docComponent = docFile.filter(function (comment) {
return comment.longname === 'module.exports';
})[0];
var description = _variables.EMPTY;
var comment = _variables.EMPTY;
var tags = {};
if (docComponent) {
description = (0, _variables.getDescription)(docComponent);
comment = (0, _variables.getComment)(docComponent);
tags = (0, _processTags2.default)(docComponent, _variables.IGNORE_DEFAULT);
}
var props = (0, _processProps2.default)(docFile, component);
var methods = (0, _processMethods2.default)(docFile, component);
} else {
docFile = [];
displayName = component.name || _variables.EMPTY;
docComponent = false;
}
var description = _variables.EMPTY;
var comment = _variables.EMPTY;
var tags = {};
if (docComponent) {
description = (0, _variables.getDescription)(docComponent);
comment = (0, _variables.getComment)(docComponent);
tags = (0, _processTags2.default)(docComponent, _variables.IGNORE_DEFAULT);
}
var props = (0, _processProps2.default)(docFile, component);
var methods = (0, _processMethods2.default)(docFile, component);
return {
description: description,
methods: methods,
displayName: displayName,
props: props,
comment: comment,
tags: tags
};
} catch (e) {
console.log(e);
}
return {
description: description,
methods: methods,
displayName: displayName,
props: props,
comment: comment,
tags: tags
};
}

@@ -21,13 +21,15 @@ 'use strict';

var listMethods = [];
(0, _keys2.default)(component.methods).forEach(function (methodName) {
var docPart = docFile.filter(function (comment) {
return comment.longname.indexOf('methods.' + methodName) > -1;
})[0];
if (docPart) {
if (docPart['access'] && docPart['access'] === 'public') {
listMethods.push((0, _getMethod2.default)(methodName, docPart));
if (component.methods) {
(0, _keys2.default)(component.methods).forEach(function (methodName) {
var docPart = docFile.filter(function (comment) {
return comment.longname.indexOf('methods.' + methodName) > -1;
})[0];
if (docPart) {
if (docPart['access'] && docPart['access'] === 'public') {
listMethods.push((0, _getMethod2.default)(methodName, docPart));
}
}
}
});
});
}
return listMethods;
}

@@ -22,11 +22,13 @@ 'use strict';

var obj = {};
_blockTags2.default.filter(function (tagName) {
return ignoreTags.indexOf(tagName) === -1;
}).forEach(function (tagName) {
var tag = (0, _getTag2.default)(tagName, docPart);
if (tag) {
obj[tagName] = tag;
}
});
if (docPart) {
_blockTags2.default.filter(function (tagName) {
return ignoreTags.indexOf(tagName) === -1;
}).forEach(function (tagName) {
var tag = (0, _getTag2.default)(tagName, docPart);
if (tag) {
obj[tagName] = tag;
}
});
}
return obj;
}
{
"name": "vue-docgen-api",
"version": "1.0.3",
"version": "1.0.4",
"description": "Toolbox to extract information from Vue component files for documentation generation purposes.",

@@ -5,0 +5,0 @@ "bugs": {

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