Code: Docs that build themselves with Grimoire
Docs that build themselves with Grimoire: the code
The sample books behind the slides, built and checked with Grimoire 0.5.0 on Jennifer 0.26.0. Get Grimoire with jvc app install https://github.com/jennifer-language/grimoire, from a checkout (git clone --branch 0.5.0 https://github.com/jennifer-language/grimoire, then grimoire/bin/grimoire), or use the container image ghcr.io/jennifer-language/grimoire:0.5.0 with no install. Build output (site/, the PDFs, the EPUB) is not kept here.
my-book/: the bookgrimoire init my-bookwrites, with the configuration of the talk and areference/folder added to the outline ("A book in a minute", "The outline: SUMMARY.md", "Tried on our book"). Build, frommy-book/:grimoire build --pdf --verbose(5 pages, the two reference chapters skipped insite/my-book.pdf)my-book/grimoire.toml: theme, edit link, highlighting and the printed book, withexclude = ["reference/"]("grimoire.toml: what most books set", "The printed book").grimoire build --theme ivytries another theme without editing it.my-book/grimoire-ref.toml: the second book, onlydocs/reference("Several books from one docs/ tree", "Tried on our book"). Build, frommy-book/:grimoire pdf -c grimoire-ref.toml(writessite/my-book-reference.pdf)my-book/grimoire-epub.toml:grimoire.tomlplus theepubrenderer ("The e-book: EPUB"). The optionalcoverandstylesheetkeys are paths underdocs/; they are left out here so the other builds copy no assets. Build, frommy-book/:grimoire build -c grimoire-epub.toml --pdf --verbose(addssite/my-book.epub)my-book/.github/workflows/docs.yml: publishes the book to GitHub Pages from the highest release tag with Grimoire's reusable workflow;preparerenders the reference PDF intodocs/reference/with the image,checkfails the run when a PDF is missing ("CI: publish from the latest release", "Pages that write themselves"). Copymy-book/into a repository of its own; Pages must deploy from GitHub Actions and thegithub-pagesenvironment must allow tags.plugins-book/: a one-page book that names theincludepreprocessor and thesitemaprenderer;docs/index.mdincludesdocs/examples/hello.j(include paths are relative todocs/) ("Plugins are programs", "Know what a book will run"). Run, fromplugins-book/:grimoire plugins, thengrimoire build(writessite/sitemap.xmlandsite/robots.txt);jennifer run docs/examples/hello.jruns the included program.
The container commands of "Install it, or don't" and "The container image", from my-book/:
docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" \
ghcr.io/jennifer-language/grimoire:0.5.0 build --pdf
docker run --rm --user "$(id -u):$(id -g)" -p 127.0.0.1:8080:8080 \
-v "$PWD:/work" ghcr.io/jennifer-language/grimoire:0.5.0 \
serve --watch --addr 0.0.0.0:8080The image runs as its own user jennifer, so without --user it cannot write site/ into a directory you own. With Podman use --userns=keep-id instead of --user.
| File | Size | |
|---|---|---|
| LICENSE | 899 B | raw |
| README.md | 3.0 KiB | raw |
| my-book/.github/workflows/docs.yml | 1009 B | in the zip |
| my-book/docs/SUMMARY.md | 238 B | raw |
| my-book/docs/getting-started/first-steps.md | 219 B | raw |
| my-book/docs/getting-started/installation.md | 159 B | raw |
| my-book/docs/index.md | 282 B | raw |
| my-book/docs/reference/index.md | 75 B | raw |
| my-book/docs/reference/options.md | 82 B | raw |
| my-book/grimoire-epub.toml | 693 B | raw |
| my-book/grimoire-ref.toml | 169 B | raw |
| my-book/grimoire.toml | 618 B | raw |
| plugins-book/docs/examples/hello.j | 39 B | raw |
| plugins-book/docs/index.md | 181 B | raw |
| plugins-book/grimoire.toml | 184 B | raw |