From 618beb1ac1cd04b203654d5a019c0ed04e4c26cb Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 14 Feb 2023 14:39:19 +0100 Subject: Fix links --- docs/src/html.rs | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'docs/src/html.rs') diff --git a/docs/src/html.rs b/docs/src/html.rs index 9fbb4fd8..ac48952d 100644 --- a/docs/src/html.rs +++ b/docs/src/html.rs @@ -125,15 +125,10 @@ impl<'a> Handler<'a> { "unsupported link type: {ty:?}", ); - let mut link = self + *dest = self .handle_link(dest) - .unwrap_or_else(|| panic!("invalid link: {dest}")); - - if !link.contains('#') && !link.ends_with('/') { - link.push('/'); - } - - *dest = link.into(); + .unwrap_or_else(|| panic!("invalid link: {dest}")) + .into(); } // Inline raw. @@ -226,16 +221,36 @@ impl<'a> Handler<'a> { let info = func.info()?; route.push_str(info.category); route.push('/'); - route.push_str(name); - route.push('/'); - if let Some(param) = param { - route.push_str("#parameters--"); - route.push_str(param); + + if let Some(group) = GROUPS + .iter() + .find(|group| group.functions.iter().any(|func| func == info.name)) + { + route.push_str(&group.name); + route.push_str("/#"); + route.push_str(info.name); + if let Some(param) = param { + route.push_str("-parameters--"); + route.push_str(param); + } else { + route.push_str("-summary"); + } + } else { + route.push_str(name); + route.push('/'); + if let Some(param) = param { + route.push_str("#parameters--"); + route.push_str(param); + } } } else { route.push_str(rest); } + if !route.contains('#') && !route.ends_with('/') { + route.push('/'); + } + Some(route) } } -- cgit v1.2.3