Skip to content

Parameter details after the first example are collapsed by mistake #6922

@YDX-2147483647

Description

@YDX-2147483647

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.

/// 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.

Image Image

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.

Discord

laurmaedje
yeah I know about this. I intended to do something about before the release.

Debug

Current implementations

typst/docs/src/lib.rs

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)
}

typst/docs/src/model.rs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions