Skip to content

Commit

Permalink
[docs-infra] Adapt docs infra to Base UI docs needs (#41963)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak authored Apr 19, 2024
1 parent 6577056 commit 8dfd253
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
4 changes: 3 additions & 1 deletion docs/src/modules/components/ApiPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ export default function ApiPage(props) {
`)}
language="jsx"
/>
<p dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
{pageContent.imports.length > 1 && (
<p dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
)}
{componentDescription ? (
<React.Fragment>
<br />
Expand Down
4 changes: 3 additions & 1 deletion docs/src/modules/components/ComponentsApiContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ export default function ComponentsApiContent(props) {
<Heading hash={componentNameKebabCase} text={`${componentName} API`} />
<Heading text="import" hash={`${componentNameKebabCase}-import`} level="h3" />
<HighlightedCode code={importInstructions} language="jsx" />
<p dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
{imports.length > 1 && (
<p dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
)}
<PropertiesSection
properties={componentProps}
propertiesDescriptions={propDescriptions}
Expand Down
4 changes: 3 additions & 1 deletion docs/src/modules/components/HooksApiContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export default function HooksApiContent(props) {
<Heading hash={hookNameKebabCase} text={`${hookName} API`} />
<Heading text="import" hash={`${hookNameKebabCase}-import`} level="h3" />
<HighlightedCode code={importInstructions} language="jsx" />
<p dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
{imports.length > 1 && (
<p dangerouslySetInnerHTML={{ __html: t('api-docs.importDifference') }} />
)}
{Object.keys(parameters).length > 0 ? (
<PropertiesSection
properties={parameters}
Expand Down
11 changes: 6 additions & 5 deletions docs/src/modules/sandbox/Dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CODE_VARIANTS } from 'docs/src/modules/constants';
import type { MuiProductId } from 'docs/src/modules/utils/getProductInfoFromUrl';

const packagesWithBundledTypes = ['date-fns', '@emotion/react', '@emotion/styled', 'dayjs'];
const muiNpmOrgs = ['@mui', '@base_ui', '@pigment-css'];

/**
* WARNING: Always uses `latest` typings.
Expand All @@ -15,7 +16,7 @@ function addTypeDeps(deps: Record<string, string>): void {
const packagesWithDTPackage = Object.keys(deps)
.filter((name) => packagesWithBundledTypes.indexOf(name) === -1)
// All the MUI packages come with bundled types
.filter((name) => name.indexOf('@mui/') !== 0);
.filter((name) => !muiNpmOrgs.some((org) => name.startsWith(org)));

packagesWithDTPackage.forEach((name) => {
let resolvedName = name;
Expand Down Expand Up @@ -79,7 +80,7 @@ export default function SandboxDependencies(
}

// TODO: consider if this configuration could be injected in a "cleaner" way.
if (muiDocConfig) {
if (muiDocConfig && muiDocConfig.csbIncludePeerDependencies) {
newDeps = muiDocConfig.csbIncludePeerDependencies(newDeps, {
versions,
});
Expand Down Expand Up @@ -108,7 +109,7 @@ export default function SandboxDependencies(
};

// TODO: consider if this configuration could be injected in a "cleaner" way.
if (muiDocConfig) {
if (muiDocConfig && muiDocConfig.csbGetVersions) {
versions = muiDocConfig.csbGetVersions(versions, { muiCommitRef: commitRef });
}

Expand All @@ -125,8 +126,8 @@ export default function SandboxDependencies(
deps[name] = versions[name] ?? 'latest';
}

if (muiDocConfig) {
const resolvedDep = muiDocConfig?.postProcessImport(fullName);
if (muiDocConfig && muiDocConfig.postProcessImport) {
const resolvedDep = muiDocConfig.postProcessImport(fullName);
if (resolvedDep) {
deps = { ...deps, ...resolvedDep };
}
Expand Down

0 comments on commit 8dfd253

Please sign in to comment.