Skip to content

Commit

Permalink
doc: fix multiline codeblock comments (#20996)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Mar 11, 2024
1 parent a10415f commit 565cdf2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmd/tools/vdoc/tests/testdata/multiline/main.comments.out
Expand Up @@ -44,3 +44,10 @@ fn a8()
Fixme: this should be it's own paragraph.
fn a9()
normal comment
fn foo()
foo does stuff
```
this is a multiline codeblock.
second line
third line.
```
1 change: 1 addition & 0 deletions cmd/tools/vdoc/tests/testdata/multiline/main.out
Expand Up @@ -9,3 +9,4 @@ fn a6()
fn a7()
fn a8()
fn a9()
fn foo()
8 changes: 8 additions & 0 deletions cmd/tools/vdoc/tests/testdata/multiline/main.v
Expand Up @@ -62,3 +62,11 @@ pub fn a8() {
pub fn a9() {
println('hi')
}

// foo does stuff
// ```
// this is a multiline codeblock.
// second line
// third line.
// ```
pub fn foo() {}
2 changes: 1 addition & 1 deletion vlib/v/doc/utils.v
Expand Up @@ -62,8 +62,8 @@ pub fn merge_doc_comments(comments []DocComment) string {
}
mut comment := ''
mut next_on_newline := true
mut is_codeblock := false
for cmt in doc_comments.reverse() {
mut is_codeblock := false
line_loop: for line in cmt.split_into_lines() {
l := line.trim_left('\x01').trim_space()
if is_codeblock {
Expand Down

0 comments on commit 565cdf2

Please sign in to comment.