fix: don't assert well-formed named parameters in docstring (#948)

This commit is contained in:
Myriad-Dreamin 2024-12-05 16:10:27 +08:00 committed by GitHub
parent d5c07b1ae3
commit a7f203a31c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -283,8 +283,12 @@ pub(crate) fn sig_of_type(
}
for (name, ty) in sig_ty.named_params() {
let doc = docstring.named.get(name).unwrap();
let default = doc.default.clone();
let docstring = docstring.named.get(name);
let default = Some(
docstring
.and_then(|doc| doc.default.clone())
.unwrap_or_else(|| "unknown".into()),
);
let ty = ty.clone();
if matches!(name.as_ref(), "fill" | "stroke" | "size") {
@ -293,7 +297,7 @@ pub(crate) fn sig_of_type(
param_specs.push(Interned::new(ParamTy {
name: name.clone(),
docs: Some(doc.docs.clone()),
docs: docstring.map(|doc| doc.docs.clone()),
default,
ty,
attrs: ParamAttrs::named(),