From 1e461d80ddb073a2bf77cb693c00582a59422b1a Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 19 Feb 2024 16:32:12 +0200 Subject: [PATCH 1/5] Avoid misreporting not generated API links --- docs/.link-check-errors.txt | 5 ----- docs/scripts/reportBrokenLinks.js | 19 +++++++++---------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/docs/.link-check-errors.txt b/docs/.link-check-errors.txt index 87eaaff0f8d8b..8f6134afc7cbe 100644 --- a/docs/.link-check-errors.txt +++ b/docs/.link-check-errors.txt @@ -6,11 +6,6 @@ Broken links found by `yarn docs:link-check` that exist: - 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 diff --git a/docs/scripts/reportBrokenLinks.js b/docs/scripts/reportBrokenLinks.js index d1dffe84647b6..667b894718b67 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 = []; @@ -36,24 +35,24 @@ parseDocFolder( ); function getPageUrlFromLink(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)]) + .filter((link) => !availableLinks[getPageUrlFromLink(link)]) // unstyled sections are added by scripts (cannot be found in markdown) .filter((link) => !link.includes('#unstyled')) .filter((link) => UNSUPPORTED_PATHS.every((unsupportedPath) => !link.includes(unsupportedPath))) From a1e8c1d40ea1ebf6cc53b0ea2bd7f23afc47d536 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 19 Feb 2024 16:51:36 +0200 Subject: [PATCH 2/5] Update broken links --- CHANGELOG.md | 2 +- .../migration/migration-data-grid-v6/migration-data-grid-v6.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41587985378a8..42b69fd9e600d 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/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 bf363d6181cbd..e9077aa350d61 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. From 59c4e900925201d19b67a8852b72df6b80d46849 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 19 Feb 2024 16:52:08 +0200 Subject: [PATCH 3/5] Run `docs:link-check` --- docs/.link-check-errors.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docs/.link-check-errors.txt b/docs/.link-check-errors.txt index 8f6134afc7cbe..f185b183d0ae0 100644 --- a/docs/.link-check-errors.txt +++ b/docs/.link-check-errors.txt @@ -2,12 +2,3 @@ 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/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 From 5c9b416f921ed5066ee458f61441181edb2d6d22 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 19 Feb 2024 17:02:47 +0200 Subject: [PATCH 4/5] Exclude `components-api` and `hooks-api` as well as they are generated links --- docs/.link-check-errors.txt | 2 -- docs/scripts/reportBrokenLinks.js | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/.link-check-errors.txt b/docs/.link-check-errors.txt index f185b183d0ae0..8096f1b7324bf 100644 --- a/docs/.link-check-errors.txt +++ b/docs/.link-check-errors.txt @@ -1,4 +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/ diff --git a/docs/scripts/reportBrokenLinks.js b/docs/scripts/reportBrokenLinks.js index 667b894718b67..82e0fa9990b7a 100644 --- a/docs/scripts/reportBrokenLinks.js +++ b/docs/scripts/reportBrokenLinks.js @@ -53,8 +53,10 @@ write('Broken links found by `yarn docs:link-check` that exist:\n'); Object.keys(usedLinks) .filter((link) => link.startsWith('/')) .filter((link) => !availableLinks[getPageUrlFromLink(link)]) - // unstyled sections are added by scripts (cannot be found in markdown) - .filter((link) => !link.includes('#unstyled')) + // 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) => { From 7df0ab8efdaa9609b01aeb0f44789595c395a858 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 19 Feb 2024 17:49:46 +0200 Subject: [PATCH 5/5] Code review: Alex --- docs/scripts/reportBrokenLinks.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/scripts/reportBrokenLinks.js b/docs/scripts/reportBrokenLinks.js index 82e0fa9990b7a..f8051e81a8cb0 100644 --- a/docs/scripts/reportBrokenLinks.js +++ b/docs/scripts/reportBrokenLinks.js @@ -34,7 +34,7 @@ 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\//); @@ -52,7 +52,7 @@ const availableLinks = { ...availableLinksCore, ...availableLinksX }; write('Broken links found by `yarn docs:link-check` that exist:\n'); Object.keys(usedLinks) .filter((link) => link.startsWith('/')) - .filter((link) => !availableLinks[getPageUrlFromLink(link)]) + .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)), @@ -67,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'),