Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Completion Tidy style doc comment #1015

Open
Eric-Song-Nop opened this issue Dec 17, 2024 · 3 comments
Open

Auto Completion Tidy style doc comment #1015

Eric-Song-Nop opened this issue Dec 17, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@Eric-Song-Nop
Copy link
Collaborator

Motivation

Doc comment is handy in Typst, while repeaty to repeat the parameters. We can have tinymist to generate a doc comment snippet for use when insert ///

Description

Similar to VSCode auto JSDoc.

Examples/Questions

when insert /// before a function, we can generate a snippet for doc comment:

///
  ^
  |
#let sinc(x) = if x == 0 { 1 } else { calc.sin(x) / x }

// generate:

/// {$3 Desc}
///
/// - x ({$1}): $2
/// -> {$3}
#let sinc(x) = if x == 0 { 1 } else { calc.sin(x) / x }
@Eric-Song-Nop
Copy link
Collaborator Author

(if this feature is wanted, I can do it

@Eric-Song-Nop
Copy link
Collaborator Author

For me, Tinymist is the right place for this feature. Other doc string generators might struggle to implement this feature because of lack of high quality typst, for example treesitter parser for Typst behaves poorly for identifying function definitions, thus hard to implement Neogen for Typst.

@Myriad-Dreamin
Copy link
Owner

Hey, you found a good feature. First we could split two parts to discuss with less arguments:

  • Q1: How does tinymist expose the function to users?
  • Q2: How does tinymist-query provide a function to help that?

For Q1, instead of guessing people's mind, what about using code actions? It should provide a code action to toggle comment update on head of the let binding items (e.g. #let f of #let f(x) = x). Compared with always generate docs automatically, providing a such code action would be less controversial.

For Q2, tinymist-query should provide a comment updater that not only generating docs from scratch but also updating existing docs. As a good start, it should be good enough to provide a simple generator.

@Eric-Song-Nop Eric-Song-Nop changed the title Auto Tidy style doc comment Auto Completion Tidy style doc comment Dec 17, 2024
@Eric-Song-Nop Eric-Song-Nop self-assigned this Dec 18, 2024
@Myriad-Dreamin Myriad-Dreamin added the enhancement New feature or request label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants