mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Implement syntax highlighting for doctests
This commit is contained in:
parent
d8552d114c
commit
4a2efb2f42
4 changed files with 368 additions and 46 deletions
|
@ -284,3 +284,53 @@ fn main() {
|
|||
false,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_highlight_doctest() {
|
||||
check_highlighting(
|
||||
r#"
|
||||
impl Foo {
|
||||
/// Constructs a new `Foo`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # #![allow(unused_mut)]
|
||||
/// let mut foo: Foo = Foo::new();
|
||||
/// ```
|
||||
pub const fn new() -> Foo {
|
||||
Foo { }
|
||||
}
|
||||
|
||||
/// `bar` method on `Foo`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let foo = Foo::new();
|
||||
///
|
||||
/// // calls bar on foo
|
||||
/// assert!(foo.bar());
|
||||
///
|
||||
/// /* multi-line
|
||||
/// comment */
|
||||
///
|
||||
/// let multi_line_string = "Foo
|
||||
/// bar
|
||||
/// ";
|
||||
///
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// let foobar = Foo::new().bar();
|
||||
/// ```
|
||||
pub fn foo(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
"#
|
||||
.trim(),
|
||||
"crates/ra_ide/src/snapshots/highlight_doctest.html",
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue