diff --git a/starlark/src/docs/markdown.rs b/starlark/src/docs/markdown.rs index 4e4df0572..ee02430c9 100644 --- a/starlark/src/docs/markdown.rs +++ b/starlark/src/docs/markdown.rs @@ -26,6 +26,7 @@ use crate::docs::DocMember; use crate::docs::DocParam; use crate::docs::DocProperty; use crate::docs::DocString; +use crate::docs::DocType; use crate::typing::Ty; /// What to render from a [`DocString`]. @@ -174,6 +175,15 @@ pub(super) fn render_members<'a>( format!("# {name}{summary}\n\n{members_details}") } +pub(super) fn render_doc_type(name: &str, prefix: &str, t: &DocType) -> String { + render_members( + &name, + &t.docs, + &prefix, + t.members.iter().map(|(n, m)| (&**n, m.clone())), + ) +} + /// Used by LSP. pub fn render_doc_item(name: &str, item: &DocItem) -> String { match item { @@ -187,12 +197,7 @@ pub fn render_doc_item(name: &str, item: &DocItem) -> String { .map(|m| (&**n, m)) }), ), - DocItem::Type(o) => render_members( - &format!("`{name}` type"), - &o.docs, - &format!("{name}."), - o.members.iter().map(|(n, m)| (&**n, m.clone())), - ), + DocItem::Type(o) => render_doc_type(&format!("`{name}` type"), &format!("{name}."), o), DocItem::Member(DocMember::Function(f)) => render_function(name, f), DocItem::Member(DocMember::Property(p)) => render_property(name, p), } diff --git a/starlark/src/docs/multipage.rs b/starlark/src/docs/multipage.rs index 8a9eccacb..2f020c4e1 100644 --- a/starlark/src/docs/multipage.rs +++ b/starlark/src/docs/multipage.rs @@ -17,6 +17,7 @@ use std::collections::HashMap; +use crate::docs::markdown::render_doc_type; use crate::docs::markdown::render_members; use crate::docs::DocItem; use crate::docs::DocModule; @@ -49,12 +50,7 @@ fn render_markdown_multipage_inner( result.extend(render_markdown_multipage_inner(m, &name, &path)); } DocItem::Type(t) => { - let rendered = render_members( - &name, - &t.docs, - &format!("{name}."), - t.members.iter().map(|(n, m)| (&**n, m.clone())), - ); + let rendered = render_doc_type(&name, &format!("{name}."), &t); result.insert(path, rendered); } DocItem::Member(m) => {