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

vue-docgen-api

Package Overview
Dependencies
Maintainers
3
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 4.43.3 to 4.44.0

dist/script-handlers/slotHandlerLiteral.d.ts

13

dist/Documentation.d.ts

@@ -1,8 +0,9 @@

import { Descriptor, PropDescriptor, MethodDescriptor, SlotDescriptor, EventDescriptor, ComponentDoc, DocBlockTags, BlockTag, Param, UnnamedParam, Tag, ParamTag, ParamType } from 'vue-inbrowser-compiler-utils';
export { Descriptor, PropDescriptor, MethodDescriptor, SlotDescriptor, EventDescriptor, ComponentDoc, DocBlockTags, BlockTag, Param, UnnamedParam, Tag, ParamTag, ParamType };
import { Descriptor, PropDescriptor, MethodDescriptor, SlotDescriptor, EventDescriptor, ExposedDescriptor, ComponentDoc, DocBlockTags, BlockTag, Param, UnnamedParam, Tag, ParamTag, ParamType } from 'vue-inbrowser-compiler-utils';
export { Descriptor, PropDescriptor, MethodDescriptor, SlotDescriptor, EventDescriptor, ExposedDescriptor, ComponentDoc, DocBlockTags, BlockTag, Param, UnnamedParam, Tag, ParamTag, ParamType };
export default class Documentation {
private propsMap;
private eventsMap;
private slotsMap;
private methodsMap;
private slotsMap;
private eventsMap;
private exposedMap;
private dataMap;

@@ -18,5 +19,6 @@ private docsBlocks;

getPropDescriptor(propName: string): PropDescriptor;
getMethodDescriptor(methodName: string): MethodDescriptor;
getEventDescriptor(eventName: string): EventDescriptor;
getSlotDescriptor(slotName: string): SlotDescriptor;
getMethodDescriptor(methodName: string): MethodDescriptor;
getExposedDescriptor(exposedName: string): ExposedDescriptor;
toObject(): ComponentDoc;

@@ -26,1 +28,2 @@ private getDescriptor;

}
export { Documentation };

@@ -17,2 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Documentation = void 0;
var ts_map_1 = __importDefault(require("ts-map"));

@@ -23,5 +24,6 @@ var Documentation = /** @class */ (function () {

this.propsMap = new ts_map_1.default();
this.eventsMap = new ts_map_1.default();
this.slotsMap = new ts_map_1.default();
this.methodsMap = new ts_map_1.default();
this.slotsMap = new ts_map_1.default();
this.eventsMap = new ts_map_1.default();
this.exposedMap = new ts_map_1.default();
this.originExtendsMixin = {};

@@ -51,7 +53,2 @@ this.dataMap = new ts_map_1.default();

};
Documentation.prototype.getMethodDescriptor = function (methodName) {
return this.getDescriptor(methodName, this.methodsMap, function () { return ({
name: methodName
}); });
};
Documentation.prototype.getEventDescriptor = function (eventName) {

@@ -67,2 +64,12 @@ return this.getDescriptor(eventName, this.eventsMap, function () { return ({

};
Documentation.prototype.getMethodDescriptor = function (methodName) {
return this.getDescriptor(methodName, this.methodsMap, function () { return ({
name: methodName
}); });
};
Documentation.prototype.getExposedDescriptor = function (exposedName) {
return this.getDescriptor(exposedName, this.exposedMap, function () { return ({
name: exposedName
}); });
};
Documentation.prototype.toObject = function () {

@@ -113,2 +120,3 @@ var props = this.getObjectFromDescriptor(this.propsMap);

}());
exports.Documentation = Documentation;
exports.default = Documentation;

@@ -7,3 +7,3 @@ import * as bt from '@babel/types';

export declare type Handler = (doc: Documentation, componentDefinition: NodePath, ast: bt.File, opt: ParseOptions) => Promise<void>;
export default function parseScript(source: string, options: ParseOptions, documentation?: Documentation, forceSingleExport?: boolean): Promise<Documentation[] | undefined>;
export default function parseScript(source: string, options: ParseOptions, documentation?: Documentation, forceSingleExport?: boolean, noNeedForExport?: boolean): Promise<Documentation[] | undefined>;
export declare function addDefaultAndExecuteHandlers(componentDefinitions: Map<string, NodePath>, ast: bt.File, options: ParseOptions, documentation?: Documentation, forceSingleExport?: boolean): Promise<Documentation[] | undefined>;

@@ -79,4 +79,5 @@ "use strict";

var ERROR_MISSING_DEFINITION = 'No suitable component definition found';
function parseScript(source, options, documentation, forceSingleExport) {
function parseScript(source, options, documentation, forceSingleExport, noNeedForExport) {
if (forceSingleExport === void 0) { forceSingleExport = false; }
if (noNeedForExport === void 0) { noNeedForExport = false; }
return __awaiter(this, void 0, void 0, function () {

@@ -96,2 +97,5 @@ var plugins, ast, _a, componentDefinitions, ievSet, docs;

_a = (0, resolveExportedComponent_1.default)(ast), componentDefinitions = _a[0], ievSet = _a[1];
if (componentDefinitions.size === 0 && noNeedForExport) {
componentDefinitions.set('default', ast.program.body[0]);
}
if (!(componentDefinitions.size === 0)) return [3 /*break*/, 2];

@@ -98,0 +102,0 @@ return [4 /*yield*/, (0, documentRequiredComponents_1.default)(documentation, ievSet, undefined, options)

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

@@ -80,2 +91,3 @@ if (k2 === undefined) k2 = k;

var makePathResolver_1 = __importDefault(require("./utils/makePathResolver"));
var script_setup_handlers_1 = __importDefault(require("./script-setup-handlers"));
var read = (0, util_1.promisify)(fs_1.readFile);

@@ -129,11 +141,14 @@ function parseSFC(initialDoc, source, opt) {

docs = documentation ? [documentation] : [];
if (!parts.scriptSetup) return [3 /*break*/, 6];
return [3 /*break*/, 8];
if (!parts.scriptSetup) return [3 /*break*/, 7];
return [4 /*yield*/, parseScriptTag(parts.scriptSetup, pathResolver, opt, documentation, initialDoc !== undefined, true, parts.script ? parts.script.content : '')];
case 6:
if (!parts.script) return [3 /*break*/, 8];
docs = _d.sent();
return [3 /*break*/, 9];
case 7:
if (!parts.script) return [3 /*break*/, 9];
return [4 /*yield*/, parseScriptTag(parts.script, pathResolver, opt, documentation, initialDoc !== undefined)];
case 7:
case 8:
docs = _d.sent();
_d.label = 8;
case 8:
_d.label = 9;
case 9:
if (documentation && !documentation.get('displayName')) {

@@ -150,3 +165,5 @@ displayName = path.basename(opt.filePath).replace(/\.\w+$/, '');

exports.default = parseSFC;
function parseScriptTag(scriptTag, pathResolver, opt, documentation, forceSingleExport) {
function parseScriptTag(scriptTag, pathResolver, opt, documentation, forceSingleExport, isSetupScript, isSetupScriptOtherScript) {
if (isSetupScript === void 0) { isSetupScript = false; }
if (isSetupScriptOtherScript === void 0) { isSetupScriptOtherScript = ''; }
return __awaiter(this, void 0, void 0, function () {

@@ -188,4 +205,5 @@ var scriptSource, extSrc, extSrcAbs, extSource, _a, docs, _b;

: 'js';
opt = isSetupScript ? __assign(__assign({}, opt), { scriptPreHandlers: [], scriptHandlers: script_setup_handlers_1.default }) : opt;
if (!scriptSource) return [3 /*break*/, 6];
return [4 /*yield*/, (0, parse_script_1.default)(scriptSource, opt, documentation, forceSingleExport)];
return [4 /*yield*/, (0, parse_script_1.default)(isSetupScriptOtherScript + '\n' + scriptSource, opt, documentation, forceSingleExport, isSetupScript)];
case 5:

@@ -192,0 +210,0 @@ _b = (_c.sent()) || [];

@@ -212,3 +212,3 @@ "use strict";

? { names: typeTags.map(function (t) { return t.type.name; }) }
: undefined;
: eventDescriptor.type;
var propertyTags = nonNullTags.filter(function (tg) { return PROPERTY_TAGS.includes(tg.title); });

@@ -215,0 +215,0 @@ if (propertyTags.length) {

@@ -14,3 +14,3 @@ import classDisplayNameHandler from './classDisplayNameHandler';

import slotHandlerFunctional from './slotHandlerFunctional';
import slotHandlerLitteral from './slotHandlerLitteral';
import slotHandlerLitteral from './slotHandlerLiteral';
import { Handler } from '../parse-script';

@@ -17,0 +17,0 @@ export { classDisplayNameHandler, classMethodHandler, classPropHandler, classEventHandler, componentHandler, displayNameHandler, eventHandler, extendsHandler, methodHandler, mixinsHandler, propHandler, slotHandler, slotHandlerFunctional, slotHandlerLitteral };

@@ -33,4 +33,4 @@ "use strict";

exports.slotHandlerFunctional = slotHandlerFunctional_1.default;
var slotHandlerLitteral_1 = __importDefault(require("./slotHandlerLitteral"));
exports.slotHandlerLitteral = slotHandlerLitteral_1.default;
var slotHandlerLiteral_1 = __importDefault(require("./slotHandlerLiteral"));
exports.slotHandlerLitteral = slotHandlerLiteral_1.default;
var defaultHandlers = [

@@ -44,3 +44,3 @@ displayNameHandler_1.default,

slotHandlerFunctional_1.default,
slotHandlerLitteral_1.default,
slotHandlerLiteral_1.default,
classDisplayNameHandler_1.default,

@@ -47,0 +47,0 @@ classMethodHandler_1.default,

@@ -11,2 +11,3 @@ import * as bt from '@babel/types';

export default function propHandler(documentation: Documentation, path: NodePath, ast: bt.File, opt: ParseOptions): Promise<void>;
export declare function describePropsFromValue(documentation: Documentation, propsValuePath: NodePath<bt.ObjectExpression, any> | NodePath<bt.ArrayExpression, any>, ast: bt.File, opt: ParseOptions, modelPropertyName?: string | null): Promise<void>;
/**

@@ -13,0 +14,0 @@ * Deal with the description of the type

@@ -61,3 +61,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.extractValuesFromTags = exports.describeDefault = exports.describeRequired = exports.getValuesFromTypeAnnotation = exports.getTypeFromTypePath = exports.describeType = void 0;
exports.extractValuesFromTags = exports.describeDefault = exports.describeRequired = exports.getValuesFromTypeAnnotation = exports.getTypeFromTypePath = exports.describeType = exports.describePropsFromValue = void 0;
var bt = __importStar(require("@babel/types"));

@@ -88,8 +88,7 @@ var recast_1 = require("recast");

return __awaiter(this, void 0, void 0, function () {
var propsPath, modelPropertyName_1, propsValuePath, objProp, objPropFiltered;
var _this = this;
var propsPath, modelPropertyName, propsValuePath;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!bt.isObjectExpression(path.node)) return [3 /*break*/, 3];
if (!bt.isObjectExpression(path.node)) return [3 /*break*/, 2];
propsPath = path

@@ -102,4 +101,22 @@ .get('properties')

}
modelPropertyName_1 = getModelPropName(path);
modelPropertyName = getModelPropName(path);
propsValuePath = propsPath[0].get('value');
return [4 /*yield*/, describePropsFromValue(documentation, propsValuePath, ast, opt, modelPropertyName)];
case 1:
_a.sent();
_a.label = 2;
case 2: return [2 /*return*/];
}
});
});
}
exports.default = propHandler;
function describePropsFromValue(documentation, propsValuePath, ast, opt, modelPropertyName) {
if (modelPropertyName === void 0) { modelPropertyName = null; }
return __awaiter(this, void 0, void 0, function () {
var objProp, objPropFiltered;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!bt.isObjectExpression(propsValuePath.node)) return [3 /*break*/, 2];

@@ -117,5 +134,3 @@ objProp = propsValuePath.get('properties');

docBlock = (0, getDocblock_1.default)(prop);
jsDoc = docBlock
? (0, getDoclets_1.default)(docBlock)
: { description: '', tags: [] };
jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
jsDocTags = jsDoc.tags ? jsDoc.tags : [];

@@ -130,3 +145,3 @@ propertyName = bt.isIdentifier(propNode.key)

}
isPropertyModel = jsDocTags.some(function (t) { return t.title === 'model'; }) || propertyName === modelPropertyName_1;
isPropertyModel = jsDocTags.some(function (t) { return t.title === 'model'; }) || propertyName === modelPropertyName;
propName = isPropertyModel ? 'v-model' : propertyName;

@@ -168,5 +183,3 @@ propDescriptor = documentation.getPropDescriptor(propName);

.get('properties')
.filter(function (p) {
return bt.isObjectProperty(p.node);
});
.filter(function (p) { return bt.isObjectProperty(p.node); });
// type and values

@@ -214,3 +227,3 @@ describeTypeAndValuesFromPath(propValuePath, propDescriptor);

}
exports.default = propHandler;
exports.describePropsFromValue = describePropsFromValue;
/**

@@ -370,3 +383,3 @@ * Deal with the description of the type

var isOldSchoolFunction = bt.isFunctionExpression(defaultFunction.node);
// if default is undefined or null, litterals are allowed
// if default is undefined or null, literals are allowed
if (bt.isNullLiteral(defaultFunction.node) ||

@@ -373,0 +386,0 @@ (bt.isIdentifier(defaultFunction.node) && defaultFunction.node.name === 'undefined')) {

@@ -11,7 +11,7 @@ "use strict";

function extractLeadingComment(siblings, templateAst) {
// if the slot has no comment siblings, the slot is not documented
// if the item has no siblings, the item is not documented
if (siblings.length < 1) {
return [];
}
// First find the position of the slot in the list
// First find the position of the item in the siblings list
var i = siblings.length - 1;

@@ -26,5 +26,13 @@ var currentSlotIndex = -1;

// get all siblings before the current node
var slotSiblingsBeforeSlot = siblings.slice(0, currentSlotIndex).reverse();
var slotSiblingsBeforeSlot = siblings
.slice(0, currentSlotIndex)
.filter(function (s) { return !(0, guards_1.isTextNode)(s); })
.reverse();
// find the first node that is not a potential comment
var indexLastComment = slotSiblingsBeforeSlot.findIndex(function (sibling) { return !(0, guards_1.isCommentNode)(sibling); });
var indexLastComment = slotSiblingsBeforeSlot.findIndex(function (sibling) {
return !(0, guards_1.isCommentNode)(sibling) &&
!((0, guards_1.isInterpolationNode)(sibling) &&
(0, guards_1.isSimpleExpressionNode)(sibling.content) &&
isCodeOnlyJSComment(sibling.content.content));
});
// cut the comments array on this index

@@ -35,6 +43,38 @@ var slotLeadingComments = (indexLastComment > 0

.reverse()
.filter(guards_1.isCommentNode);
.filter(function (s) { return (0, guards_1.isCommentNode)(s) || (0, guards_1.isInterpolationNode)(s); });
// return each comment text
return slotLeadingComments.map(function (comment) { return comment.content.trim(); });
return slotLeadingComments.map(function (comment) {
return (0, guards_1.isCommentNode)(comment)
? comment.content.trim()
: (0, guards_1.isInterpolationNode)(comment) && (0, guards_1.isSimpleExpressionNode)(comment.content)
? cleanUpComment(comment.content.content.trim())
: '';
});
}
exports.default = extractLeadingComment;
function isCodeOnlyJSComment(code) {
var codeTrimmed = code.trim();
return (
// check single-line comments
isCodeOnlyJSCommentSingleLine(codeTrimmed) ||
// check multi-line comments
isCodeOnlyJSCommentMultiLine(codeTrimmed));
}
function isCodeOnlyJSCommentSingleLine(code) {
return code.split('\n').every(function (line) { return line.startsWith('//'); });
}
function isCodeOnlyJSCommentMultiLine(code) {
return (code.startsWith('/*') &&
code.endsWith('*/') &&
// avoid picking up comments that have multiple blocks
code.slice(2, -2).indexOf('*/') === -1);
}
function cleanUpComment(comment) {
return isCodeOnlyJSCommentMultiLine(comment)
? comment.slice(2, -2)
: comment
.trim()
.slice(2)
.split(/\n\/\//g)
.join('\n');
}
import * as bt from '@babel/types';
import { ParamType } from '../Documentation';
import { NodePath } from 'ast-types/lib/node-path';
import { BlockTag, ParamType } from '../Documentation';
export default function getTypeFromAnnotation(typeNode: bt.TypeAnnotation | bt.TSTypeAnnotation | bt.Noop | null): ParamType | undefined;
export declare function decorateItem(item: NodePath, propDescriptor: {
description?: string;
tags?: Record<string, BlockTag[]>;
}): void;

@@ -21,4 +21,11 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.decorateItem = void 0;
var bt = __importStar(require("@babel/types"));
var getDocblock_1 = __importDefault(require("./getDocblock"));
var getDoclets_1 = __importDefault(require("./getDoclets"));
var transformTagsIntoObject_1 = __importDefault(require("./transformTagsIntoObject"));
function getTypeFromAnnotation(typeNode) {

@@ -100,1 +107,13 @@ if (typeNode) {

}
function decorateItem(item, propDescriptor) {
var docBlock = (0, getDocblock_1.default)(item);
var jsDoc = docBlock ? (0, getDoclets_1.default)(docBlock) : { description: '', tags: [] };
var jsDocTags = jsDoc.tags ? jsDoc.tags : [];
if (jsDoc.description) {
propDescriptor.description = jsDoc.description;
}
if (jsDocTags.length) {
propDescriptor.tags = (0, transformTagsIntoObject_1.default)(jsDocTags);
}
}
exports.decorateItem = decorateItem;

@@ -1,3 +0,4 @@

import { Node, BaseElementNode, DirectiveNode, SimpleExpressionNode, CompoundExpressionNode, InterpolationNode, CommentNode, AttributeNode } from '@vue/compiler-dom';
export declare function isCommentNode(node: any): node is CommentNode;
import { Node, BaseElementNode, DirectiveNode, SimpleExpressionNode, CompoundExpressionNode, InterpolationNode, CommentNode, AttributeNode, TextNode } from '@vue/compiler-dom';
export declare function isTextNode(node?: Node): node is TextNode;
export declare function isCommentNode(node?: Node): node is CommentNode;
export declare function isBaseElementNode(node?: Node): node is BaseElementNode;

@@ -4,0 +5,0 @@ export declare function isDirectiveNode(prop?: Node): prop is DirectiveNode;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isInterpolationNode = exports.isCompoundExpressionNode = exports.isSimpleExpressionNode = exports.isAttributeNode = exports.isDirectiveNode = exports.isBaseElementNode = exports.isCommentNode = void 0;
exports.isInterpolationNode = exports.isCompoundExpressionNode = exports.isSimpleExpressionNode = exports.isAttributeNode = exports.isDirectiveNode = exports.isBaseElementNode = exports.isCommentNode = exports.isTextNode = void 0;
function isTextNode(node) {
return !!node && node.type === 2 /* TEXT */;
}
exports.isTextNode = isTextNode;
function isCommentNode(node) {
return node.type === 3 /* COMMENT */;
return !!node && node.type === 3 /* COMMENT */;
}

@@ -7,0 +11,0 @@ exports.isCommentNode = isCommentNode;

{
"name": "vue-docgen-api",
"version": "4.43.3",
"version": "4.44.0",
"description": "Toolbox to extract information from Vue component files for documentation generation purposes.",

@@ -42,3 +42,3 @@ "homepage": "https://vue-styleguidist.github.io",

"ts-map": "^1.0.3",
"vue-inbrowser-compiler-utils": "^4.43.3"
"vue-inbrowser-compiler-utils": "^4.44.0"
},

@@ -55,3 +55,3 @@ "devDependencies": {

},
"gitHead": "1735ff875b3c29284efa1fb8ddc0ba0758bf2c6a"
"gitHead": "1ea9ecfac70f3536d0d0697d7b308f384c7fe5a4"
}
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