Implement syntax highlighting for doctests

This commit is contained in:
Leander Tentrup 2020-04-28 11:01:51 +02:00
parent d8552d114c
commit 4a2efb2f42
4 changed files with 368 additions and 46 deletions

View file

@ -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,
)
}