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:
@ -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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user