UNPKG

dgeni-packages

Version:

A collection of dgeni packages for generating documentation from source code

56 lines 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getExportDocType = void 0; const typescript_1 = require("typescript"); /* tslint:disable:no-bitwise */ function getExportDocType(symbol) { if (symbol.flags & typescript_1.SymbolFlags.Function) { return 'function'; } if (symbol.flags & typescript_1.SymbolFlags.Class) { return 'class'; } if (symbol.flags & typescript_1.SymbolFlags.Interface) { return 'interface'; } if (symbol.flags & typescript_1.SymbolFlags.ConstEnum) { return 'enum'; } if (symbol.flags & typescript_1.SymbolFlags.RegularEnum) { return 'enum'; } if (symbol.flags & typescript_1.SymbolFlags.Property) { return 'module-property'; } if (symbol.flags & typescript_1.SymbolFlags.TypeAlias) { return 'type-alias'; } if (symbol.flags & typescript_1.SymbolFlags.FunctionScopedVariable) { return 'var'; } if (symbol.flags & typescript_1.SymbolFlags.BlockScopedVariable) { return getBlockScopedVariableDocType(symbol); } if (symbol.flags & typescript_1.SymbolFlags.ValueModule) { return 'value-module'; } if (symbol.flags & typescript_1.SymbolFlags.NamespaceModule) { return 'namespace'; } throw new Error(`Unknown symbol type: symbolName: ${symbol.name} symbolType: ${symbol.flags} file: ${symbol.getDeclarations()[0].getSourceFile().fileName}`); } exports.getExportDocType = getExportDocType; function getBlockScopedVariableDocType(symbol) { let node = symbol.valueDeclaration || symbol.getDeclarations()[0]; while (node) { if (node.flags & typescript_1.NodeFlags.Const) { return 'const'; } node = node.parent; } return 'let'; } //# sourceMappingURL=getExportDocType.js.map