Skip to content

Commit

Permalink
fix: Exclude empty modules from documentation
Browse files Browse the repository at this point in the history
Closes #1607
  • Loading branch information
Gerrit0 committed Jun 25, 2021
1 parent da27756 commit 8a5a933
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/lib/application.ts
Expand Up @@ -332,10 +332,12 @@ export class Application extends ChildableComponent<
entryPoints.push(...this.getEntryPointsForPaths(this.entryPoints));
}

const programs = entryPoints.map((e) => e.program);
this.logger.verbose(`Converting with ${programs.length} programs`);
const programs = new Set(entryPoints.map((e) => e.program));
this.logger.verbose(
`Converting with ${programs.size} programs and ${entryPoints.length} entry points`
);

const errors = flatMap(programs, ts.getPreEmitDiagnostics);
const errors = flatMap([...programs], ts.getPreEmitDiagnostics);
if (errors.length) {
this.logger.diagnostics(errors);
return;
Expand Down
20 changes: 16 additions & 4 deletions src/lib/converter/converter.ts
@@ -1,6 +1,5 @@
import * as ts from "typescript";
import * as _ from "lodash";
import * as assert from "assert";

import { Application } from "../application";
import { Type, ProjectReflection, ReflectionKind } from "../models/index";
Expand Down Expand Up @@ -283,8 +282,10 @@ export class Converter extends ChildableComponent<
});
for (const { entryPoint, context } of entries) {
// active program is already set on context
assert(context);
this.convertReExports(context, entryPoint.sourceFile);
// if we don't have a context, then this entry point is being ignored
if (context) {
this.convertReExports(context, entryPoint.sourceFile);
}
}
context.setActiveProgram(undefined);
}
Expand All @@ -298,6 +299,17 @@ export class Converter extends ChildableComponent<
const symbol = getSymbolForModuleLike(context, node);
let moduleContext: Context;

const allExports = getExports(context, node, symbol);

if (
allExports.every((exp) => this.shouldIgnore(exp, context.checker))
) {
this.owner.logger.verbose(
`Ignoring entry point ${entryName} since all members will be ignored.`
);
return;
}

if (singleEntryPoint) {
// Special case for when we're giving a single entry point, we don't need to
// create modules for each entry. Register the project as this module.
Expand All @@ -324,7 +336,7 @@ export class Converter extends ChildableComponent<
moduleContext = context.withScope(reflection);
}

for (const exp of getExports(context, node, symbol).filter((exp) =>
for (const exp of allExports.filter((exp) =>
isDirectExport(context.resolveAliasedSymbol(exp), node)
)) {
convertSymbol(moduleContext, exp);
Expand Down

0 comments on commit 8a5a933

Please sign in to comment.