mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-23 12:46:43 +00:00
feat: cache docstring building (Part. 2) (#680)
* feat: cache docstring building (Part. 2) * dev: fix import * dev: change some variable names
This commit is contained in:
parent
3ed401740e
commit
4aeb3747bc
7 changed files with 398 additions and 259 deletions
|
|
@ -23,12 +23,12 @@ use typst::syntax::package::{PackageManifest, PackageSpec};
|
|||
use typst::syntax::{FileId, Span, VirtualPath};
|
||||
use typst::World;
|
||||
|
||||
pub(crate) use self::tidy::*;
|
||||
use crate::analysis::analyze_dyn_signature;
|
||||
use crate::syntax::{find_docs_of, get_non_strict_def_target, IdentRef};
|
||||
use crate::ty::Ty;
|
||||
use crate::upstream::truncated_doc_repr;
|
||||
use crate::AnalysisContext;
|
||||
pub(crate) use tidy::*;
|
||||
|
||||
/// Information about a package.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
|
@ -54,6 +54,13 @@ impl From<(PathBuf, PackageSpec)> for PackageInfo {
|
|||
}
|
||||
}
|
||||
|
||||
/// Kind of a docstring.
|
||||
#[derive(Debug, Clone, Hash, Serialize, Deserialize)]
|
||||
pub enum DocStringKind {
|
||||
/// A docstring for a function.
|
||||
Function,
|
||||
}
|
||||
|
||||
/// Docs about a symbol.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(tag = "kind")]
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
use ecow::EcoString;
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typst::diag::StrResult;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct TidyParamDocs {
|
||||
pub name: String,
|
||||
pub docs: String,
|
||||
pub types: String,
|
||||
pub default: Option<String>,
|
||||
pub name: EcoString,
|
||||
pub docs: EcoString,
|
||||
pub types: EcoString,
|
||||
pub default: Option<EcoString>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct TidyFuncDocs {
|
||||
pub docs: String,
|
||||
pub return_ty: Option<String>,
|
||||
pub return_ty: Option<EcoString>,
|
||||
pub params: Vec<TidyParamDocs>,
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +58,7 @@ pub fn identify_func_docs(converted: &str) -> StrResult<TidyFuncDocs> {
|
|||
continue;
|
||||
};
|
||||
|
||||
return_ty = Some(w.trim().to_string());
|
||||
return_ty = Some(w.trim().into());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +121,7 @@ pub fn identify_func_docs(converted: &str) -> StrResult<TidyFuncDocs> {
|
|||
name: param_line.0,
|
||||
types: param_line.1,
|
||||
default: None,
|
||||
docs: buf.into_iter().join("\n"),
|
||||
docs: buf.into_iter().join("\n").into(),
|
||||
});
|
||||
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue