From 42d6bae36feef90d323532aa28c6e80aeec95153 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 19 Feb 2024 18:08:33 +0200 Subject: [PATCH] [core] Fix docs link check (#12135) --- CHANGELOG.md | 2 +- docs/.link-check-errors.txt | 16 ---------- .../migration-data-grid-v6.md | 2 +- docs/scripts/reportBrokenLinks.js | 29 ++++++++++--------- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41587985378a..42b69fd9e600 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1353,7 +1353,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos - The clipboard related exports `ignoreValueFormatterDuringExport` and `splitClipboardPastedText` are no longer prefixed with `unstable_`. -- The deprecated constants `SUBMIT_FILTER_STROKE_TIME` and `SUBMIT_FILTER_DATE_STROKE_TIME` have been removed from the `DataGrid` exports. Use the [`filterDebounceMs`](https://next.mui.com/x/api/data-grid/data-grid/#DataGrid-prop-filterDebounceMs) prop to customize filter debounce time. +- The deprecated constants `SUBMIT_FILTER_STROKE_TIME` and `SUBMIT_FILTER_DATE_STROKE_TIME` have been removed from the `DataGrid` exports. Use the [`filterDebounceMs`](https://next.mui.com/x/api/data-grid/data-grid/#data-grid-prop-filterDebounceMs) prop to customize filter debounce time. - The `slots.preferencesPanel` slot and the `slotProps.preferencesPanel` prop were removed. Use `slots.panel` and `slotProps.panel` instead. diff --git a/docs/.link-check-errors.txt b/docs/.link-check-errors.txt index 87eaaff0f8d8..8096f1b7324b 100644 --- a/docs/.link-check-errors.txt +++ b/docs/.link-check-errors.txt @@ -1,18 +1,2 @@ Broken links found by `yarn docs:link-check` that exist: -- https://mui.com/base-ui/react-autocomplete/hooks-api/#use-autocomplete -- https://mui.com/base-ui/react-portal/components-api/ -- https://mui.com/material-ui/api/button/#props -- https://mui.com/material-ui/api/input-base/#InputBase-prop-disableInjectingGlobalStyles -- https://mui.com/material-ui/api/menu-item/#css -- https://mui.com/material-ui/api/popper/#props -- https://mui.com/material-ui/guides/api/#native-properties -- https://mui.com/system/styles/api/#creategenerateclassname-options-class-name-generator -- https://mui.com/system/styles/api/#serverstylesheets -- https://mui.com/system/styles/api/#stylesprovider -- https://mui.com/system/styles/api/#themeprovider -- https://mui.com/x/api/charts/gauge/#classes -- https://mui.com/x/api/data-grid/data-grid/#DataGrid-prop-filterDebounceMs -- https://mui.com/x/api/data-grid/data-grid/#props -- https://mui.com/x/api/data-grid/data-grid/#slots -- https://mui.com/x/api/date-pickers/date-picker/#slots diff --git a/docs/data/migration/migration-data-grid-v6/migration-data-grid-v6.md b/docs/data/migration/migration-data-grid-v6/migration-data-grid-v6.md index bf363d6181cb..e9077aa350d6 100644 --- a/docs/data/migration/migration-data-grid-v6/migration-data-grid-v6.md +++ b/docs/data/migration/migration-data-grid-v6/migration-data-grid-v6.md @@ -436,7 +436,7 @@ See the [Direct state access](/x/react-data-grid/state/#direct-selector-access) ``` - The deprecated constants `SUBMIT_FILTER_STROKE_TIME` and `SUBMIT_FILTER_DATE_STROKE_TIME` are no longer exported. - Use the [`filterDebounceMs`](/x/api/data-grid/data-grid/#DataGrid-prop-filterDebounceMs) prop to customize filter debounce time. + Use the [`filterDebounceMs`](/x/api/data-grid/data-grid/#data-grid-prop-filterDebounceMs) prop to customize filter debounce time. - The `GridPreferencesPanel` component is not exported anymore as it wasn't meant to be used outside of the Data Grid. diff --git a/docs/scripts/reportBrokenLinks.js b/docs/scripts/reportBrokenLinks.js index d1dffe84647b..f8051e81a8cb 100644 --- a/docs/scripts/reportBrokenLinks.js +++ b/docs/scripts/reportBrokenLinks.js @@ -11,7 +11,6 @@ function save(lines) { } const UNSUPPORTED_PATHS = ['/careers/', '/store/']; -const UNSUPPORTED_ANCHORS_PATHS = ['/api/']; const buffer = []; @@ -35,27 +34,29 @@ parseDocFolder( '', ); -function getPageUrlFromLink(link) { +function removeApiLinkHash(link) { + // Determine if the link is an API path + // e.g. /x/api/data-grid/, /material-ui/api/button/, /system/api/box/ + const isApiPath = link.match(/^\/[\w-]+\/api\//); + if (!isApiPath) { + return link; + } const [rep] = link.split('/#'); - return rep; + // if the link actually includes a hash, we need to re-add the necessary `/` at the end + return link.includes('/#') ? `${rep}/` : rep; } const usedLinks = { ...usedLinksCore, ...usedLinksX }; const availableLinks = { ...availableLinksCore, ...availableLinksX }; -const removeUnsupportedHash = (link) => { - const doNotSupportAnchors = UNSUPPORTED_ANCHORS_PATHS.some((unsupportedPath) => - link.includes(unsupportedPath), - ); - const rep = doNotSupportAnchors ? getPageUrlFromLink(link) : link; - return rep; -}; write('Broken links found by `yarn docs:link-check` that exist:\n'); Object.keys(usedLinks) .filter((link) => link.startsWith('/')) - .filter((link) => !availableLinks[removeUnsupportedHash(link)]) - // unstyled sections are added by scripts (cannot be found in markdown) - .filter((link) => !link.includes('#unstyled')) + .filter((link) => !availableLinks[removeApiLinkHash(link)]) + // these url segments are specific to Base UI and added by scripts (can not be found in markdown) + .filter((link) => + ['components-api', 'hooks-api', '#unstyled'].every((str) => !link.includes(str)), + ) .filter((link) => UNSUPPORTED_PATHS.every((unsupportedPath) => !link.includes(unsupportedPath))) .sort() .forEach((linkKey) => { @@ -66,7 +67,7 @@ Object.keys(usedLinks) console.log('available anchors on the same page:'); console.log( Object.keys(availableLinks) - .filter((link) => getPageUrlFromLink(link) === getPageUrlFromLink(linkKey)) + .filter((link) => removeApiLinkHash(link) === removeApiLinkHash(linkKey)) .sort() .map(getAnchor) .join('\n'),