Adds a new option to IParseOptions, alternateComment.#968
Adds a new option to IParseOptions, alternateComment.#968dcodeIO merged 2 commits intoprotobufjs:masterfrom
Conversation
…his activates an alternate comment parsing mode that preserves double-slash comments.
| // standard comment parsing | ||
| if (charAt(offset) === "/") { // Line | ||
| // check for triple-slash comment | ||
| isDoc = charAt(start = offset + 1) === "/"; |
There was a problem hiding this comment.
What do you think of doing something like
isDoc = (charAt(start = offset) === "/" && ++offset) || alternateCommentMode;here so it always handles /// and advances properly, and otherwise falls back to // in alternateCommentMode? Just asking because it seems that duplicating this section could potentially be avoided.
I'd say it would be fine if /// in non-alternateCommentMode also coalesces consecutive lines.
There was a problem hiding this comment.
Thanks for looking. I agree that avoiding duplication would be good, however I am hesitant to change existing behavior in case other consumers of this library depend on it.
In the spirit of your comment, I consolidated the /* handling for original and alternate parsing modes. The ////// handling is a bit too divergent to consolidate further.
|
Looking good, thank you! |
If this new flag is true, the tokenizer will change the way it parses comments from the input. Instead of requiring /// or /** / (docblock style) comments only, it will additionally accept // and / */ comments. It will consecutive lines of // comments into one multi-line comment.
The motivation here is that we want to parse comments in customer api descriptions which don't adhere to the docblock style.