Skip to content

Commit

Permalink
[docs-infra] Avoid cryptic errors when tests don't exist (#42356)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot committed May 27, 2024
1 parent 10bb5fb commit e7604d2
Showing 1 changed file with 5 additions and 3 deletions.
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 @@ -286,7 +286,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 @@ -317,7 +317,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 @@ -777,6 +777,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 @@ -792,7 +793,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

0 comments on commit e7604d2

Please sign in to comment.