Skip to content

Commit

Permalink
derive: reword in_doc error message if code block is absent
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski committed Nov 21, 2024
1 parent 8369243 commit b291e1a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion rinja_derive/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ fn no_rinja_code_block(span: Span, ast: &syn::DeriveInput) -> CompileError {
};
CompileError::no_file_info(
format!(
"when using `in_doc = true`, the {kind}'s documentation needs a `rinja` code block"
"when using `in_doc` with the value `true`, the {kind}'s documentation needs a \
`rinja` code block"
),
Some(span),
)
Expand Down
3 changes: 2 additions & 1 deletion rinja_derive/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,8 @@ fn test_code_in_comment() {
let err = build_template(&ast).unwrap_err();
assert_eq!(
err.to_string(),
"when using `in_doc = true`, the struct's documentation needs a `rinja` code block"
"when using `in_doc` with the value `true`, the struct's documentation needs a `rinja` \
code block"
);

let ts = "
Expand Down
4 changes: 2 additions & 2 deletions testing/tests/ui/rinja-block.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ error: unknown node `fail`
5 | /// Some documentation
| ^^^^^^^^^^^^^^^^^^^^^^

error: when using `in_doc = true`, the struct's documentation needs a `rinja` code block
error: when using `in_doc` with the value `true`, the struct's documentation needs a `rinja` code block
--> tests/ui/rinja-block.rs:15:34
|
15 | #[template(ext = "txt", in_doc = true)]
Expand Down Expand Up @@ -36,7 +36,7 @@ error: template attribute `in_doc` expects a boolean value
51 | #[template(ext = "txt", in_doc = "yes")]
| ^^^^^

error: when using `in_doc = true`, the enum's documentation needs a `rinja` code block
error: when using `in_doc` with the value `true`, the enum's documentation needs a `rinja` code block
--> tests/ui/rinja-block.rs:60:34
|
60 | #[template(ext = "txt", in_doc = true)]
Expand Down

0 comments on commit b291e1a

Please sign in to comment.