MCPcopy
hub / github.com/compodoc/compodoc / processPublicApi

Method processPublicApi

src/index-cli.ts:301–403  ·  view source on GitHub ↗

* Process public API exports from dist folder or API markdown files

(
        distPath: string,
        sourceRoot: string,
    )

Source from the content-addressed store, hash-verified

299 * Process public API exports from dist folder or API markdown files
300 */
301 private async processPublicApi(
302 distPath: string,
303 sourceRoot: string,
304 ): Promise<void> {
305 logger.info("Processing public API exports");
306
307 try {
308 // First, try to parse API markdown files from the source root
309 logger.info("Checking for *.api.md files in source root");
310 const apiMarkdownExports =
311 await parseApiMarkdownExports(sourceRoot);
312
313 if (
314 apiMarkdownExports.apiMdFiles.size > 0 &&
315 apiMarkdownExports.symbolToFiles.size > 0
316 ) {
317 logger.info(
318 `Found ${apiMarkdownExports.apiMdFiles.size} relevant *.api.md file(s) with ${apiMarkdownExports.symbolToFiles.size} symbol(s)`,
319 );
320
321 // Map symbols from API markdown files directly to source files
322 const symbolToSourceFiles = new Map<string, Set<string>>();
323
324 for (const [symbolName] of apiMarkdownExports.symbolToFiles) {
325 const sourceFiles = new Set<string>();
326
327 // Find the corresponding source file for this symbol
328 const sourceFile = this.findSourceFileForSymbol(
329 symbolName,
330 sourceRoot,
331 );
332 if (sourceFile) {
333 sourceFiles.add(sourceFile);
334 }
335
336 if (sourceFiles.size > 0) {
337 symbolToSourceFiles.set(symbolName, sourceFiles);
338 logger.debug(
339 `Public API symbol: ${symbolName} -> ${Array.from(sourceFiles).join(", ")}`,
340 );
341 }
342 }
343
344 // Store in configuration
345 Configuration.mainData.publicApiExports = symbolToSourceFiles;
346
347 logger.info(
348 `Loaded ${symbolToSourceFiles.size} public API symbol(s) from ${apiMarkdownExports.apiMdFiles.size} *.api.md file(s) (using API Markdown parser)`,
349 );
350 } else {
351 // Fall back to index.d.ts parsing
352 logger.info(
353 "No relevant *.api.md files found, falling back to index.d.ts parsing",
354 );
355
356 const publicApiExports = await parsePublicApi(distPath);
357
358 if (publicApiExports.symbolToFiles.size === 0) {

Callers 1

startMethod · 0.95

Calls 11

parseApiMarkdownExportsFunction · 0.90
parsePublicApiFunction · 0.90
createSourcePathMapperFunction · 0.90
setMethod · 0.80
mapDistToSourceMethod · 0.80
infoMethod · 0.45
addMethod · 0.45
debugMethod · 0.45
warnMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected