Skip to content

Comments as documentation

NativeBrowserNode1 min read

Use // to leave a note for readers. A short group of comments directly above a public declaration also becomes its API documentation in the editor. Dream does not use /// or block comments.

At a glance

// Number of elements currently stored.
public get length(): int {
    return this.count;
}
  • // starts a comment that runs to the end of the line.
  • Comments directly above a public declaration become its documentation in the editor.
// Number of elements currently stored.
public get length(): int {
    return this.count;
}

Contiguous // lines directly above a declaration are the docs. A blank line ends that block:

// This is attached — hover shows it.
public fun ready(): bool {
    return true;
}

// This is NOT attached — a blank line sits above the declaration.
public fun orphan(): void {}

The editor shows that block on hover. Private helpers and non-public funs may omit comments.

Prefer one concise sentence that states behavior and edge cases (None when empty, case-sensitivity, …), matching the style of List and int.parse in the stdlib.