dgeni-packages
Version:
A collection of dgeni packages for generating documentation from source code
42 lines • 1.85 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseApiDoc = void 0;
const ts = require("typescript");
const FileInfo_1 = require("../services/TsParser/FileInfo");
class BaseApiDoc {
constructor(host, moduleDoc, symbol, declaration, aliasSymbol) {
this.host = host;
this.moduleDoc = moduleDoc;
this.symbol = symbol;
this.declaration = declaration;
this.aliasSymbol = aliasSymbol;
this.name = this.aliasSymbol ? this.aliasSymbol.name : this.symbol.name;
this.aliases = [this.name, this.moduleDoc.id + "/" + this.name];
this.id = this.moduleDoc.id + "/" + this.name;
this.basePath = this.moduleDoc.basePath;
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.content = this.host.getContent(this.declaration);
this.path = '';
this.outputPath = '';
this.originalModule = this.fileInfo.projectRelativePath
.replace(new RegExp("\\." + this.fileInfo.extension + "$"), "");
this.typeChecker = this.moduleDoc.typeChecker;
}
getTypeString(decl) {
if (!ts.isVariableDeclaration(decl) && !ts.isPropertyDeclaration(decl) && !ts.isParameter(decl)) {
return undefined;
}
if (!decl.type && !decl.initializer) {
return undefined;
}
const type = decl.type ?
this.typeChecker.getTypeFromTypeNode(decl.type) :
this.typeChecker.getTypeAtLocation(decl);
return this.host.typeToString(this.typeChecker, type);
}
}
exports.BaseApiDoc = BaseApiDoc;
//# sourceMappingURL=ApiDoc.js.map