Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs-infra] Move API pages to TS #43199

Merged
merged 15 commits into from
Aug 13, 2024
Merged

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Aug 6, 2024

This is a follow up of #43128

In this PR I move all the component reusing API Sections to TS, which implies:

  • Typing there title component

  • TS was wonplaining about proptypes being any so I did the following to at least keep the warnings in dev mode

    - Component.propTypes = { ...definitions };
    if (process.env.NODE_ENV !== 'production') {
    -   ComponentsApiContent.propTypes = exactProp(ComponentsApiContent.propTypes);
    +   ComponentsApiContent.propTypes = exactProp({ ...definitions });
    }
  • I also moved the ComponentClassDefinition type to the @mui-internal/api-docs-builder for consistency with the other types (for pros, slots)

@mui-bot
Copy link

mui-bot commented Aug 6, 2024

Netlify deploy preview

https://deploy-preview-43199--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against a82c250

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 8, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 8, 2024
Comment on lines +77 to +78
displayClassKeys?: boolean;
styleOverridesLink?: string;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more you type pages, the more you fix inconsistencies 😅

Comment on lines +39 to +40
function Heading(props: SectionTitleProps) {
const { hash, title, level = 'h2' } = props;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed this props title to match with the SectionTitle props naming

@@ -80,7 +96,7 @@ export default function HooksApiContent(props) {
title="api-docs.parameters"
titleHash={`${hookNameKebabCase}-parameters`}
defaultLayout={defaultLayout}
layoutStorageKey={layoutStorageKey}
layoutStorageKey={layoutStorageKey.props}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS helping to spot wrong usage of component props 👮‍♂️

@alexfauquette alexfauquette marked this pull request as ready for review August 8, 2024 12:38
@alexfauquette alexfauquette requested a review from a team August 8, 2024 12:39
@zannager zannager added the scope: docs-infra Specific to the docs-infra product label Aug 8, 2024
Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Glad typing pays off

@@ -30,7 +30,7 @@ import {
getClassApiDefinitions,
getClassesToC,
} from 'docs/src/modules/components/ApiPage/definitions/classes';
import { getSlotsApiDefinitions } from './ApiPage/definitions/slots';
import { getSlotsApiDefinitions } from 'docs/src/modules/components/ApiPage/definitions/slots';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relative imports make more sense imo, but that's a little pet peeve of mine 😄

Copy link
Member Author

@alexfauquette alexfauquette Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a post traumatic symptomes.

Did not took care of it so I've little context, but most of the files on docs/modules don't have a relative import because it was causing conflict when used in mui-x repo. Since mui-x and material-ui agree on the fact the docs/ point to this folder (in mui-x the docs folder is aliased docsx), every import start with docs/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: docs-infra Specific to the docs-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants