@irwinproject/storybook-addon-tsdoc
Version:
Generate mdx documentation from your typescript!
44 lines (43 loc) • 1.93 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSignature = exports.sig = void 0;
const node_tools_1 = require("./node-tools");
const SyntaxKindDelegator_1 = require("./SyntaxKindDelegator");
const SyntaxKindDelegator_types_1 = __importDefault(require("./SyntaxKindDelegator.types"));
const decorators_1 = require("./decorators");
const console_log_colors_1 = require("console-log-colors");
const TS_1 = __importDefault(require("./TS"));
const node_signature_map_1 = require("./node-signature-map");
/**
* A list of types to be ignored... perhaps I should build this into bySyntax
*/
const Ignores = new Set([
SyntaxKindDelegator_types_1.default.MultiLineCommentTrivia
]);
/**
* Just a convenience method to make the same bySyntax method reusable.
* @param node
* @returns
*/
const sig = (node) => (!!node && !Ignores.has(node.getKind())) ? (0, SyntaxKindDelegator_1.bySyntax)(node, node_signature_map_1.nodeSignatureMap, (n) => {
if (!n)
return '';
if ((0, node_tools_1.isPrimitive)(n))
return (0, decorators_1.$type)(n.getText());
TS_1.default.err("Signature Missing type", (0, console_log_colors_1.yellow)(n.getKindName()), (0, console_log_colors_1.gray)((0, node_tools_1.getFullName)(n)), n.getText());
return "";
}) : '';
exports.sig = sig;
/**
* Once a full signature name is resolved the typing of the object will be necessary. This typing however will be different for different declaration type. As such I will be handling these similar to the SyntaxKind... I need a SyntaxKind switching function
* @todo this is unecessary these functions arent public.
* @param node
*/
const getSignature = (node) => {
const s = (0, exports.sig)(node);
return s;
};
exports.getSignature = getSignature;