Ricky Moony and Lucy, a moon shaped mascot for Dream with the star shaped mascot for Gleam, each with cute cartoon eyes and a smile

Checks that every code block in a Gleam project’s docs matches a tested snippet file.


Hex Package Latest Release HexDocs Coverage MIT License Gleam

dream_snippets

A code block with no tested snippet can be wrong, and nobody finds out until a reader tries it. dream_snippets is the check that every Dream repository runs in CI to stop that: each Gleam code block in the README, the guides and the doc comments must be a copy of a snippet file that the tests compile and run. It works in any Gleam project on GitHub.

Sent here by a “not in the exact format” message? Copy the heading and badges from Copy a badge in the Tested code blocks guide.

Features

Installation

gleam add --dev dream_snippets

Quick Start

Run the check from the project root:

Run the check Tested snippet Guide: Getting started

gleam run -m dream_snippets

It prints one line for each problem and a summary line, and it stops with exit code 1 when it finds a problem. The same check is one Gleam call:

Check a project and read what the command prints Tested snippet Guide: Use it from Gleam

import dream_snippets

pub fn summary_of(directory: String) -> List(String) {
  let output = dream_snippets.output(dream_snippets.check_project(directory))
  output.standard_output
}

Guides

Design Principles

dream_snippets follows Dream’s design principles and contributing guide.

About Dream

This package was first built inside the Dream web toolkit, as the check behind its tested docs. It is standalone and can be used in any Gleam project. It follows Dream’s design principles and will be maintained as part of the Dream ecosystem.

Contributing

See the Contributing Guide for guidelines.


License

MIT — see LICENSE.md


Built in Gleam, on the BEAM, by the Dream Team ❤️
✨ Search Document