MCPcopy
hub / github.com/compodoc/compodoc / findSourceFile

Method findSourceFile

src/utils/source-path-mapper.util.ts:47–65  ·  view source on GitHub ↗

* Find the source file corresponding to a dist declaration file

(distFilePath: string)

Source from the content-addressed store, hash-verified

45 * Find the source file corresponding to a dist declaration file
46 */
47 private findSourceFile(distFilePath: string): string | null {
48 // Get the relative path from dist root
49 const relativePath = path.relative(this.distPath, distFilePath);
50
51 // Remove .d.ts extension, leaving .ts
52 const withoutDTs = relativePath.replace(/\.d\.ts$/, '.ts');
53
54 // Try common patterns
55 const patterns = this.generateSourcePatterns(withoutDTs);
56
57 for (const pattern of patterns) {
58 const fullPath = path.join(this.sourceRoot, pattern);
59 if (fs.existsSync(fullPath)) {
60 return fullPath;
61 }
62 }
63
64 return null;
65 }
66
67 /**
68 * Generate possible source file path patterns

Callers 1

mapDistToSourceMethod · 0.95

Calls 3

replaceMethod · 0.45
existsSyncMethod · 0.45

Tested by

no test coverage detected