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

Components: Normalize newlines in auto-generated READMEs #68208

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

mirka
Copy link
Member

@mirka mirka commented Dec 20, 2024

What?

Fixes a minor issue with component descriptions running into the next sections due to a missing newline.

Why?

This missing newline isn't visible when the Markdown is rendered to HTML, but is a bit messy when reading as raw Markdown text.

Testing Instructions

npm run docs:components to regenerate the README files.

@mirka mirka added [Type] Developer Documentation Documentation for developers [Package] Components /packages/components labels Dec 20, 2024
@mirka mirka self-assigned this Dec 20, 2024
Copy link

github-actions bot commented Dec 20, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mirka <[email protected]>
Co-authored-by: tyxla <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@mirka mirka requested a review from a team December 20, 2024 17:50
Copy link

github-actions bot commented Dec 20, 2024

Flaky tests detected in e5e4a65.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12436516579
📝 Reported issues:

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Just a minor question to confirm my assumptions.

@@ -8,14 +8,18 @@ import json2md from 'json2md';
*/
import { generateMarkdownPropsJson } from './props.mjs';

function normalizeTrailingNewline( str ) {
return str?.length ? str.replace( /\n*$/, '\n' ) : undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Just to be sure I understand, this aims to result in having exactly one newline, even if the description doesn't come with a newline, right? Even in the case of an empty description string, which will also result in just a newline?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question. I hope this captures the intent better: e5e4a65

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, it does 👍 Also thanks for using trim() instead of length, that basically makes it impossible to break with an arbitrary space or tab.

Copy link
Member

Choose a reason for hiding this comment

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

Feel free to ship 🚀

@mirka mirka merged commit ca24cce into trunk Dec 20, 2024
65 of 67 checks passed
@mirka mirka deleted the autogen-readme-spacing branch December 20, 2024 22:54
@github-actions github-actions bot added this to the Gutenberg 20.0 milestone Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants