Settings and checks reference

This page lists every setting of the check with its default, and every check it makes. The guides explain how to use them. Come here when you need the full list.

Table of Contents

What the check reads from gleam.toml

FieldUsed for
nameThe messages about a wrong tag, as in the docs of my_app use the version in gleam.toml.
versionThe release of every document that names no release of its own (see The release of a document): the tag that its tested snippet badges and guide badges link at, and the new tag of its diff badges. Release notes and changelog sections of an older release are compared with the files at their own tag instead.
repositoryThe GitHub repository that every badge links at: user is the owner and repo the name. type must be github.
[dependencies], [dev-dependencies]The keys only. A gleam add or gleam deps update line with no badge may name them and name. A missing table has no keys, and a value that is not a table is an error.

Settings

All settings go in an optional [tools.dream_snippets] table in gleam.toml. Each one is optional.

SettingTypeDefaultWhat it does
markdownlist of paths["README.md", "SECURITY.md", "docs", "examples"]Markdown documents, and directories walked for .md files. The root README.md gets the README rules.
changeloglist of paths["CHANGELOG.md"]Changelogs. Only the text before the first section, the ## [Unreleased] section and the sections of checked_from_version and later are checked.
release_noteslist of paths["releases"]Directories of release-<version>.md files, or single release-<version>.md files. Only the notes of checked_from_version and later are checked.
gleam_sourcelist of paths["src"]Directories walked for .gleam files, whose /// and //// doc comments are checked.
checked_from_versionstring, a semver version such as "1.0.0" or "1.0.0-rc.1""0.0.0"The first version whose changelog section and release notes are checked, in semver order. 0.0.0 checks every version.
guideslist of paths["docs/guides"]The directories of guides. A README guide badge links to a .md file under one of them, and code at an older release is allowed in them. They aren’t walked.
tested_fileslist of paths["test", ".github"]The files and directories that the tests or CI use. A file, command or output block links to a file that is one of them or under one of them. A path doesn’t need to exist, and the list isn’t walked.
badge_guidestring"https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html"Where a message about a malformed badge or a missing guide badge tells the reader to copy it from.
release_notes_guidestring"https://hexdocs.pm/dream_snippets/guides/release-notes-template.html"Where a release notes message tells the reader to read the “Release notes template” section.

The defaults in TOML

The same defaults, as you’d write them. The tests read this file and make sure that it gives the same settings as no table:

The defaults Tested snippet

[tools.dream_snippets]
markdown = ["README.md", "SECURITY.md", "docs", "examples"]
changelog = ["CHANGELOG.md"]
release_notes = ["releases"]
gleam_source = ["src"]
checked_from_version = "0.0.0"
guides = ["docs/guides"]
tested_files = ["test", ".github"]
badge_guide = "https://hexdocs.pm/dream_snippets/guides/tested-code-blocks.html"
release_notes_guide = "https://hexdocs.pm/dream_snippets/guides/release-notes-template.html"

A project whose docs are tested from 1.1.0 on, and whose contributing guide shows the badges, sets two of them:

Two settings Tested snippet

[tools.dream_snippets]
checked_from_version = "1.1.0"
badge_guide = "docs/contributing.md"

Rules for the settings

What the check reads

KindFilesRules
Markdown.md files under the markdown pathsEach fence, by its kind. Code at an older release only under a guides directory. The root README.md also needs a guide badge on each example with a tested snippet badge.
Release notesrelease-<version>.md files under the release_notes paths, of checked_from_version and laterEach fence, code at an older release allowed, and the release notes template.
ChangelogThe changelog filesEach fence of the text before the first section, the ## [Unreleased] section and the ## [<version>] sections of checked_from_version and later.
Gleam source.gleam files under the gleam_source pathsEach fence in each run of /// or //// doc comment lines, read as Markdown.

The release of a document

Each document, or each changelog section, belongs to one release. The release sets the tag of its badge links and the code that its blocks are compared with.

DocumentReleaseBadge links and the new tag of a diffCode that the blocks are compared with
A guide, the README, another Markdown document, doc commentsThe version in gleam.tomlThat versionThe working tree. A diff is git diff <old tag> -- <path>.
release-<version>.md, or the ## [<version>] changelog section, of the version in gleam.tomlThat versionThat versionThe working tree, as for a guide
release-<version>.md, or the ## [<version>] changelog section, of an older releaseIts own versionIts own versionThe files at its tag (git show <tag>:<path>). A diff is git diff <old tag> <tag> -- <path>.
The ## [Unreleased] section, a section with another name, the text before the first sectionThe version in gleam.tomlThat versionThe working tree

So the docs of a release stay right after the next version bump, with no change. The tag of an older release must be in the clone. A release after the version in gleam.toml is a problem. Versions are ordered as semver 2.0.0 orders them: a pre-release such as 0.2.0-rc.1 comes before 0.2.0, so its notes and its code at an older release belong to an older release.

Block kinds and their proofs

check.classify_fence reads the kind of every fence from its info string, the text after the opening backticks or tildes. The language is the first word, in lowercase. Every check gets the kind from there, so a language that the check doesn’t know is a file block, never a skipped block.

Info stringKindProofCounted as
gleamGleam blockA heading with the tested snippet badge, or with the code at an older release badge. The block is the linked file or line range, byte for byte.blocks
diffDiff blockA heading with the tested diff badge. The block is a part of the real git diff.diff blocks
markdown, mdExample documentEach fence in it is checked by its kind, with the rules and the release of the document around it. Each other line must not look like Gleam code. Its headings, links and badges without a fence are not checked, and it is not checked against the release notes template.Its fences
bash, sh, shell, consoleCommand blockA heading with the tested snippet badge or the code at an older release badge, to a file of tested_files. With no badge heading: each line is blank, gleam add or gleam deps update, at least one is not blank, and each argument is a package name of name, [dependencies] or [dev-dependencies], or --dev on a gleam add line. A gleam add line names a package.command blocks
textOutput blockA heading with a badge to a file of tested_files, as for a command block.output blocks
<language> illustration, for any language but gleam, diff, markdown and mdIllustrationNone. No line may look like Gleam code.illustration blocks
Any other languageFile blockA heading with a badge to a file of tested_files, as for a command block. With no badge heading, a toml block only: the first line that is not blank is [dependencies] or [dev-dependencies], each other line is blank, one of those two, or <package> = "<requirement>", at least one requirement is there, each package is name, and each requirement is >= <release> and < <next major>.0.0 for the release of the document.file blocks
NothingUnlabelledNone. Always a problem.Not counted

A heading with a badge is any heading line, at most one blank line above the fence, with the text alt="Tested snippet" or alt="Code at . When a file or command block has one, the badge is checked, and the block is never proven by its lines instead. Only the illustration mark changes the kind: other words after the language, as in toml title=x, are not read.

The check can’t see whether a test or CI uses a file, or whether a test compares an output file with the real output. The tested_files setting is the project’s statement of the first, and the tests of the project are the proof of the second. Tested code blocks shows a test that compares an output file.

Checks

The check fails when one of these is true. Each one has its own message, and Fix a failed check shows each message with its fix.

Gleam blocks and the tested snippet badge

File, command and output blocks

Packages and dependency lines

Other fences

The README and the guide badge

Diff blocks

Code at an older release

Release notes and changelog sections of a release

Release notes

Release notes template lists the sections.

Errors that stop the check

Output and exit status

ResultStandard outputStandard errorExit status
No problemThe summary lineNothing0
ProblemsOne file:line: reason line for each problem, sorted by file and line, then the summary lineNothing1
An error that stops the checkNothingOne error: <description> line1

The summary line has the form <n> blocks and <n> diff blocks checked in <n> files, <n> problems; <n> file blocks, <n> command blocks and <n> output blocks checked; <n> illustration blocks, with the singular for a count of 1, as in 1 block and 0 diff blocks checked in 1 file, 1 problem; 0 file blocks, 1 command block and 0 output blocks checked; 0 illustration blocks. blocks counts the gleam blocks. The part before the ; has the form of earlier versions, so a tool that reads only that part, or that looks for , 0 problems;, reads both. Each problem and each error is exactly one line: a control character in a file name, a value or a message is shown as \n, \r, \t or \u{<hex>}. The check uses no network. It reads files from the working tree, and runs git rev-parse, git diff, git ls-tree and git show in the project root for diff blocks, code at an older release, and the release notes and changelog sections of an older release.

✨ Search Document