vue-docgen-api
Advanced tools
Comparing version 4.74.0 to 4.74.1
@@ -1,3 +0,2 @@ | ||
import setupEventHandler from './setupEventHandler'; | ||
declare const _default: (typeof setupEventHandler)[]; | ||
declare const _default: ((documentation: import("../Documentation").default, componentDefinition: import("ast-types/lib/node-path").NodePath<any, any>, astPath: import("@babel/types").File, opt: import("../types").ParseOptions) => Promise<void>)[]; | ||
export default _default; |
import * as bt from '@babel/types'; | ||
import { NodePath } from 'ast-types/lib/node-path'; | ||
import type { Documentation } from '../Documentation'; | ||
import type { ParseOptions } from '../types'; | ||
/** | ||
@@ -12,3 +11,4 @@ * Extract information from an setup-style VueJs 3 component | ||
*/ | ||
export default function setupPropHandler(documentation: Documentation, componentDefinition: NodePath, astPath: bt.File, opt: ParseOptions): Promise<void>; | ||
declare const _default: (documentation: Documentation, componentDefinition: NodePath<any, any>, astPath: bt.File, opt: import("../types").ParseOptions) => Promise<void>; | ||
export default _default; | ||
export declare function getPropsFromLiteralType(documentation: Documentation, typeParamsPathMembers: any): void; |
@@ -75,3 +75,3 @@ "use strict"; | ||
*/ | ||
function setupPropHandler(documentation, componentDefinition, astPath, opt) { | ||
exports.default = (0, tsUtils_1.defineHandler)(function setupPropHandler(documentation, componentDefinition, astPath, opt) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -88,3 +88,2 @@ var propsDef; | ||
normalizedNodePath.node.callee.name === 'defineProps') { | ||
propsDef = normalizedNodePath.get('arguments', 0); | ||
if (normalizedNodePath.node.typeParameters) { | ||
@@ -95,14 +94,30 @@ var typeParamsPath = normalizedNodePath.get('typeParameters', 'params', 0); | ||
} | ||
else if (bt.isTSTypeReference(typeParamsPath.node) && | ||
bt.isIdentifier(typeParamsPath.node.typeName)) { | ||
// its a reference to an interface or type | ||
var typeName = typeParamsPath.node.typeName.name; // extract the identifier | ||
// find it's definition in the file | ||
var definitionPath = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, typeName, opt); | ||
// use the same process to exact info | ||
if (definitionPath) { | ||
getPropsFromLiteralType(documentation, definitionPath); | ||
else if (bt.isTSTypeReference(typeParamsPath.node)) { | ||
if (bt.isIdentifier(typeParamsPath.node.typeName)) { | ||
// its a reference to an interface or type | ||
var typeName = typeParamsPath.node.typeName.name; // extract the identifier | ||
// find it's definition in the file | ||
var definitionPath = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, typeName, opt); | ||
// use the same process to exact info | ||
if (definitionPath && | ||
(bt.isTSTypeLiteral(definitionPath.node) || | ||
bt.isTSInterfaceBody(definitionPath.node))) { | ||
getPropsFromLiteralType(documentation, definitionPath); | ||
} | ||
} | ||
else if (bt.isTSQualifiedName(typeParamsPath.node.typeName)) { | ||
// its a reference to an interface or type | ||
var importName = typeParamsPath.node.typeName.left.name; // extract the import identifier | ||
var typeName = typeParamsPath.node.typeName.right.name; // extract the identifier | ||
var definitionPath = (0, tsUtils_1.getTypeDefinitionFromIdentifier)(astPath, typeName, opt, importName); | ||
// use the same process to exact info | ||
if (definitionPath) { | ||
getPropsFromLiteralType(documentation, definitionPath); | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
propsDef = normalizedNodePath.get('arguments', 0); | ||
} | ||
// add defaults from withDefaults | ||
@@ -136,4 +151,3 @@ if (hasDefaults) { | ||
}); | ||
} | ||
exports.default = setupPropHandler; | ||
}); | ||
function getPropsFromLiteralType(documentation, typeParamsPathMembers) { | ||
@@ -140,0 +154,0 @@ typeParamsPathMembers.each(function (prop) { |
import * as bt from '@babel/types'; | ||
import { NodePath } from 'ast-types/lib/node-path'; | ||
import { ParseOptions } from '../../types'; | ||
export declare function getTypeDefinitionFromIdentifier(astPath: bt.File, typeName: string, opt: ParseOptions): NodePath | undefined; | ||
import Documentation from '../../Documentation'; | ||
export declare function defineHandler(handler: (documentation: Documentation, componentDefinition: NodePath, astPath: bt.File, opt: ParseOptions) => Promise<void>): (documentation: Documentation, componentDefinition: NodePath, astPath: bt.File, opt: ParseOptions) => Promise<void>; | ||
export declare function getTypeDefinitionFromIdentifier(astPath: bt.File, typeName: string, opt: ParseOptions, importName?: string): NodePath | undefined; | ||
declare const _default: {}; | ||
export default _default; |
@@ -40,3 +40,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTypeDefinitionFromIdentifier = void 0; | ||
exports.getTypeDefinitionFromIdentifier = exports.defineHandler = void 0; | ||
var fs_1 = __importDefault(require("fs")); | ||
@@ -48,2 +48,6 @@ var bt = __importStar(require("@babel/types")); | ||
var makePathResolver_1 = __importDefault(require("../../utils/makePathResolver")); | ||
function defineHandler(handler) { | ||
return handler; | ||
} | ||
exports.defineHandler = defineHandler; | ||
var getTypeDefinitionFromIdentifierFromModule = function (module, typeName, opt, pathResolver) { | ||
@@ -59,3 +63,3 @@ var parser = (0, babel_parser_1.default)({ plugins: ['typescript'] }); | ||
}; | ||
function getTypeDefinitionFromIdentifier(astPath, typeName, opt) { | ||
function getTypeDefinitionFromIdentifier(astPath, typeName, opt, importName) { | ||
var typeBody = undefined; | ||
@@ -81,2 +85,8 @@ var pathResolver = (0, makePathResolver_1.default)((0, path_1.dirname)(opt.filePath), opt.alias, opt.modules); | ||
}, | ||
visitImportNamespaceSpecifier: function (path) { | ||
if (!typeBody && path.value.local.name === importName) { | ||
typeBody = getTypeDefinitionFromIdentifierFromModule(path.parent.value.source.value, typeName, opt, pathResolver); | ||
} | ||
return false; | ||
}, | ||
visitTSInterfaceDeclaration: function (nodePath) { | ||
@@ -83,0 +93,0 @@ if (bt.isIdentifier(nodePath.node.id) && nodePath.node.id.name === typeName) { |
{ | ||
"name": "vue-docgen-api", | ||
"version": "4.74.0", | ||
"version": "4.74.1", | ||
"description": "Toolbox to extract information from Vue component files for documentation generation purposes.", | ||
@@ -54,2 +54,3 @@ "homepage": "https://vue-styleguidist.github.io", | ||
"@types/pug": "2.0.6", | ||
"@types/hash-sum": "^1.0.0", | ||
"dedent": "0.7.0", | ||
@@ -56,0 +57,0 @@ "globby": "10.0.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
797024
133
12448
16