Repository navigation
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Caezarr
force-pushed
the
fix/doc-whitespace-blank-lines
branch
2 times, most recently
from
November 20, 2026 11:54
ac3906a to
4db076a
Compare
protoc keeps everything after `//`, so a `// ` line with a trailing space reaches the doc formatter as " ". The indented-code fencing only treated an empty line as blank, so such a line: - inside an indented code example, closed the `text` fence and opened a second one for the rest of the example, leaving a stray line between the two blocks - with four or more spaces, outside a block, opened an empty code block CommonMark, and so rustdoc, reads a line of only spaces and tabs as blank. The formatter now does the same, with the same lookahead an empty line gets: inside a block it keeps the block open when more indented code follows.
Caezarr
force-pushed
the
fix/doc-whitespace-blank-lines
branch
from
November 20, 2026 11:54
4db076a to
2541c55
Compare
Author
|
I have read the CLA Document and I hereby sign the CLA |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
doc_lines_implinbuffa-codegen/src/comments.rsnow treats a comment line made only of spaces and tabs as a blank line, the same way it already treats an empty line. A newis_blankhelper is used in the three places that checkedline.is_empty(): the blank-line branch inside an indented code block, its lookahead for more indented code, and the blank-line branch for prose.Why
protoc keeps everything after
//, so a//separator line with a trailing space reaches the formatter as" ". Only""counted as blank, so:inside an indented code example, the line closed the
textfence and opened a second one, so one example rendered as two code blocks with a stray line between them:" line1\n \n line2"produced```text,line1,```,,```text,line2,```.outside a block, a line of four or more spaces opened an empty code block:
"Foo.\n \nBar."producedFoo.,```text, an empty code line,```,Bar..CommonMark (and so rustdoc) reads a line of only spaces and tabs as a blank line: it can't start an indented code block, and it doesn't end one when more indented code follows. The formatter now agrees with that.
Tests
Two colocated unit tests in
comments.rs:test_doc_whitespace_only_line_within_indented_block_keeps_fence_open:" "," ","\t"and" "between two indented lines give one fenced block.test_doc_whitespace_only_line_does_not_open_indented_block: a line of six spaces between two prose lines comes out as an empty doc line.Both fail before the change and pass after it.
cargo test -p buffa-codegen --libpasses (852 tests).The checked-in generated code doesn't change: none of the vendored
.protofiles has a comment line with trailing whitespace.