mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-24 21:19:37 +00:00
dev: more consistent way to get docs of decls (#752)
* dev: more consistent way to get docs of decls * test: update snapshot
This commit is contained in:
parent
8129c6741e
commit
1c1bc19caf
23 changed files with 462 additions and 451 deletions
|
|
@ -15,9 +15,8 @@ use typst::{
|
|||
|
||||
use crate::{
|
||||
analysis::{QueryStatGuard, SharedContext},
|
||||
docs::DocStringKind,
|
||||
prelude::*,
|
||||
syntax::find_module_level_docs,
|
||||
syntax::{find_module_level_docs, DefKind},
|
||||
ty::{BuiltinTy, InsTy, Interned, Ty},
|
||||
};
|
||||
|
||||
|
|
@ -82,7 +81,7 @@ pub(crate) fn expr_of(
|
|||
|
||||
let module_docstring = Arc::new(
|
||||
find_module_level_docs(&source)
|
||||
.and_then(|docs| compute_docstring(&ctx, source.id(), docs, DocStringKind::Module))
|
||||
.and_then(|docs| compute_docstring(&ctx, source.id(), docs, DefKind::Module))
|
||||
.unwrap_or_default(),
|
||||
);
|
||||
|
||||
|
|
@ -275,7 +274,7 @@ impl<'a> ExprWorker<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_docstring(&mut self, decl: &DeclExpr, kind: DocStringKind) {
|
||||
fn check_docstring(&mut self, decl: &DeclExpr, kind: DefKind) {
|
||||
if let Some(docs) = self.comment_matcher.collect() {
|
||||
let docstring = compute_docstring(&self.ctx, self.fid, docs, kind);
|
||||
if let Some(docstring) = docstring {
|
||||
|
|
@ -427,7 +426,7 @@ impl<'a> ExprWorker<'a> {
|
|||
|
||||
let span = p.span();
|
||||
let decl = Decl::pattern(span).into();
|
||||
self.check_docstring(&decl, DocStringKind::Variable);
|
||||
self.check_docstring(&decl, DefKind::Variable);
|
||||
let pattern = self.check_pattern(p);
|
||||
Expr::Let(Interned::new(LetExpr {
|
||||
span,
|
||||
|
|
@ -443,7 +442,7 @@ impl<'a> ExprWorker<'a> {
|
|||
Some(name) => Decl::func(name).into(),
|
||||
None => Decl::closure(typed.span()).into(),
|
||||
};
|
||||
self.check_docstring(&decl, DocStringKind::Function);
|
||||
self.check_docstring(&decl, DefKind::Function);
|
||||
self.resolve_as(Decl::as_def(&decl, None));
|
||||
|
||||
let (params, body) = self.with_scope(|this| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue