MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / generateDocumentation

Function generateDocumentation

src/telemetryGenerator.node.ts:432–608  ·  view source on GitHub ↗
(fileNames: string[])

Source from the content-addressed store, hash-verified

430}
431
432function generateDocumentation(fileNames: string[]): void {
433 const configFile = getTsCompilerOptionsJson();
434 const host = new TypeScriptLanguageServiceHost(fileNames, configFile.options);
435 const languageService = ts.createLanguageService(host, undefined, ts.LanguageServiceMode.Semantic);
436 const program = languageService.getProgram()!;
437 const typeChecker = program!.getTypeChecker();
438 const entries = new Map<string, TelemetryEntry>();
439
440 // First generate documentation for common properties and measures.
441 generateDocumentationForCommonTypes(fileNames);
442
443 // Visit every sourceFile in the program
444 if (program) {
445 for (const sourceFile of program.getSourceFiles()) {
446 if (!sourceFile.isDeclarationFile) {
447 // Walk the tree to search for classes
448 ts.forEachChild(sourceFile, visit.bind(undefined, sourceFile));
449 }
450 }
451 }
452 /** visit nodes finding exported classes */
453 function visit(sourceFile: ts.SourceFile, node: ts.Node) {
454 // Only consider exported nodes
455 if (!isNodeExported(node)) {
456 return;
457 }
458 if (ts.isModuleDeclaration(node)) {
459 // This is a namespace, visit its children
460 ts.forEachChild(node, visit.bind(undefined, sourceFile));
461 return;
462 }
463
464 if (!ts.isClassDeclaration(node) || node.name?.text !== 'IEventNamePropertyMapping') {
465 return;
466 }
467
468 try {
469 node.members.forEach((m) => {
470 if (ts.isPropertyDeclaration(m)) {
471 const typeNode = m.type;
472 if (!typeNode || typeNode.kind !== ts.SyntaxKind.TypeReference) {
473 console.error(`Unrecognized type ${m.name.getText()}`);
474 } else if (
475 typeNode &&
476 ts.isTypeReferenceNode(typeNode) &&
477 typeNode.typeArguments?.length === 1 &&
478 typeNode.typeName.getText() === 'TelemetryEventInfo'
479 ) {
480 let name = m.name.getText().trim();
481 let constantName = m.name.getText().trim().replace('[', '').replace(']', '');
482
483 if (m.name.kind === ts.SyntaxKind.ComputedPropertyName) {
484 const defs = languageService.getDefinitionAtPosition(
485 m.getSourceFile().fileName,
486 m.name.end - 1
487 );
488 if (defs && defs.length) {
489 const refSourceFile = program!.getSourceFile(defs[0].fileName);

Callers 1

generateTelemetryOutputFunction · 0.85

Calls 10

getTsCompilerOptionsJsonFunction · 0.85
generateTelemetryCSVFunction · 0.85
generateTelemetryGdprFunction · 0.85
sortMethod · 0.65
errorMethod · 0.65
fromMethod · 0.45
valuesMethod · 0.45
keysMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected