Skip to content

Fix doc generation for sentence-case component names#4048

Merged
jhoffmcd merged 1 commit into2026-01from
jhoffmcd-03-06-fix-doc-generation-for-sentence-case-component-names
Mar 6, 2026
Merged

Fix doc generation for sentence-case component names#4048
jhoffmcd merged 1 commit into2026-01from
jhoffmcd-03-06-fix-doc-generation-for-sentence-case-component-names

Conversation

@jhoffmcd
Copy link

@jhoffmcd jhoffmcd commented Mar 6, 2026

Background

This pull request addresses an issue with component documentation generation where component names containing spaces were not being properly converted to valid TypeScript type names, causing type reference errors in the generated documentation.

Solution

Added a toPascalCase utility function that converts component names with spaces into proper PascalCase format for TypeScript type names. The function splits the name by spaces, capitalizes the first letter of each word, and joins them together. Additionally, updated the kebabCasedName conversion to handle spaces by replacing them with hyphens.

This approach ensures that component names like "My Component" are converted to "MyComponentElementProps" for type references while maintaining "my-component" for kebab-case usage. The alternative would have been to restrict component names to not contain spaces, but this solution maintains flexibility in naming while ensuring valid TypeScript types.

🎩

  • Component documentation now generates valid TypeScript type references for components with spaces in their names
  • Kebab-case conversion properly handles spaces by converting them to hyphens

Checklist

  • I have 🎩'd these changes
  • I have updated relevant documentation

Copy link
Author

jhoffmcd commented Mar 6, 2026

@jhoffmcd jhoffmcd marked this pull request as ready for review March 6, 2026 18:29
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset directory. If the changes are user-facing and should cause a version bump, run yarn changeset to track your changes and include them in the next release CHANGELOG. If you are making simple updates to repo configuration, examples, or documentation, you do not need to add a changeset.

extraExamples?: ReferenceEntityTemplateSchema['examples'];
}

function toPascalCase(name: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @jhoffmcd! We want the names to display in sentence case in the docs. Would this change reverse that, or am I misreading?

cc. @mcvinci

Copy link
Author

Choose a reason for hiding this comment

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

I don't think so? See the follow up doc generation for this 2026-01 https://github.com/Shopify/ui-extensions/pull/4049/changes#diff-1b861b5affa29cc420f73eb83328a52dd4af6c51c03dcf85de0c6f8c49766ec5R204371-R204372

With this change, we are just applying the Pascal Case to type, and we leave the name(title) alone.

Copy link
Author

Choose a reason for hiding this comment

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

@rennyG let me know if that works for you. I have approvals to merge this PR but don't want to if you have reservations.

Copy link
Author

Choose a reason for hiding this comment

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

Accidentally merged :man-facepalming:

Copy link
Contributor

@mcvinci mcvinci left a comment

Choose a reason for hiding this comment

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

Hey @jhoffmcd! Thanks so much for putting this fix together. I did a quick test with generating some of the other shared docs like, admin UI, and all works as expected. ❤️

Would you mind cherrypicking this change to the 2026-04-rc and 2025-10 versions / branches as well? The sentence casing applies to versions 2025-10+.

@jhoffmcd jhoffmcd merged commit 44806e5 into 2026-01 Mar 6, 2026
7 checks passed
Copy link
Author

jhoffmcd commented Mar 6, 2026

Hey @mcvinci! I looked into cherry-picking this to both branches and found:

  1. 2026-04-rc — already has this fix: https://github.com/Shopify/ui-extensions/blob/2026-04-rc/packages/ui-extensions/src/docs/shared/component-definitions.ts#L35-L40
  2. 2025-10 — uses a different doc architecture where type references are hardcoded per-component in individual .doc.ts files rather than generated from the name string, so this bug doesn't apply there. For example:
    - Shared name is sentence-case: https://github.com/Shopify/ui-extensions/blob/2025-10/packages/ui-extensions/src/docs/shared/components/ChoiceList.ts#L4
    - But the type is hardcoded as 'ChoiceListElementProps': https://github.com/Shopify/ui-extensions/blob/2025-10/packages/ui-extensions/src/surfaces/checkout/components/ChoiceList/ChoiceList.doc.ts#L16

@mcvinci
Copy link
Contributor

mcvinci commented Mar 7, 2026

Hey @mcvinci! I looked into cherry-picking this to both branches and found:

  1. 2026-04-rc — already has this fix: https://github.com/Shopify/ui-extensions/blob/2026-04-rc/packages/ui-extensions/src/docs/shared/component-definitions.ts#L35-L40
  2. 2025-10 — uses a different doc architecture where type references are hardcoded per-component in individual .doc.ts files rather than generated from the name string, so this bug doesn't apply there. For example:

Super appreciate you looking into this, @jhoffmcd! It looks like we're covered in those other impacted versions then, which is perfect! Thanks again for fixing this. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants