5694: Format docs in to_proto::markup_content r=jonas-schievink a=JmPotato

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Close #5442 

Removing # was handled in rust_analyzer::markdown::format_docs(). However, this function is no longer called in rust_analyzer::handlers::handle_hover() since commit e8bb153 (PR #5273). This pr add this formatting function back.

Co-authored-by: JmPotato <ghzpotato@gmail.com>
This commit is contained in:
bors[bot] 2020-08-09 18:02:02 +00:00 committed by GitHub
commit 859963b9a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View file

@ -508,6 +508,37 @@ fn main() { }
);
}
#[test]
fn hover_shows_fn_doc() {
check(
r#"
/// # Example
/// ```
/// # use std::path::Path;
/// #
/// foo(Path::new("hello, world!"))
/// ```
pub fn foo<|>(_: &Path) {}
fn main() { }
"#,
expect![[r#"
*foo*
```rust
pub fn foo(_: &Path)
```
___
# Example
```
# use std::path::Path;
#
foo(Path::new("hello, world!"))
```
"#]],
);
}
#[test]
fn hover_shows_struct_field_info() {
// Hovering over the field when instantiating

View file

@ -755,7 +755,8 @@ pub(crate) fn runnable(
}
pub(crate) fn markup_content(markup: Markup) -> lsp_types::MarkupContent {
lsp_types::MarkupContent { kind: lsp_types::MarkupKind::Markdown, value: markup.into() }
let value = crate::markdown::format_docs(markup.as_str());
lsp_types::MarkupContent { kind: lsp_types::MarkupKind::Markdown, value }
}
#[cfg(test)]