Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Contributors

Listsome is one crate and one binary, with no runtime and no database. This page covers the layout of the code, the commands that keep it honest, and what a change needs before it’s worth a review.

How a build works

projects/*/index.md   frontmatter and Markdown
        |
        v
  project_intake      splits frontmatter, parses Markdown, extracts structure
        |
        v
  model               Project, ProjectMetadata, Step, MaterialItem
        |
        v
  render              MiniJinja context built from the model
        |
        v
  generator           writes output/, images, taxonomies, feed, manifest
        |
        v
  output/             static HTML, any host takes it from here

listsome build walks the pipeline in that order, and each stage takes its input from the stage before it rather than from the filesystem.

Modules

PathResponsibility
src/main.rsEntry point, log filter setup, error exit code
src/cli.rsArgument parsing with clap, command dispatch
src/commands.rsCommand implementations, the only place that wires stages together
src/config.rsConfig loading, defaults for a new site, saving
src/error.rsListsomeError and the crate’s result alias
src/model/Project, ProjectMetadata, Step, MaterialItem, SiteConfig
src/project_intake/Frontmatter parsing, Markdown to HTML, steps, callouts, materials tables
src/project_intake/materials.rsColumn matching and h-product markup for bills of materials
src/render/mod.rsTemplate contexts and content enhancement
src/generator/Site writing: discovery, assets, taxonomy, feed, renderer
src/images.rsResizing and encoding
src/webmention/Fetch, verify, storage, send, shared HTTP client
src/server/Dev server, file watch, WebSocket reload
src/templates/Built-in MiniJinja templates
src/assets/Built-in style sheet and the lightbox script

src/project_intake is the parser. Nothing named src/parser exists, whatever older notes say.

Data flow

  1. A command loads listsome.toml through config::find_and_load_config.
  2. generator::discovery walks projects/ two levels deep and reads every directory that holds an index.md.
  3. project_intake::parse_project splits frontmatter, renders the body, and pulls out steps, callouts, and materials tables. A file that fails to parse build drops it rather than reports it.
  4. render builds a context per project and hands it to a MiniJinja template.
  5. generator::assets copies each project’s assets/ directory and re-encodes images on the way through.
  6. generator writes the index pages, the category and tag pages, the Atom feed, and output/.webmentions/outbound.json.

Design rules

The checks enforce these rules rather than suggest them.

  • No unwrap, no expect, no panic outside tests. clippy.toml allows them in test code, and src/main.rs denies clippy::unwrap_used, clippy::expect_used, and clippy::panic at the crate root for everything else.
  • Errors carry their context. ListsomeError attaches the path, template, or pattern that failed, and keeps the underlying error as its #[source], so a message names a file rather than a syscall and a cause stays reachable.
  • Pure parsing, shell commands. project_intake and render take data and return data. Filesystem and network work lives in commands.rs and generator/.
  • One HTTP abstraction. webmention::http::HttpClient has a real implementation and a mock, so tests never reach the network.
  • No silent drops. A build that skips a project or a config key says so. One exception is still open: #84, a project that fails to parse.

Commands

just is the front door.

CommandWhat it does
just buildRelease build
just installRelease build, then copy to ~/.cargo/bin
just testTest suite
just checkType check, no code generation
just clippyLints with --all-targets and -D warnings
just docs-lintVale and rumdl over docs/ and the README, then the mdBook build
just serve-exampleRelease build, then serve the example site on port 8080
just watchRebuild on change

cargo clippy without --all-targets skips test code, which is why the pre-commit hook isn’t the gate that matters. Run just clippy before you call a change done.

Tests

cargo test runs the unit modules inside src/ plus one integration suite:

  • tests/example_site.rs builds examples/basic with the compiled binary and snapshots the index page, one project page, and the category index. When a change shouldn’t alter output, the snapshot diff has to be additive only:

    git diff --unified=0 tests/snapshots | grep '^-[^-]'
    

    Empty output means the diff removed nothing.

rss.xml stays out of snapshots on purpose. Its updated field is the clock, so a byte-exact comparison would fail on the next Tuesday.

Documentation

docs/ is an mdBook, and book/ is its build output. Three tools hold the line, and just docs-lint runs all of them:

  • mdBook builds the site that .woodpecker/docs.yml publishes to Codeberg Pages. Broken internal links show up there.
  • Vale checks prose against the Google rules vendored in .vale/Google plus the project rules in .vale/styles/listsome. MinAlertLevel = suggestion, so every alert it prints is a failure.
  • rumdl checks Markdown structure with an 80-column prose limit. Tables and code blocks are exempt, and paragraphs aren’t.

Prose rules worth knowing before you write: no em dashes, no parentheses in prose or tables, active voice with a named actor, contractions, and no first-person plural. Vale wants most acronyms spelled out, and a spelling out needs parentheses, so this documentation avoids the acronyms instead.

Continuous integration

Woodpecker runs four pipelines from .woodpecker/:

  • ci.yml checks formatting, lints with --all-targets, runs tests, builds docs, and does a release build on pushes and pull requests.
  • release-pr.yml opens a release pull request when Cargo.toml bumps.
  • release.yml builds the binary and creates the tag and release.
  • docs.yml builds the book and publishes it to Codeberg Pages.

Everything runs on rust:1.96, the same toolchain the crate requires.

Making a change

Never commit on main. Work in a sibling worktree:

git fetch origin
git worktree add ../listsome-feature-name -b feature/name origin/main
cd ../listsome-feature-name

Commit with conventional commit messages. cog verify runs in the commit-msg hook and rejects anything it can’t parse into the changelog:

git add .
git commit -m "feat(content): price a materials table as a bill of materials"

Before you push, rebase, then run the gates:

git fetch origin main
git rebase origin/main
just clippy && just test && just docs-lint
just build && just serve-example

origin is Codeberg. fj is the forge command-line tool, and its subcommands are search rather than list:

fj pr search
fj issue search --state open
fj pr create "Title" --body-file body.md

Feed long bodies from a file. fj pr create --body and fj issue edit replace the whole body, and text inside a double-quoted shell string gets its backticks executed.

Decisions

Anything that changes architecture earns a record in docs/adr/ before the code lands. The records follow Michael Nygard’s format, and the newest one is the last file in the directory. A record is a snapshot of a decision, so later work adds a new record rather than editing an old one. When a record stops matching the code, say so in its status section: stale prose about a live system is worse than no prose.