Skip to content

Commit 5666297

Browse files
committed
fix: treat a snippet marker inside a QDoc comment as markup
Signed-off-by: Joseph Kato <joseph@jdkato.io>
1 parent c2d1a55 commit 5666297

4 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎internal/lint/qdoc.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,13 @@ func (c *qdocConv) line(raw string) { //nolint:gocyclo // one case per command f
425425
return
426426
}
427427

428+
// A `//` line inside a comment is a snippet marker -- `//! [intro]` --
429+
// or code, never prose. QDoc renders nothing for it, so it does not end
430+
// the paragraph it sits in the middle of either.
431+
if strings.HasPrefix(trimmed, "//") {
432+
return
433+
}
434+
428435
if trimmed == "" {
429436
c.closeDiv()
430437
c.flush()

‎internal/lint/qdoc_test.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ func TestQdocHTML(t *testing.T) {
110110
`<data class="anchor">Another Anchor</data>`, "<p>Prose here.</p>"},
111111
[]string{"\\target", "\\keyword"},
112112
},
113+
{
114+
"a snippet marker is markup, and does not break its paragraph",
115+
"/*!\n Prose one.\n//! [intro]\n Prose two.\n*/\n",
116+
[]string{"Prose one.", "Prose two."},
117+
[]string{"intro", "//!"},
118+
},
113119
{
114120
"sa lines are markup",
115121
"Prose here.\n\n\\sa QWidget, QObject\n",

‎testdata/e2e/lint.yaml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ cases:
351351
briefs, notes, items, cells, and captions are prose. A command may
352352
share the opening `/*!` line; a conditional block's prose, a
353353
deprecation's advice, and a summary still count; and modifiers, cell
354-
spans, and version qualifiers say nothing"
354+
spans, version qualifiers, and snippet markers say nothing"
355355
args: test.qdoc
356356
exit: 0
357357
want: |
@@ -378,6 +378,8 @@ cases:
378378
test.qdoc:105:53:vale.Annotations:'TODO' left in text
379379
test.qdoc:108:35:vale.Annotations:'XXX' left in text
380380
test.qdoc:108:70:vale.Annotations:'TODO' left in text
381+
test.qdoc:113:45:vale.Annotations:'TODO' left in text
382+
test.qdoc:116:51:vale.Annotations:'XXX' left in text
381383
absent:
382384
- FIXME
383385
- NOTE

‎testdata/fixtures/formats/test.qdoc‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,11 @@
107107

108108
Use \bold {bold prose with an XXX in it} and \i {emphasis with a TODO}.
109109
*/
110+
111+
/*!
112+
//! [intro]
113+
A snippet marker holds no prose, and no TODO of its own.
114+
//! [intro]
115+
116+
\image screenshot-FIXME.png A caption with an XXX in it.
117+
*/

0 commit comments

Comments
 (0)