Repository navigation
Document associated constants - #8743
Conversation
laurmaedje
left a comment
There was a problem hiding this comment.
Nice work! This is exciting. :)
Aside from my typical nits, one thing: I feel like it may be a bit hard to distinguish at a glance what is a constant and what is a function.
One solution would be to split up into "Constants" and "Functions" or "Methods", but there are also elements and it would become a bit of a mess with the URL anchors (they should remain stable ideally). Though the group pages do just this (probably for consistency with the existing "Functions" heading?).
Alternatively, we could try to distinguish it visually within the Definitions section (I think I prefer this route).
The question is how. I could potentially see extra parens after the name of a function. E.g. something like is-infinite() and slice(..) be used there (the dots would depend on whether there is at least one argument). But we could also try to do it just visually. I'm open to suggestions.
Also, this looks wrong in PDF:
db8ba07 to
e67ea9a
Compare
I think the main reason why I implemented a separate section for constants for group pages but not for function pages was because function pages would need to have many other sections as you noted: for constants, methods, associated functions, associated elements, etc..
I would personally prefer going the other route, with separate sections for constants, methods, etc.. This would make the documentation more organized and also make it clearer to the user that, e.g., associated functions and methods are different things (currently, the only way to distinguish them is by seeing whether they use the Fixed. |
But they are not. It's rather the opposite; they are exactly the same. Method call syntax is purely call site sugar. Overall, I don't have a problem with separation sections per se, but I would like to avoid changing the HTML ids and breaking links ("Cool URIs don't change"). Also, which concrete sections would you add? |
That's interesting... I had never realized how far this went. For example,
I believe this can be implemented without affecting the existing ids.
In order, I would replace the "Definitions" section with the following sections (keeping only those that are non-empty):
I think that should cover everything. Optionally, associated elements could be in a section separate from associated functions, but this may be excessive. |
|
I am as of yet undecided which approach I prefer. I will ask the other team members for their opinion and get back to you. |
|
I discussed this with @reknih. We agreed on having separate sections, but would like to drop the "Associated" prefix. It feels a bit unncessarily technical. So just "Constants", "Functions", and "Types". That's also consistent with the current group pages. And the HTML IDs should ideally remain stable. |
0eef8d3 to
a638105
Compare
|
I implemented the sections for associated definitions. The IDs should remain stable compared to the live version currently at typst.app/docs. The only exception is bare |
|
I am working on fixing the conflicts, sorry for the delay |
|
Oh no, I already started work on that, too. I thought it would be easy at first, so I thought I'll just do it, but it's not. But I'm pretty much done with it now. |
|
I'm stuck with a gazillion introspection errors that are likely caused by two mistakenly swapped arguments somewhere in |
a638105 to
22de77f
Compare
|
I pushed my rebase. I also made some additional changes to be able to keep the Since the rebase was quite hairy, I would appreciate if you could double-check whether the final diff matches what you would expect (especially in |
The changes to |
22de77f to
f83ff40
Compare
|
Thank you! A very nice addition to the docs. :) |
…ember` This commit migrate to the changes in 83ff40ad (`9f2b6e871^`) _Display constants in the documentation_ in typst/typst#8743. See also my previous commit.

Closes #8355.
This PR adds infrastructure to support documentation for associated constants in the documentation, and adds documentation for almost all associated constants.
AFAIK, the only constants that still aren't documented are
math.difandmath.Difbecause I could not find a right place to put them. Note thatmath.difis currently only documented on the General Symbols list, andmath.Difnot documented at all. I also excluded individual color definitions from thecolortype, because they are better documented together in the "Predefined colors" section. On the other hand, the "Predefined color maps" section has been moved to the documentation for thecolor.mapmodule, which is documented as a constant.Documentation for constants are stored in
BindingInfo, as part of a newBindingDocumentationstructure, which ensures that a binding cannot have only partial documentation information. When creating a binding from a function, type or element, its documentation is copied to the binding. There is AFAIK a single exception: symbol functions, for which the binding does not have any documentation information (which makes sense, because the binding is for the symbol, not the function).I would argue that this closes #6567 by making
sys.versiona searchable item in the documentation, such that searching for "version" yields the result "Compiler Version".A few screenshots showing some newly-documented constants.