From f8a59adf5e9633aa5d10efcdbf70b408d280ef01 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 26 Aug 2020 18:56:41 +0200 Subject: Tease apart orthogonal concerns in markdown link rewriting `hir` should know nothing about URLs, markdown and html. It should only be able to: * resolve stringy path from documentation * generate canonical stringy path for a def In contrast, link rewriting should not care about semantics of paths and names resolution, and should be concern only with text mangling bits. --- crates/ide/src/hover.rs | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'crates/ide/src/hover.rs') diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 536411704..efec0184e 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -1755,6 +1755,60 @@ pub struct B<|>ar ); } + #[test] + fn test_doc_links_enum_variant() { + check( + r#" +enum E { + /// [E] + V<|> { field: i32 } +} +"#, + expect![[r#" + *V* + + ```rust + test::E + ``` + + ```rust + V + ``` + + --- + + [E](https://docs.rs/test/*/test/enum.E.html) + "#]], + ); + } + + #[test] + fn test_doc_links_field() { + check( + r#" +struct S { + /// [`S`] + field<|>: i32 +} +"#, + expect![[r#" + *field* + + ```rust + test::S + ``` + + ```rust + field: i32 + ``` + + --- + + [`S`](https://docs.rs/test/*/test/struct.S.html) + "#]], + ); + } + #[test] fn test_hover_macro_generated_struct_fn_doc_comment() { mark::check!(hover_macro_generated_struct_fn_doc_comment); -- cgit v1.2.3