diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4fc52dd..be93d7e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -31,3 +31,10 @@ jobs: - name: Run build run: npm run build + + - name: Generate API docs + run: npm run docs:generate + + # We do this because we want to surface doc-building errors early + - name: Build docs + run: vitepress build docs diff --git a/scripts/generate-api-docs.ts b/scripts/generate-api-docs.ts index 67cad16..ec78d8e 100644 --- a/scripts/generate-api-docs.ts +++ b/scripts/generate-api-docs.ts @@ -134,8 +134,18 @@ const generateDocs = (entryFiles: string[], apiConfigFile: string, dry = false) if (aliasedDeclaration) { const sourceFile = aliasedDeclaration.getSourceFile(); const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile); - if (moduleSymbol) { + // If the aliased declaration lives in a module we've already visited (e.g. a + // same-file `export type { Foo }` re-export of a local declaration), recursing + // won't reach it, so add the alias symbol directly. Otherwise follow the reexport. + if (moduleSymbol && !visited.has(moduleSymbol)) { symbols.push(...getAllExportedSymbols(moduleSymbol, visited)); + } else { + // Push the aliased symbol (not the alias) so downstream sees the real + // declaration and its JSDoc rather than the empty ExportSpecifier. + const hasPublicTag = ts.getJSDocTags(aliasedDeclaration).some(tag => tag.tagName.text === 'public'); + if (hasPublicTag) { + symbols.push(aliasedSymbol); + } } } }