You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Triple Slash comments produce comment offset in generated files. #762
This is similar to an issue I had reported concerning, I think, a blank line before an enum offset the comments.
It would seem that a triple slash comment on the message definition line also causes subsequent triple slash comments to offset as well.
messageLocation{/// A geo location on Earthfloatlatitude=1;/// Latitude in decimal degrees. Must be >= -90.0 and <= 90.0floatlongitude=2;/// Longitude in decimal degrees. Must be >= -180.0 and <= 180.0int32altitude_in_meters=3;/// Altitude in meters above ground}
produces the following
/** * Constructs a new Location. * @exports mpxs.model.Location * @constructor * @param {mpxs.model.Location$Properties=} [properties] Properties to set */classLocation{/** * Constructs a new Location. * @exports mpxs.model.Location * @constructor * @param {mpxs.model.Location$Properties=} [properties] Properties to set */constructor(properties?: mpxs.model.Location$Properties);/** * A geo location on Earth * @type {number} */publiclatitude: number;/** * Latitude in decimal degrees. Must be >= -90.0 and <= 90.0 * @type {number} */publiclongitude: number;/** * Longitude in decimal degrees. Must be >= -180.0 and <= 180.0 * @type {number} */publicaltitudeInMeters: number;...
<please paste the stack trace of the error if applicable>
It's probably fair to note that we will probably switch to having /** */ comments on the messages at some point anyway, but for now we have the simple /// line.
In your example, this leads to misinterpretation where comments belong, which certainly needs some improvements in detecting compatible comment types. However, your first comment (message Location { /// A geo location on Earth) still won't work even with a fix for wrong offsets.
We will change to the block comments which is what we should have used for the message anyway. I thought it might be related, but it only looked related.
Activity
ehallander9591 commentedon Apr 18, 2017
It's probably fair to note that we will probably switch to having /** */ comments on the messages at some point anyway, but for now we have the simple /// line.
Cheers
dcodeIO commentedon Apr 18, 2017
The parser looks at trailing comments only for non-block structures (anything that doesn't use
{...}blocks).You can see this here: https://github.com/dcodeIO/protobuf.js/blob/master/src/parse.js#L297
In your example, this leads to misinterpretation where comments belong, which certainly needs some improvements in detecting compatible comment types. However, your first comment (
message Location { /// A geo location on Earth) still won't work even with a fix for wrong offsets.ehallander9591 commentedon Apr 18, 2017
We will change to the block comments which is what we should have used for the message anyway. I thought it might be related, but it only looked related.
Cheers
Fixed: parser should not confuse previous trailing line comments with…
dcodeIO commentedon Apr 18, 2017
This adds a little more knowledge about trailing comments to the parser. It should accept:
plus, it prefers comments on top over trailing comments:
and, of course, it shouldn't confuse trailing comments anymore.