Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (
node.kind === ReflectionKind.Global ||
node.kind === ReflectionKind.ExternalModule
) {
let children = node.children;
if (children && children.length > 0) {
children.forEach(function(child) {
findConstructs(child, files, node);
});
}
} else {
if (
(node.kind === ReflectionKind.Class ||
node.kind === ReflectionKind.Interface ||
node.kind === ReflectionKind.TypeAlias ||
node.kind === ReflectionKind.ObjectLiteral ||
node.kind === ReflectionKind.Module ||
node.kind === ReflectionKind.Variable ||
node.kind === ReflectionKind.Enum ||
node.kind === ReflectionKind.Function) &&
node.flags.isExported &&
files.find(
filePath =>
node.sources[0].fileName.split('/').pop() ===
filePath.split('/').pop(),
)
) {
if (parent && parent.kind === ReflectionKind.Module) {
// Set the node name with its parent namespace
node.name = parent ? parent.name + '.' + node.name : node.name;
}
exportedConstructs.push(node);
if (
node.kind === ReflectionKind.Global ||
node.kind === ReflectionKind.ExternalModule
) {
let children = node.children;
if (children && children.length > 0) {
children.forEach(function(child) {
findConstructs(child, files, node);
});
}
} else {
if (
(node.kind === ReflectionKind.Class ||
node.kind === ReflectionKind.Interface ||
node.kind === ReflectionKind.TypeAlias ||
node.kind === ReflectionKind.ObjectLiteral ||
node.kind === ReflectionKind.Module ||
node.kind === ReflectionKind.Variable ||
node.kind === ReflectionKind.Enum ||
node.kind === ReflectionKind.Function) &&
node.flags.isExported &&
files.find(
filePath =>
node.sources != null &&
node.sources[0].fileName.split('/').pop() ===
filePath.split('/').pop()
)
) {
if (parent && parent.kind === ReflectionKind.Module) {
// Set the node name with its parent namespace
node.name = parent ? parent.name + '.' + node.name : node.name;
}
) {
processMarkdown(node);
this.constructs.push(new TSConstruct(node));
createAnchor(node);
let title = TSHelper.getNodeTitle(node);
this.sections.push({
title: title,
anchor: node.anchorId,
depth: 3,
});
// build sections for children
let children = node.children;
if (
(node.kind === ReflectionKind.Class ||
node.kind === ReflectionKind.Interface ||
node.kind === ReflectionKind.ObjectLiteral ||
node.kind === ReflectionKind.Module ||
node.kind === ReflectionKind.Enum) &&
children &&
children.length > 0
) {
children.forEach((child: Node) => {
if (
child.inheritedFrom ||
child.flags.isPrivate ||
child.flags.isProtected
) {
child.shouldDocument = false;
} else {
// This is needed in UI, good to keep the eligibility logic at one place
child.shouldDocument = true;
processMarkdown(child);
) {
processMarkdown(node);
this.constructs.push(new TSConstruct(node));
createAnchor(node);
let title = TSHelper.getNodeTitle(node);
this.sections.push({
title: title,
anchor: node.anchorId,
depth: 3,
});
// build sections for children
let children = node.children;
if (
(node.kind === ReflectionKind.Class ||
node.kind === ReflectionKind.Interface ||
node.kind === ReflectionKind.ObjectLiteral ||
node.kind === ReflectionKind.Module ||
node.kind === ReflectionKind.Enum) &&
children &&
children.length > 0
) {
children.forEach((child: Node) => {
if (
child.inheritedFrom ||
child.flags.isPrivate ||
child.flags.isProtected
) {
child.shouldDocument = false;
} else {
// This is needed in UI, good to keep the eligibility logic at one place
child.shouldDocument = true;
processMarkdown(child);
export function ifIsLiteralType(this: DeclarationReflection, truthy: boolean, options: any) {
const isLiteralType = this.kind === ReflectionKind.ObjectLiteral || this.kind === ReflectionKind.TypeLiteral;
if (isLiteralType && truthy) {
return options.fn(this);
}
return !isLiteralType && !truthy ? options.fn(this) : options.inverse(this);
}
export function memberSymbol(this: DeclarationReflection) {
const isStatic = this.flags.map(flag => flag).includes('Static');
const symbol = '•';
if (this.kind === ReflectionKind.ConstructorSignature) {
return '\\+';
}
if (this.kind === ReflectionKind.CallSignature) {
return '▸';
}
if (this.kind === ReflectionKind.TypeAlias) {
return 'Ƭ';
}
if (this.kind === ReflectionKind.ObjectLiteral) {
return '▪';
}
if (this.kind === ReflectionKind.Property && isStatic) {
return '▪';
}
return symbol;
}
export function declarationTitle(this: DeclarationReflection, showSymbol: boolean) {
const isOptional = this.flags.map(flag => flag).includes('Optional');
const md = [];
if (this.parent && this.parent.kind !== ReflectionKind.ObjectLiteral && this.kind === ReflectionKind.ObjectLiteral) {
md.push(heading(3));
}
if (showSymbol) {
md.push(memberSymbol.call(this));
}
md.push(`**${this.name}**${isOptional ? '? ' : ''}:`);
if (this.type) {
md.push(`*${type.call(this.type)}*`);
}
if (this.defaultValue) {
md.push(`= ${this.defaultValue}`);
}
return md.join(' ');
export function ifParentIsObjectLiteral(this: DeclarationReflection, truthy: boolean, options: any) {
const parentIsObjectLiteral = this.parent && this.parent.parent && this.parent.parent.kind === ReflectionKind.ObjectLiteral;
if (parentIsObjectLiteral && truthy) {
return options.fn(this);
}
return !parentIsObjectLiteral && !truthy ? options.fn(this) : options.inverse(this);
}