Skip to content

Commit

Permalink
[core] Fix docs link check (#12135)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy committed Feb 19, 2024
1 parent 6179f3f commit 42d6bae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 32 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
16 changes: 0 additions & 16 deletions docs/.link-check-errors.txt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 15 additions & 14 deletions docs/scripts/reportBrokenLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function save(lines) {
}

const UNSUPPORTED_PATHS = ['/careers/', '/store/'];
const UNSUPPORTED_ANCHORS_PATHS = ['/api/'];

const buffer = [];

Expand All @@ -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) => {
Expand All @@ -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'),
Expand Down

0 comments on commit 42d6bae

Please sign in to comment.