Some improvements to the boxed signatures in the docs (#6593)

* Show a more reasonable name in function docs

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Fix buggy docs for union types

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Make types in the docs signatures into links

Signed-off-by: Nick Cameron <nrc@ncameron.org>

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-05-01 04:03:22 +12:00
committed by GitHub
parent ccd5b0272d
commit c050739f41
128 changed files with 821 additions and 731 deletions

View File

@ -783,6 +783,15 @@ impl BodyItem {
BodyItem::ReturnStatement(node) => (node.comment_start, node.start),
}
}
pub(crate) fn visibility(&self) -> ItemVisibility {
match self {
BodyItem::ImportStatement(node) => node.visibility,
BodyItem::VariableDeclaration(node) => node.visibility,
BodyItem::TypeDeclaration(node) => node.visibility,
BodyItem::ExpressionStatement(_) | BodyItem::ReturnStatement(_) => ItemVisibility::Default,
}
}
}
impl From<BodyItem> for SourceRange {
@ -1917,6 +1926,12 @@ pub struct TypeDeclaration {
pub digest: Option<Digest>,
}
impl TypeDeclaration {
pub(crate) fn name(&self) -> &str {
&self.name.name
}
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
#[ts(export)]
#[serde(tag = "type")]
@ -1996,6 +2011,10 @@ impl VariableDeclaration {
}
}
pub(crate) fn name(&self) -> &str {
&self.declaration.id.name
}
pub fn replace_value(&mut self, source_range: SourceRange, new_value: Expr) {
self.declaration.init.replace_value(source_range, new_value.clone());
}