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

Add comments to literal value message #2804

Merged
merged 3 commits into from
Mar 7, 2024
Merged

Conversation

gilwong00
Copy link
Contributor

Add description field to LiteralValue message

@gilwong00 gilwong00 requested a review from bufdev as a code owner March 6, 2024 21:22
@gilwong00 gilwong00 requested a review from jhump March 6, 2024 21:22
@@ -473,6 +473,7 @@ message LiteralValue {
ArrayLiteral array_value = 8;
MessageLiteral message_value = 9;
}
string description = 10;
Copy link
Member

Choose a reason for hiding this comment

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

What is this field? On face value, semantically a LiteralValue is very clear as to what it is. Unless I'm missing something, it seems unclear why it would have a description field.

Copy link
Member

Choose a reason for hiding this comment

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

I suggested calling it description for consistency with everything else in this package (see lines 303 and 341 above for example).

But it comes from comments in the source for this option value. So when an option value has a description, it can be rendered in docs as a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

description is intended to be any leading comments on the option/value. I can see why the name was confusing there. The idea was to reuse the same field name here for leading comments like we did for Message and the others. I can add some docs explaining what this is or we can rename the field to something comments to be more explicit. Wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the placement semantically. It seems we have descriptions on Enums, EnumValues, Services, Messages, Fields, but then not on Methods, and not on any of the other .*Literal.* types. Why is this Literal special (and why don't we have it on Method)?

Regardless, yes comments is a better name.

Copy link
Member

Choose a reason for hiding this comment

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

(and why don't we have it on Method)?

Maybe you overlooked it? It's there:

string description = 2;

It's not on the other literal types since those are really just the concrete kinds of LiteralValue. If it were on those others, it would be redundant with the comment on the enclosing LiteralValue.

Copy link
Member

@jhump jhump Mar 7, 2024

Choose a reason for hiding this comment

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

Semantically, it's a comment about a particular option value. For example:

// A comment about the first element.
option (some_repeated_option) = { foo: "bar" };
// A comment about the second element.
option (some_repeated_option) = { foo: "baz" };

// A comment about a field value inside a message.
option (some_message_option).name = "Bob Loblaw";

// A comment about a simple scalar option value
option (some_scalar_option) = 42;

Copy link
Member

Choose a reason for hiding this comment

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

Got it - ok, let's just rename it to comments

Copy link
Member

Choose a reason for hiding this comment

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

Another option we discussed was putting it on the FieldLiteral, so it's associated not just with a value but the value of a field/option/extension.

However, that doesn't work to capture comments on repeated options, like in the above example for the some_repeated_option custom option. If we only had it on the field (some_repeated_option), then we don't know what comment to use, since the source actually has two comments for the field, one for each element in the list value. So LiteralValue is the most usable/flexible placement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to comments

@@ -473,6 +473,7 @@ message LiteralValue {
ArrayLiteral array_value = 8;
MessageLiteral message_value = 9;
}
string comments = 10;
Copy link
Member

Choose a reason for hiding this comment

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

You renamed this comments but not everything else - update everything to be consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 got it, my bad I thought we only wanted to do it here. Fixed in latest commit.

Copy link
Member

@jhump jhump Mar 7, 2024

Choose a reason for hiding this comment

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

Uh, do we use JSON between the BSR web UI and the BSR server? If so, this is not a backwards compatible change and will break the current functionality for comments (older client code will be looking for a description property in the JSON payload).

I guess we don't have buf breaking enabled for this repo, since nothing complained about this?

Copy link
Member

Choose a reason for hiding this comment

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

Only the UI uses this, and so assumedly @gilwong00 will update the BSR anyways. We don't check for breaking changes on alpha APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, i have a PR to make these changes in the BSR so we shouldnt be affected for to long

@gilwong00 gilwong00 requested a review from bufdev March 7, 2024 17:27
@gilwong00 gilwong00 merged commit de6db03 into main Mar 7, 2024
11 checks passed
@gilwong00 gilwong00 deleted the gwong/add-comments-for-options branch March 7, 2024 19:25
@gilwong00 gilwong00 changed the title Add description to literal value message Add comments to literal value message Mar 7, 2024
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.

3 participants