Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs-infra] Avoid cryptic errors when tests don't exist #42356

Merged
merged 4 commits into from
May 27, 2024
Merged
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
8 changes: 5 additions & 3 deletions packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ async function annotateComponentDefinition(api: ReactApi, componentJsdoc: Annota
}

let inheritanceAPILink = null;
if (api.inheritance !== null) {
if (api.inheritance) {
inheritanceAPILink = `[${api.inheritance.name} API](${
api.inheritance.apiPathname.startsWith('http')
? api.inheritance.apiPathname
Expand Down Expand Up @@ -315,7 +315,7 @@ async function annotateComponentDefinition(api: ReactApi, componentJsdoc: Annota
api.apiPathname.startsWith('http') ? api.apiPathname : `${HOST}${api.apiPathname}`
})`,
);
if (api.inheritance !== null) {
if (api.inheritance) {
markdownLines.push(`- inherits ${inheritanceAPILink}`);
}

Expand Down Expand Up @@ -769,6 +769,7 @@ export default async function generateComponentApi(
reactApi.slots = [];
reactApi.classes = [];
reactApi.demos = componentInfo.getDemos();
reactApi.inheritance = null;
if (reactApi.demos.length === 0) {
throw new Error(
'Unable to find demos. \n' +
Expand All @@ -784,7 +785,8 @@ export default async function generateComponentApi(
reactApi.spread = testInfo.spread ?? spread;
reactApi.themeDefaultProps = testInfo.themeDefaultProps;
reactApi.inheritance = componentInfo.getInheritance(testInfo.inheritComponent);
} catch (e) {
} catch (error: any) {
console.error(error.message);
if (project.name.includes('grid')) {
// TODO: Use `describeConformance` for the DataGrid components
reactApi.forwardsRefTo = 'GridRoot';
Expand Down