Skip to content

Style Guide

Ants Aare edited this page Feb 28, 2025 · 2 revisions

Methods and variables:

Methods should explain what they do, no single letter or two letter methods. Methods that draw something in a CeTZ canvas should have a uniform naming. I would like to suggest a -canvas suffix, but I already saw it in some packages that draw- is more common.

Use kebab-case instead of snake_case or camelCase. All names should be lowercase. When more than two arguments -> split arguments into one per line like this:

#let method(arg1, arg2)={
}

#let method(
  arg1,
  arg2,
  arg3,<-trailing comma
)={
}

Comments:

English comments only. We're all not native speakers, so when we have a codebase with 10 languages it's gonna be all hell. If you comment out codeblocks you always need a description if you want it to stay, otherwise it will be deleted without thinking about it. We are using git, so nothing is getting lost.

Other

returns should always be on their own line, because they are important

if ... {
  return data
}

// big nono
if ... { return data}

When possible try to use trailing commas, typst has amazing trailing comma support, so might as well use it:

(
  "hello": "world",
  "world": "hello",<-trailing comma
)

Clone this wiki locally