aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/doc_links.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-03-17 19:57:30 +0000
committerLukas Wirth <[email protected]>2021-03-17 20:00:01 +0000
commit9763f0a6bd0d576236ff126173d7df3462c22a52 (patch)
tree6bb31b0325e8a7b9bef577901575a048344e8eb5 /crates/ide/src/doc_links.rs
parentec10835d604c534a0b0ad5fd3d8783e0bf123cbb (diff)
Semantic highlight intradoclinks in documentation
Diffstat (limited to 'crates/ide/src/doc_links.rs')
-rw-r--r--crates/ide/src/doc_links.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index 5ea9fc4fb..c7c1f4fee 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -65,6 +65,8 @@ pub(crate) fn extract_definitions_from_markdown(
65) -> Vec<(String, Option<hir::Namespace>, Range<usize>)> { 65) -> Vec<(String, Option<hir::Namespace>, Range<usize>)> {
66 let mut res = vec![]; 66 let mut res = vec![];
67 let mut cb = |link: BrokenLink| { 67 let mut cb = |link: BrokenLink| {
68 // These allocations are actually unnecessary but the lifetimes on BrokenLinkCallback are wrong
69 // this is fixed in the repo but not on the crates.io release yet
68 Some(( 70 Some((
69 /*url*/ link.reference.to_owned().into(), 71 /*url*/ link.reference.to_owned().into(),
70 /*title*/ link.reference.to_owned().into(), 72 /*title*/ link.reference.to_owned().into(),
@@ -72,13 +74,10 @@ pub(crate) fn extract_definitions_from_markdown(
72 }; 74 };
73 let doc = Parser::new_with_broken_link_callback(markdown, Options::empty(), Some(&mut cb)); 75 let doc = Parser::new_with_broken_link_callback(markdown, Options::empty(), Some(&mut cb));
74 for (event, range) in doc.into_offset_iter() { 76 for (event, range) in doc.into_offset_iter() {
75 match event { 77 if let Event::Start(Tag::Link(_, target, title)) = event {
76 Event::Start(Tag::Link(_link_type, ref target, ref title)) => { 78 let link = if target.is_empty() { title } else { target };
77 let link = if target.is_empty() { title } else { target }; 79 let (link, ns) = parse_link(&link);
78 let (link, ns) = parse_link(link); 80 res.push((link.to_string(), ns, range));
79 res.push((link.to_string(), ns, range));
80 }
81 _ => {}
82 } 81 }
83 } 82 }
84 res 83 res