Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions build-tools/tasks/docs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
const path = require('path');
const { writeComponentsDocumentation, documentTestUtils } = require('@cloudscape-design/documenter');
const { writeFile } = require('../utils/files');
const { writeComponentsDocumentation, writeTestUtilsDocumentation } = require('@cloudscape-design/documenter');
const workspace = require('../utils/workspace');

module.exports = function docs() {
Expand All @@ -15,27 +14,17 @@ module.exports = function docs() {
TagEditor: ['getTagsDiff'],
},
});
testUtilDocs();
writeTestUtilsDocumentation({
outDir: path.join(workspace.apiDocsPath, 'test-utils-doc'),
tsconfigPath: require.resolve('../../src/test-utils/tsconfig.json'),
domUtils: {
root: 'src/test-utils/dom/index.ts',
extraExports: ['default', 'ElementWrapper'],
},
selectorsUtils: {
root: 'src/test-utils/selectors/index.ts',
extraExports: ['default', 'ElementWrapper'],
},
});
return Promise.resolve();
};

function testUtilDocs() {
['dom', 'selectors'].forEach(testUtilType => {
const baseWrapperDefinitions = require(`@cloudscape-design/test-utils-core/test-utils-doc/${testUtilType}`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: in the old version we used to mix the base classes into this documentation. it should not be happening anymore

The consuming code will import them explicitly

const componentWrapperDefinitions = documentTestUtils(
{
tsconfig: require.resolve('../../src/test-utils/tsconfig.json'),
},
`**/{${testUtilType},types}/**/*`
);

const definitions = [...baseWrapperDefinitions, ...componentWrapperDefinitions];
const indexContent = `module.exports = {
classes: ${JSON.stringify(definitions)}
}
`;

const outPath = path.join(workspace.apiDocsPath, 'test-utils-doc', `${testUtilType}.js`);
writeFile(outPath, indexContent);
});
}
Loading
Loading