Skip to content

Commit

Permalink
chore: Add function description and change parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
cansuaa committed Aug 8, 2024
1 parent 6bc165e commit ab41f6a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { resolve } from 'pathe';
export function bootstrapProject(
options: Partial<TypeDocAndTSOptions>,
filteringGlob?: string,
nodeModulesInputFilePaths?: string[]
additionalInputFilePaths?: string[]
): ProjectReflection {
const app = new Application();
app.options.addReader(new TSConfigReader());
Expand All @@ -18,8 +18,8 @@ export function bootstrapProject(
throw new Error('Errors during parsing configuration');
}

if (nodeModulesInputFilePaths?.length) {
inputFiles.push(...nodeModulesInputFilePaths);
if (additionalInputFilePaths?.length) {
inputFiles.push(...additionalInputFilePaths);
}

const filteredInputFiles = filterFiles(inputFiles, filteringGlob);
Expand Down
12 changes: 9 additions & 3 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ import { ComponentDefinition } from './interfaces';
import extractComponents from './components-extractor';
import { bootstrapProject } from '../bootstrap';

/**
* @param tsconfigPath Path to tsconfig file
* @param publicFilesGlob Filter to obtain public files
* @param nodeModulesDependencyFilePaths node_modules paths of libraries to include in documentation e.g.["dir/node_modules/@cloudscape-design/components/icon/interfaces.d.ts"]
* @returns Component definitions
*/
export function documentComponents(
tsconfigPath: string,
publicFilesGlob: string,
nodeModulesInputFilePaths?: string[]
nodeModulesDependencyFilePaths?: string[]
): ComponentDefinition[] {
const includeNodeModulePaths = Boolean(nodeModulesInputFilePaths?.length);
const includeNodeModulePaths = Boolean(nodeModulesDependencyFilePaths?.length);
const project = bootstrapProject(
{
tsconfig: tsconfigPath,
includeDeclarations: includeNodeModulePaths,
excludeExternals: includeNodeModulePaths,
},
undefined,
nodeModulesInputFilePaths
nodeModulesDependencyFilePaths
);
return extractComponents(publicFilesGlob, project);
}
4 changes: 2 additions & 2 deletions test/components/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { TestUtilsDoc } from '../../src/test-utils/interfaces';

// TODO: Move this file into common location, improve naming

export function buildProject(name: string, nodeModulesInputFilePaths?: string[]): ComponentDefinition[] {
export function buildProject(name: string, nodeModulesDependencyFilePaths?: string[]): ComponentDefinition[] {
return documentComponents(
require.resolve(`../../fixtures/components/${name}/tsconfig.json`),
`fixtures/components/${name}/*/index.tsx`,
nodeModulesInputFilePaths
nodeModulesDependencyFilePaths
);
}

Expand Down
2 changes: 1 addition & 1 deletion test/components/third-party-import-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test('should resolve object type to string', () => {
]);
});

test('passing nodeModulesInputFilePaths should enable includeDeclarations and excludeExternals', () => {
test('passing nodeModulesDependencyFilePaths should enable includeDeclarations and excludeExternals', () => {
const bootstrapProjectSpy = jest.spyOn(bootstrap, 'bootstrapProject');
buildProject('third-party-import-types', [nodeModulesPath]);

Expand Down

0 comments on commit ab41f6a

Please sign in to comment.