UNPKG

dgeni-packages

Version:

A collection of dgeni packages for generating documentation from source code

41 lines 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ModuleDoc = void 0; const path = require("canonical-path"); const FileInfo_1 = require("../services/TsParser/FileInfo"); /** * A module doc represents an ES6 module that contains exports such as classes, functions, constants, etc, * which are represented by docs of their own. */ class ModuleDoc { constructor(symbol, basePath, hidePrivateMembers, typeChecker) { this.symbol = symbol; this.basePath = basePath; this.hidePrivateMembers = hidePrivateMembers; this.typeChecker = typeChecker; this.docType = 'module'; this.id = ensureRelative(this.basePath, this.symbol.name.replace(/^"|"$/g, '').replace(/\/index$/, '')); this.name = this.id.split('/').pop(); this.declaration = this.symbol.valueDeclaration; this.aliases = [this.id, this.name]; this.exports = []; this.fileInfo = new FileInfo_1.FileInfo(this.declaration, this.basePath); this.startingLine = this.fileInfo.location.start.line + (this.fileInfo.location.start.character ? 1 : 0); this.endingLine = this.fileInfo.location.end.line; this.path = ''; this.outputPath = ''; this.content = ''; } } exports.ModuleDoc = ModuleDoc; /** * Convert a potentially absolute path to relative. * * If `toPath` is already relative, it is practically returned unchanged. If it is an absolute path, * it is resolved relative to `fromPath` (which should always be an absolute path). */ function ensureRelative(absoluteFromPath, toPath) { const absoluteToPath = path.resolve(absoluteFromPath, toPath); return path.relative(absoluteFromPath, absoluteToPath); } //# sourceMappingURL=ModuleDoc.js.map