feat: handle func.with stack during signature analysis (#699)

* fix: some cases of docs checking

* feat: check signature with binding stack

* feat: handle with stack

* dev: update snapshot

* dev: update snapshot
This commit is contained in:
Myriad-Dreamin 2024-10-17 18:57:17 +08:00 committed by GitHub
parent 39f343d536
commit e35b9f9c73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 279 additions and 111 deletions

View file

@ -68,7 +68,7 @@ pub enum SymbolDocsT<T> {
Function(Box<SignatureDocsT<T>>),
/// Documentation about a variable.
#[serde(rename = "var")]
Variable(TidyVarDocs),
Variable(TidyVarDocsT<T>),
/// Documentation about a module.
#[serde(rename = "module")]
Module(TidyModuleDocs),
@ -139,6 +139,8 @@ pub struct SignatureDocsT<T> {
pub ret_ty: T,
}
/// Documentation about a signature.
pub type UntypedSignatureDocs = SignatureDocsT<()>;
/// Documentation about a signature.
pub type SignatureDocs = SignatureDocsT<TypeRepr>;

View file

@ -18,10 +18,15 @@ pub struct TidyFuncDocs {
pub params: Vec<TidyParamDocs>,
}
/// Documentation about a variable (without type information).
pub type UntypedVarDocs = TidyVarDocsT<()>;
/// Documentation about a variable.
pub type TidyVarDocs = TidyVarDocsT<Option<(String, String)>>;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TidyVarDocs {
pub struct TidyVarDocsT<T> {
pub docs: EcoString,
pub return_ty: Option<String>,
pub return_ty: T,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -164,7 +169,8 @@ pub fn identify_var_docs(converted: EcoString) -> StrResult<TidyVarDocs> {
break;
};
return_ty = Some(w.trim().to_string());
// todo: convert me
return_ty = Some((w.trim().into(), String::new()));
break_line = Some(i);
break;
}
@ -233,7 +239,7 @@ mod tests {
let f = super::identify_var_docs(s.into()).unwrap();
let mut res = format!(">> docs:\n{}\n<< docs", f.docs);
if let Some(t) = f.return_ty {
res.push_str(&format!("\n>>return\n{t}\n<<return"));
res.push_str(&format!("\n>>return\n{}\n<<return", t.0));
}
res
}