-
Notifications
You must be signed in to change notification settings - Fork 4
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
New documentation format #32
Comments
imo we shouldn't remove old doc comment parser to ensure compatibility. The suitable timing to remove them might be the day when we have type annotations. |
besides, it looks like the new syntax isn't friendly to documenting a function or let bindiing destructing the parameters in place. e.g. #let f(((((x,),y),z),w),s) = x+y+z+w+s; we'll have a bad reformatted result on above function if we use the new syntax. |
Both parsers will live side-by-side for a while. You can specify which one you want to use. |
True, but nor could the older parser handle destructured parameters. Not quite sure if one should even have something like that in a public API function. Do you have a use-case in mind that couldn't be written in anther way? I'd vote to just write a single parameter in your proposed case, say that it takes an |
This issue tracks the progress on a major update to the documentation syntax.
Many of these decisions were discussed here typst-community/guidelines#8 and on Discord.
Overview
@@
syntax with normal@
references.This will also bring the documentation style very close to the current Typst documentation (although that is still written in Rust, as of now). Also, on a sidenote, the Typst documentation does not quite use Typst markup at the moment, but rather markdown (e.g., section headings are written as
#
, not=
and cross-references use markdown link syntax).In my personal opinion, it is a nice and suitable philosophy to write Typst documentation in valid Typst. The new update targets this philosophy.
Descriptions
In comparison to before, the parameters descriptions are now stripped off the main function description and placed right before each parameter.
For more information, see #33 .
As long as we don't have type annotations ...
Before Typst features built-in type annotations, a temporary syntax is introduced. The description of a definition or parameter can end with a type annotation starting with
->
followed by a list of possible types separated by the pipe|
operator.I anticipate that moving documentation towards built-in type annotations will then be easy - maybe automatable - for sorce code written in this style.
References
Due to internal reasons, in the early days of Tidy, the decision was made to introduce a custom syntax for cross-references using a double
@@
symbol.@tingerrr has pointed out, that it would also be possible to just use Typst referencing syntax, i.e., a single
@
. This could internally be realized via a show rule that displays alink
to the respective entry.Proposal:
@my-other-definition
.@my-func.x
.Both should result in valid Typst markup in all cases.
For more information, see #34 .
Code examples
Every good documentation needs some examples. Typst-package-authors like them to be displayed automatically along with the rendered output. For this, Tidy provides the
example
function which is available in all doc-comments. Inspired by the Typst documentation, it's rather straight-forward to allow for using regular raw syntax in combination with a special "language". This can be simply implemented with a show rule.For more information, see #35 .
The text was updated successfully, but these errors were encountered: