本文整理汇总了TypeScript中typedoc/dist/lib/converter.Context类的典型用法代码示例。如果您正苦于以下问题:TypeScript Context类的具体用法?TypeScript Context怎么用?TypeScript Context使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: onEnd
private onEnd(context: Context) {
if (this.excludeNotExported) {
context.removeReflections(this.notExported);
this.notExported = undefined!;
}
this.application.options.setValue("excludeNotExported", this.excludeNotExported);
}
示例2: onCreateDeclaration
private onCreateDeclaration(context: Context, reflection: Reflection, node: ts.Node | undefined) {
// rename built-in symbols
const match = /^__@(\w+)$/.exec(reflection.name);
if (match) {
context.updateReflection(reflection, { name: `[Symbol.${match[1]}]` });
}
// rename computed properties
if (reflection.kindOf(ReflectionKind.ClassMember) && reflection.name === "__computed" && node && ts.isDeclaration(node)) {
const name = ts.getNameOfDeclaration(node);
const symbol = name && context.checker.getSymbolAtLocation(name); // get the late-bound symbol
if (name || symbol) {
context.updateReflection(reflection, {
name: symbol
? context.checker.symbolToString(symbol, /*node*/ undefined, ts.SymbolFlags.ClassMember)
: node.getText()
});
}
else {
this.reflectionsToRemove.add(reflection);
}
}
}
示例3: finishResolution
private finishResolution(context: Context, reflection: DeclarationReflection) {
const binding = reflection.exportOf;
if (!binding || !binding.reflection) return;
binding.isExportStar = binding.reflection.kindOf(ReflectionKind.ExternalModule);
if (!binding.reflection.flags.isExported && reflection.parent === binding.reflection.parent) {
// take on the name of the first export binding.
context.updateReflection(binding.reflection, { name: reflection.name });
binding.reflection.setFlag(ReflectionFlag.Exported, true);
this.notExported.delete(binding.reflection);
this.notExported.add(reflection);
}
else {
if (reflection.kind !== binding.reflection.kind && reflection.parent.kind === binding.reflection.parent.kind) {
context.updateReflection(reflection, { kind: binding.reflection.kind });
if (binding.reflection instanceof DeclarationReflection) {
if (binding.reflection.comment) reflection.comment = binding.reflection.comment;
if (binding.reflection.defaultValue) reflection.defaultValue = binding.reflection.defaultValue;
if (binding.reflection.getSignature) reflection.getSignature = binding.reflection.getSignature;
if (binding.reflection.setSignature) reflection.setSignature = binding.reflection.setSignature;
if (binding.reflection.indexSignature) reflection.indexSignature = binding.reflection.indexSignature;
if (binding.reflection.type) reflection.type = binding.reflection.type;
if (binding.reflection.typeParameters) reflection.typeParameters = binding.reflection.typeParameters;
if (binding.reflection.overwrites) reflection.overwrites = binding.reflection.overwrites;
if (binding.reflection.inheritedFrom) reflection.inheritedFrom = binding.reflection.inheritedFrom;
if (binding.reflection.implementationOf) reflection.implementationOf = binding.reflection.implementationOf;
if (binding.reflection.extendedTypes) reflection.extendedTypes = binding.reflection.extendedTypes;
if (binding.reflection.extendedBy) reflection.extendedBy = binding.reflection.extendedBy;
if (binding.reflection.implementedTypes) reflection.implementedTypes = binding.reflection.implementedTypes;
if (binding.reflection.implementedBy) reflection.implementedBy = binding.reflection.implementedBy;
if (binding.reflection.typeHierarchy) reflection.typeHierarchy = binding.reflection.typeHierarchy;
if (binding.reflection.signatures) reflection.signatures = binding.reflection.signatures.map(sig => cloneSignatureReflectionWithName(sig, reflection, binding));
if (binding.reflection.sources) reflection.sources = binding.reflection.sources;
}
}
}
}
示例4: onCreateDeclaration
private onCreateDeclaration(context: Context, reflection: DeclarationReflection, node: ts.Node | undefined) {
if (node && ts.isExportSpecifier(node)) {
return;
}
if (node && node.parent && ts.isSourceFile(node.parent) && !ts.isExternalModule(node.parent)) {
// ignore globals
return;
}
if (reflection.kindOf(ReflectionKind.ExternalModule) && node && ts.isSourceFile(node) && node.symbol) {
const renameTo = getRename(node);
if (renameTo) {
this.renames.push({ symbolID: context.getSymbolID(node.symbol), renameTo });
}
}
if (reflection.kindOf(ReflectionKind.Method) && reflection.flags.isExported && node && ts.isFunctionDeclaration(node) && !(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export)) {
// A function in a module that merges with a class declaration should *not* be explicitly exported.
reflection.setFlag(ReflectionFlag.Exported, false);
}
if (reflection.kindOf(ReflectionKind.ModuleMember | ReflectionKind.ClassMember) && !reflection.flags.isExported) {
this.notExported.add(reflection);
}
}
示例5: convert
convert(context: Context, node: ts.ExportDeclaration) {
if (node.exportClause) {
for (const specifier of node.exportClause.elements) {
const exportedName = ts.unescapeLeadingUnderscores(specifier.name.escapedText);
const localName = specifier.propertyName ? ts.unescapeLeadingUnderscores(specifier.propertyName.escapedText) : exportedName;
const symbol = getTargetSymbol(context, context.checker.getExportSpecifierLocalTargetSymbol(specifier));
// const kind = !symbol ? ReflectionKind.Variable :
// symbol.flags & ts.SymbolFlags.Function ? ReflectionKind.Function :
// symbol.flags & ts.SymbolFlags.Class ? ReflectionKind.Class :
// symbol.flags & ts.SymbolFlags.Interface ? ReflectionKind.Interface :
// symbol.flags & ts.SymbolFlags.Enum ? ReflectionKind.Enum :
// symbol.flags & ts.SymbolFlags.TypeAlias ? ReflectionKind.TypeAlias :
// symbol.flags & ts.SymbolFlags.Variable ? ReflectionKind.Variable :
// // symbol.flags & ts.SymbolFlags.Module ? ReflectionKind.Module :
// ReflectionKind.Variable;
const kind = ReflectionKind.Export;
const reflection = createDeclaration(context, specifier, kind, exportedName);
if (reflection) {
reflection.exportOf = new ExportBinding(localName, symbol && context.getSymbolID(symbol));
}
}
}
return context.scope;
}
示例6: onCreateParameter
private onCreateParameter(context: Context, parameter: ParameterReflection, node: ts.ParameterDeclaration | undefined) {
if (node && (ts.isObjectBindingPattern(node.name) || ts.isArrayBindingPattern(node.name)) && parameter.type) {
parameter.type = context.converter.convertType(context, node.type, context.getTypeAtLocation(node));
}
}
示例7: onEnd
private onEnd(context: Context) {
context.removeReflections(this.reflectionsToRemove);
this.reflectionsToRemove = undefined!;
enableRename = false;
}
示例8: onEnd
private onEnd(context: Context) {
context.removeReflections(this.reflectionsToRemove);
this.shouldStripInternal = false;
this.reflectionsToRemove = undefined!;
}
示例9: createBiblioReflection
function createBiblioReflection(name: string, url: string) {
const symbol = checker.resolveName(name, undefined, ts.SymbolFlags.Type, false);
if (symbol) {
for (const node of symbol.declarations) {
const kind =
ts.isInterfaceDeclaration(node) ? ReflectionKind.Interface :
ts.isClassDeclaration(node) ? ReflectionKind.Class :
ts.isEnumDeclaration(node) ? ReflectionKind.Enum :
ts.isModuleDeclaration(node) ? ts.isStringLiteral(node.name) ? ReflectionKind.ExternalModule : ReflectionKind.Module :
ts.isTypeAliasDeclaration(node) ? ReflectionKind.TypeAlias :
ts.isVariableDeclaration(node) ? ReflectionKind.Variable :
undefined;
if (kind === undefined) continue;
const reflection = new DeclarationReflection(context.project, name, kind);
context.registerReflection(reflection, node, symbol);
context.trigger(Converter.EVENT_CREATE_DECLARATION, reflection, node);
if (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)) {
context.withScope(reflection, node.typeParameters!, () => {});
}
if (reflection) {
reflection.url = url;
reflection.urlTarget = "external";
}
}
}
}
示例10: removeEmptyReflection
function removeEmptyReflection(reflection: Reflection) {
if (reflection.kindOf(ReflectionKind.SomeModule) && reflection instanceof ContainerReflection) {
if (!reflection.comment || !reflection.comment.hasTag("preferred")) {
if (!reflection.children || reflection.children.length === 0) {
if (!(reflection instanceof DeclarationReflection && reflection.exportOf)) {
context.removeReflection(reflection);
return true;
}
}
}
}
return false;
}