diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-05-19 11:04:20 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-05-19 11:04:20 +0200 |
| commit | 56a96881a54dd3784e0db22e36130eddf4e19a02 (patch) | |
| tree | 4a1a78c35663a81a77406e5b21f0b8d423e98130 /docs/src/html.rs | |
| parent | 551ea99d05166b0be50792f767ddd38b996e32fa (diff) | |
Doc links for function scopes
Diffstat (limited to 'docs/src/html.rs')
| -rw-r--r-- | docs/src/html.rs | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/docs/src/html.rs b/docs/src/html.rs index a9bbfb1c..a3db6393 100644 --- a/docs/src/html.rs +++ b/docs/src/html.rs @@ -301,11 +301,16 @@ impl<'a> Handler<'a> { route.push_str("/#methods-"); route.push_str(method); } else if root == "$func" { - let mut parts = rest.split('.'); + let mut parts = rest.split('.').peekable(); + let mut focus = &LIBRARY.global; + while let Some(m) = parts.peek().and_then(|name| module(focus, name).ok()) { + focus = m; + parts.next(); + } + let name = parts.next()?; - let param = parts.next(); - let value = - LIBRARY.global.get(name).or_else(|_| LIBRARY.math.get(name)).ok()?; + + let value = focus.get(name).ok()?; let Value::Func(func) = value else { return None }; let info = func.info()?; route.push_str(info.category); @@ -318,18 +323,25 @@ impl<'a> Handler<'a> { route.push_str(&group.name); route.push_str("/#"); route.push_str(info.name); - if let Some(param) = param { + if let Some(param) = parts.next() { 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); + if let Some(next) = parts.next() { + if info.params.iter().any(|param| param.name == next) { + route.push_str("#parameters-"); + route.push_str(next); + } else if info.scope.iter().any(|(name, _)| name == next) { + route.push('#'); + route.push_str(info.name); + route.push('-'); + route.push_str(next); + } else { + return None; + } } } } else { |
