@irwinproject/storybook-addon-tsdoc
Version:
Generate mdx documentation from your typescript!
15 lines (14 loc) • 7.28 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.nodeSignatureMap = void 0;
const decorators_1 = require("./decorators");
const node_signature_1 = require("./node-signature");
const node_tools_1 = require("./node-tools");
const signitors_1 = require("./signitors");
const SyntaxKindDelegator_1 = require("./SyntaxKindDelegator");
const SyntaxKindDelegator_types_1 = __importDefault(require("./SyntaxKindDelegator.types"));
const utils_1 = require("./utils");
exports.nodeSignatureMap = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ [SyntaxKindDelegator_types_1.default.ArrayType]: node => (0, node_signature_1.sig)(node.getElementTypeNode()) + '[]', [SyntaxKindDelegator_types_1.default.ParenthesizedType]: node => `(${(0, signitors_1.fromTypeNode)(node)})`, [SyntaxKindDelegator_types_1.default.Constructor]: node => `${(0, decorators_1.$type)("new")} (${node.getParameters().map(p => (0, node_signature_1.sig)(p)).join(', ')})=>${(0, decorators_1.$type)((0, node_tools_1.getName)(node.getParent()))}`, [SyntaxKindDelegator_types_1.default.SetAccessor]: node => node.getParameters().map(p => (0, node_signature_1.sig)(p)).join(', '), [SyntaxKindDelegator_types_1.default.ConditionalType]: node => `${(0, node_signature_1.sig)(node.getCheckType())} extends ${(0, node_signature_1.sig)(node.getExtendsType())} ? ${(0, node_signature_1.sig)(node.getTrueType())}<br/>: ${(0, node_signature_1.sig)(node.getFalseType())}`, [SyntaxKindDelegator_types_1.default.ExpressionWithTypeArguments]: node => `${(0, node_signature_1.sig)(node.getExpression())}${node.getTypeArguments().map(a => (0, node_signature_1.sig)(a)).join(', ').wrap('<', '>')}`, [SyntaxKindDelegator_types_1.default.RestType]: node => `...${(0, signitors_1.fromTypeNode)(node)}`, [SyntaxKindDelegator_types_1.default.QualifiedName]: node => `${(0, node_signature_1.sig)(node.getLeft())}.${(0, node_signature_1.sig)(node.getRight())}`, [SyntaxKindDelegator_types_1.default.TypePredicate]: node => `${(0, node_signature_1.sig)(node.getParameterNameNode())} ${node.hasAssertsModifier() ? (0, node_signature_1.sig)(node.getAssertsModifier()) : 'is'} ${(0, node_signature_1.sig)(node.getTypeNode())}`, [SyntaxKindDelegator_types_1.default.TypeOperator]: node => `${(0, decorators_1.$kind)((0, signitors_1.getOperator)(node))} ${(0, signitors_1.fromTypeNode)(node)}`, [SyntaxKindDelegator_types_1.default.BinaryExpression]: node => `${(0, node_signature_1.sig)(node.getLeft())} ${(0, node_signature_1.sig)(node.getOperatorToken())} ${(0, node_signature_1.sig)(node.getRight())}`, [SyntaxKindDelegator_types_1.default.CallExpression]: node => (0, signitors_1.fromType)(node.getReturnType()), [SyntaxKindDelegator_types_1.default.IndexedAccessType]: node => `${(0, node_signature_1.sig)(node.getObjectTypeNode())}[${node.getIndexTypeNode()}]` }, (0, SyntaxKindDelegator_1.combineSyntax)([SyntaxKindDelegator_types_1.default.FunctionDeclaration, SyntaxKindDelegator_types_1.default.FunctionExpression, SyntaxKindDelegator_types_1.default.MethodDeclaration, SyntaxKindDelegator_types_1.default.FunctionType, SyntaxKindDelegator_types_1.default.MethodSignature, SyntaxKindDelegator_types_1.default.ArrowFunction], signitors_1.fnSignature)), (0, SyntaxKindDelegator_1.combineSyntax)([SyntaxKindDelegator_types_1.default.PropertySignature, SyntaxKindDelegator_types_1.default.PropertyDeclaration, SyntaxKindDelegator_types_1.default.PropertyAssignment], signitors_1.propertyDecSig)), (0, SyntaxKindDelegator_1.combineSyntax)([SyntaxKindDelegator_types_1.default.BindingElement], signitors_1.fromTypeNode)), (0, SyntaxKindDelegator_1.combineSyntax)([SyntaxKindDelegator_types_1.default.ArrayLiteralExpression, SyntaxKindDelegator_types_1.default.TupleType, SyntaxKindDelegator_types_1.default.ArrayBindingPattern], signitors_1.arrayLiteral)), (0, SyntaxKindDelegator_1.combineSyntax)([SyntaxKindDelegator_types_1.default.ObjectLiteralExpression, SyntaxKindDelegator_types_1.default.ObjectBindingPattern, SyntaxKindDelegator_types_1.default.TypeLiteral], signitors_1.objLiteral)), (0, SyntaxKindDelegator_1.combineSyntax)([SyntaxKindDelegator_types_1.default.AsteriskAsteriskEqualsToken, SyntaxKindDelegator_types_1.default.AsteriskAsteriskToken, SyntaxKindDelegator_types_1.default.AsteriskEqualsToken, SyntaxKindDelegator_types_1.default.AsteriskToken, SyntaxKindDelegator_types_1.default.PlusToken, SyntaxKindDelegator_types_1.default.PlusPlusToken, SyntaxKindDelegator_types_1.default.PlusEqualsToken, SyntaxKindDelegator_types_1.default.MinusToken, SyntaxKindDelegator_types_1.default.MinusEqualsToken, SyntaxKindDelegator_types_1.default.MinusEqualsToken, SyntaxKindDelegator_types_1.default.SlashToken, SyntaxKindDelegator_types_1.default.SlashEqualsToken, SyntaxKindDelegator_types_1.default.LessThanToken, SyntaxKindDelegator_types_1.default.LessThanEqualsToken, SyntaxKindDelegator_types_1.default.GreaterThanEqualsToken], node => (0, utils_1.escape)(node.getText()))), (0, SyntaxKindDelegator_1.combineSyntax)([SyntaxKindDelegator_types_1.default.StringLiteral, SyntaxKindDelegator_types_1.default.NumericLiteral, SyntaxKindDelegator_types_1.default.BigIntLiteral, SyntaxKindDelegator_types_1.default.TrueKeyword, SyntaxKindDelegator_types_1.default.FalseKeyword], signitors_1.literal)), { [SyntaxKindDelegator_types_1.default.TypeAliasDeclaration]: signitors_1.typeAliasDeclaration, [SyntaxKindDelegator_types_1.default.TypeReference]: signitors_1.typeReference, [SyntaxKindDelegator_types_1.default.TypeParameter]: signitors_1.typeParameter, [SyntaxKindDelegator_types_1.default.NamedTupleMember]: signitors_1.namedTupleMember, [SyntaxKindDelegator_types_1.default.PropertyAccessExpression]: signitors_1.propertyAccessExpression, [SyntaxKindDelegator_types_1.default.UnionType]: signitors_1.unionType, [SyntaxKindDelegator_types_1.default.IntersectionType]: signitors_1.intersectionType, [SyntaxKindDelegator_types_1.default.LiteralType]: signitors_1.literalType, [SyntaxKindDelegator_types_1.default.Identifier]: signitors_1.identifier, [SyntaxKindDelegator_types_1.default.Parameter]: signitors_1.parameter, [SyntaxKindDelegator_types_1.default.ClassDeclaration]: signitors_1.classDeclaration, [SyntaxKindDelegator_types_1.default.ClassExpression]: signitors_1.classDeclaration, [SyntaxKindDelegator_types_1.default.InterfaceDeclaration]: signitors_1.interfaceDeclaration, [SyntaxKindDelegator_types_1.default.GetAccessor]: signitors_1.getAccessor, [SyntaxKindDelegator_types_1.default.VariableDeclaration]: signitors_1.variableDeclaration, [SyntaxKindDelegator_types_1.default.NewExpression]: signitors_1.newExpression, [SyntaxKindDelegator_types_1.default.ObjectKeyword]: () => '{}', [SyntaxKindDelegator_types_1.default.StringLiteral]: node => (0, decorators_1.$literal)((0, utils_1.escape)(node.getText())), [SyntaxKindDelegator_types_1.default.NumericLiteral]: node => (0, decorators_1.$literal)(node.getText()), [SyntaxKindDelegator_types_1.default.EnumDeclaration]: signitors_1.fromName, [SyntaxKindDelegator_types_1.default.EnumMember]: signitors_1.enummember });