-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Description
For some parameters, the details and examples are interspersed together, and details after the first example are collapsed into the example, which is confusing.
Both the official https://typst.app/docs and the community typst-jp/docs are affected.
Take place.dx for an instance
Look at the source markup of place.dx: First a paragraph, then an example, and finally another paragraph.
typst/crates/typst-library/src/layout/place.rs
Lines 138 to 151 in 88b6fc0
| /// The horizontal displacement of the placed content. | |
| /// | |
| /// ```example | |
| /// #set page(height: 100pt) | |
| /// #for i in range(16) { | |
| /// let amount = i * 4pt | |
| /// place(center, dx: amount - 32pt, dy: amount)[A] | |
| /// } | |
| /// ``` | |
| /// | |
| /// This does not affect the layout of in-flow content. | |
| /// In other words, the placed content is treated as if it | |
| /// were wrapped in a [`move`] element. | |
| pub dx: Rel<Length>, |
On the docs website, the second paragraph is collapsed into the example, even though it does not describe the example.
On the typst-jp website:
Suggestions
- Option A: Allow details and examples to be interspersed together.
Option B: Find all docs doing so and alter their wordings.
laurmaedje
yeah I know about this. I intended to do something about before the release.
Debug
Current implementations
Lines 482 to 494 in 88b6fc0
| /// Split up documentation into details and an example. | |
| fn split_details_and_example(docs: &str) -> (&str, Option<&str>) { | |
| let mut details = docs; | |
| let mut example = None; | |
| if let Some(mut i) = docs.find("```") { | |
| while docs[..i].ends_with('`') { | |
| i -= 1; | |
| } | |
| details = &docs[..i]; | |
| example = Some(&docs[i..]); | |
| } | |
| (details, example) | |
| } |
Lines 106 to 111 in 88b6fc0
| /// Details about a function parameter. | |
| #[derive(Debug, Serialize)] | |
| pub struct ParamModel { | |
| pub name: &'static str, | |
| pub details: Html, | |
| pub example: Option<Html>, |
$ cd crates/typst-library
$ rg '\s+/// ```\r?\n\s+///' --multiline --files-with-matches
src/text/raw.rs
src/math/matrix.rs
src/text/mod.rs
src/model/figure.rs
src/layout/transform.rs
src/foundations/str.rs
src/layout/place.rs
src/layout/grid/mod.rs