Documenting own functions in typst

Question,
TL;DR Is there a nice way to document self-made functions/macros

i have at this point either through trouble with package collisions, or missing features implemented quite a few of my own functions to do basic stuff, me and my group needs for our report.

At this point i would like for them to use it, but they find it hard because unlike c or any other code they cannot just hover a function and see “good documentation”
as you see it renders poorly so my question really is just, is there a nice way to have it render on the web app?

1 Like

Documentation in hover is available when using the tinymist LSP in a local editor, like neovim or vs code.

Tinymist reads /// comments (yet to be standardized), so this works for universe packages too, at least a large fraction of them.

The web-app also creates tooltips for comments using ///, but only as plain text: (Edit: it seems like it only uses the first line of the ///-comment)


You can also describe the arguments / parameters using /// in front of each argument / parameter.

For more complex project, I recommend following the documentation syntax of tidy – Typst Universe and generating a documentation PDF. This allows using full typst syntax in the descriptions, showing examples, expected types, etc.

(EDIT:) If you make sure to have a useful short (plain-text only) description as the first line of these comments, this also combines well with the web-app tooltips.

1 Like