Skip to content

Commit

Permalink
chore: Add flag to enable includeDeclarations
Browse files Browse the repository at this point in the history
  • Loading branch information
cansuaa committed Jul 30, 2024
1 parent 72b4157 commit 2ea6ef7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/components/components-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ function findProps(allDefinitions: DeclarationReflection[], propsName: string, d
};
}

export default function extractComponents(publicFilesGlob: string, project: ProjectReflection): ComponentDefinition[] {
export default function extractComponents(
publicFilesGlob: string,
project: ProjectReflection,
hasCoreComponentTypeDependency?: boolean
): ComponentDefinition[] {
const definitions: ComponentDefinition[] = [];
const isMatch = matcher(resolve(publicFilesGlob));

Expand All @@ -96,6 +100,10 @@ export default function extractComponents(publicFilesGlob: string, project: Proj

const allDefinitions = project.children.flatMap(module => {
if (!module.children) {
if (hasCoreComponentTypeDependency) {
return [];

Check warning on line 104 in src/components/components-extractor.ts

View check run for this annotation

Codecov / codecov/patch

src/components/components-extractor.ts#L104

Added line #L104 was not covered by tests
}

throw new Error(`Module ${module.originalName} does not contain a definition.`);
}

Expand Down
13 changes: 10 additions & 3 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { ComponentDefinition } from './interfaces';
import extractComponents from './components-extractor';
import { bootstrapProject } from '../bootstrap';

export function documentComponents(tsconfigPath: string, publicFilesGlob: string): ComponentDefinition[] {
const project = bootstrapProject({ tsconfig: tsconfigPath });
return extractComponents(publicFilesGlob, project);
export function documentComponents(
tsconfigPath: string,
publicFilesGlob: string,
hasCoreComponentTypeDependency?: boolean
): ComponentDefinition[] {
const project = bootstrapProject({
tsconfig: tsconfigPath,
includeDeclarations: hasCoreComponentTypeDependency,
});
return extractComponents(publicFilesGlob, project, hasCoreComponentTypeDependency);
}

0 comments on commit 2ea6ef7

Please sign in to comment.