How can I document my own user defined functions/variables?

When I use a function from the standard library there are nice little hints in the autocompletion that tell me what the function does and what its arguments are and so on.

In other programming languages there is a syntax for documentation comments that then show up in the autocompetion or the hint when hovering. (E.g. in Fortran a normal comment is ! while a documentation comment is either !! or !>)

Is there a way to do this in typst and get documentation for user-defined functions in autocomplete?

I didn’t find any issue regarding user-defined stuff, so you probably can create one. Currently, a great solution is to use tinymist. It already supports doc strings for the most part (first introduced):

image

It also supports showing type for completion tokens (first introduced):

image

Thanks for the remark on tinymist. I will try that out. :)

Regarding the issue: I am actually not sure what kind of issue this is.

It is definitely a thing for the web app but kind of also documentation.

I think it will fall into “Compiler Feature Request”. Later, an ide tag will be added by someone. Note that the web app uses Typst compiler under the hood (it is downloaded by the browser and all compilations are done on the client). It also uses typst-ide package for IDE stuff just like tinymist. (Although I think currently tinymist has a copy of that package to be able to access some private things.)

Okay, filed an issue. Thank you :) Introducce Syntax for Documenting user (and package author) defined functions. · Issue #5094 · typst/typst · GitHub

1 Like