UNPKG

type2docfx

Version:

A tool to convert json format output from TypeDoc to schema driven reference model for DocFx to consume.

66 lines 2.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Parser = void 0; var converter_1 = require("./converters/converter"); var context_1 = require("./converters/context"); var Parser = /** @class */ (function () { function Parser() { } Parser.prototype.traverse = function (node, uidMapping, context) { var collection = new Array(); if (this.needIgnore(node)) { return collection; } var models = new converter_1.Converter().convert(node, context); for (var _i = 0, models_1 = models; _i < models_1.length; _i++) { var model = models_1[_i]; uidMapping[node.id] = model.uid; collection.push(model); } if (!node.children || node.children.length <= 0) { return collection; } for (var _a = 0, _b = node.children; _a < _b.length; _a++) { var child = _b[_a]; var uid = models.length > 0 ? models[0].uid : context.PackageName; var newContext = new context_1.Context(uid, node.kindString, context.PackageName, context.References); if (models.length > 0) { models[0].children = [].concat(models[0].children, this.traverse(child, uidMapping, newContext)); } else { collection = [].concat(collection, this.traverse(child, uidMapping, newContext)); } } return collection; }; Parser.prototype.needIgnore = function (node) { if (node.name && node.name[0] === '_') { return true; } if (node.flags.isPrivate || node.flags.isProtected) { return true; } if (this.isInternal(node)) { return true; } if (!node.flags.isExported && node.sources && !node.sources[0].fileName.toLowerCase().endsWith('.d.ts')) { return true; } return false; }; Parser.prototype.isInternal = function (node) { if (node && node.comment && node.comment.tags) { node.comment.tags.forEach(function (tag) { if (tag.tag === 'internal') { return true; } }); } return false; }; return Parser; }()); exports.Parser = Parser; //# sourceMappingURL=parser.js.map