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

Use YAML literal block syntax for description, rationale #1140

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

zcorpan
Copy link
Member

@zcorpan zcorpan commented Dec 6, 2024

This prevents some syntax issues with YAML, e.g. '#' can be used in a literal block without being treated as a line comment.

The switch from PyYAML to ruamel.yaml was needed to validate the syntax style.

This prevents some syntax issues with YAML, e.g. '#' can be used in a literal block without being treated as a line comment.

The switch from PyYAML to ruamel.yaml was needed to validate the syntax style.
Comment on lines 84 to +85
if not isinstance(item['bug'], str) or not item['bug'].startswith("https://bugzilla.mozilla.org/show_bug.cgi?id="):
self.log_error(f"'bug' must be a URL starting with 'https://bugzilla.mozilla.org/show_bug.cgi?id=', got {item['bug']}", key, line)
self.log_error(f"'bug' must be a URL starting with 'https://bugzilla.mozilla.org/show_bug.cgi?id=', got {item['bug']}.", key)
Copy link
Member

Choose a reason for hiding this comment

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

If we're requiring this, why not include just the bug number (and take the https://bugzilla... as implied?)

Not for this change, but as a followup perhaps.

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 think it's easier for contributors to paste the full URL for all of the URLs than to find out what substring should be used. Though new issues will have the URLs in the issue OP instead, so it doesn't matter so much.

if 'caniuse' in item and item['caniuse'] not in [None, '']:
if not isinstance(item['caniuse'], str) or not item['caniuse'].startswith("https://caniuse.com/"):
self.log_error(f"'caniuse' must be a URL starting with 'https://caniuse.com/' or empty, got {item['caniuse']}", key, line)
self.log_error(f"'caniuse' must be a URL starting with 'https://caniuse.com/', got {item['caniuse']}.", key)
Copy link
Member

Choose a reason for hiding this comment

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

As above.


if 'mdn' in item and item['mdn'] not in [None, '']:
if not isinstance(item['mdn'], str) or not item['mdn'].startswith("https://developer.mozilla.org/en-US/"):
self.log_error(f"'mdn' must be a URL starting with 'https://developer.mozilla.org/en-US/', got {item['mdn']}.", key)
Copy link
Member

Choose a reason for hiding this comment

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

As above

data[key][field] = LiteralScalarString(value)
else:
self.log_error(f"'{field}' must use literal block syntax (|).", key)
elif not value.endswith('\n'):
Copy link
Member

Choose a reason for hiding this comment

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

Is it even possible to have a value that doesn't have a trailing \n?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes:

foo: |-
  bar

@zcorpan zcorpan merged commit dcc602c into main Dec 9, 2024
1 check passed
@zcorpan zcorpan deleted the zcorpan/yml-literal-blocks branch December 9, 2024 21:12
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.

2 participants