diff options
author | Aleksey Kladov <[email protected]> | 2020-08-26 17:56:41 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-08-26 19:24:00 +0100 |
commit | f8a59adf5e9633aa5d10efcdbf70b408d280ef01 (patch) | |
tree | d088d683f75bbd2bed837f1ca0aca61fdba5c11b /crates/ide/src/hover.rs | |
parent | 3d6c4c143b4b4c74810318eca1b5493e43535fff (diff) |
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.
Diffstat (limited to 'crates/ide/src/hover.rs')
-rw-r--r-- | crates/ide/src/hover.rs | 54 |
1 files changed, 54 insertions, 0 deletions
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 | |||
@@ -1756,6 +1756,60 @@ pub struct B<|>ar | |||
1756 | } | 1756 | } |
1757 | 1757 | ||
1758 | #[test] | 1758 | #[test] |
1759 | fn test_doc_links_enum_variant() { | ||
1760 | check( | ||
1761 | r#" | ||
1762 | enum E { | ||
1763 | /// [E] | ||
1764 | V<|> { field: i32 } | ||
1765 | } | ||
1766 | "#, | ||
1767 | expect![[r#" | ||
1768 | *V* | ||
1769 | |||
1770 | ```rust | ||
1771 | test::E | ||
1772 | ``` | ||
1773 | |||
1774 | ```rust | ||
1775 | V | ||
1776 | ``` | ||
1777 | |||
1778 | --- | ||
1779 | |||
1780 | [E](https://docs.rs/test/*/test/enum.E.html) | ||
1781 | "#]], | ||
1782 | ); | ||
1783 | } | ||
1784 | |||
1785 | #[test] | ||
1786 | fn test_doc_links_field() { | ||
1787 | check( | ||
1788 | r#" | ||
1789 | struct S { | ||
1790 | /// [`S`] | ||
1791 | field<|>: i32 | ||
1792 | } | ||
1793 | "#, | ||
1794 | expect![[r#" | ||
1795 | *field* | ||
1796 | |||
1797 | ```rust | ||
1798 | test::S | ||
1799 | ``` | ||
1800 | |||
1801 | ```rust | ||
1802 | field: i32 | ||
1803 | ``` | ||
1804 | |||
1805 | --- | ||
1806 | |||
1807 | [`S`](https://docs.rs/test/*/test/struct.S.html) | ||
1808 | "#]], | ||
1809 | ); | ||
1810 | } | ||
1811 | |||
1812 | #[test] | ||
1759 | fn test_hover_macro_generated_struct_fn_doc_comment() { | 1813 | fn test_hover_macro_generated_struct_fn_doc_comment() { |
1760 | mark::check!(hover_macro_generated_struct_fn_doc_comment); | 1814 | mark::check!(hover_macro_generated_struct_fn_doc_comment); |
1761 | 1815 | ||