# Documentation Development
{: .no_toc }

This section covers the twinBASIC documentation's own tooling: the URL contract the compiler and IDE rely on, how to author a page in the house style, the build / preview / deploy workflow, every script and batch file in the repository, and the internals of the `tbdocs` static site generator.

## Toolchain overview

Three commands build and verify a content change:

- `build.bat` produces three output trees from the markdown source and link-checks them in the same pass.
- `check.bat` runs the further gates that read those trees, from the freshness check to the accessibility scan.
- `book.bat` renders the PDF from the third tree.

A fourth wrapper, `test.bat`, tests the toolchain rather than the site; run it when a change reaches outside `docs/`. [Tools and Scripts](/Documentation/Development/Tools.md) names the gates each wrapper runs, in order.

`examples.bat` sits outside this workflow and outside CI. It compiles the twinBASIC code samples in the pages, which needs a twinBASIC install and Windows --- see [Checking that a sample compiles](/Documentation/Development/Authoring.md#checking-that-a-sample-compiles).

![A flow chart running top to bottom from the docs/ source tree. One branch goes through serve.bat to the _serve/ tree and a local browser; the other goes through build.bat to three output trees: _site/ for the online HTML, _site-offline/ for the file:// mirror, and _site-pdf/ for the book source. check.bat reads the built trees, and book.bat turns the book source into the finished PDF. Each box but the browser links to the entry for its tool or to the section that explains it.](/assets/images/dot/toolchain-overview.svg)

Run `build.bat` before `check.bat` or `book.bat`: `check.bat` audits `_site-offline/` and refuses a tree older than its sources, and `book.bat` reads `_site-pdf/`. A clean `build.bat && check.bat` is the bar for "ready to commit".

## Build pipeline

A `build.bat` run executes `tbdocs` against a shared task graph. Workers and the main thread pull ready tasks from a SharedArrayBuffer-based scheduler; there is no central dispatcher and no fixed phase sequence. The graph is organised into five sections (**Seeds**, **Spine**, **Render**, **Write**, **Check**) that also label the timeline on the [Build Info](/Documentation/Development/BuildInfo.md) page. The [tbdocs Builder](/Documentation/Development/Builder.md) page documents the full graph, the scheduler and each task's interface contract.

## Sub-pages

- [Permanent Links](/Documentation/Development/Permanent-Links.md) --- the stable `/tB/` URL contract under which the IDE help system and external references resolve.
- [Authoring Pages](/Documentation/Development/Authoring.md) --- how to write or edit a page so it matches the rest of the site: frontmatter and permalinks, heading levels, formatting, plain-English prose, attribution, and cross-section links.
- [Building and Deployment](/Documentation/Development/Building.md) --- the day-to-day workflow for editing content: requirements, building, serving locally, link checking, Graphviz diagrams, screenshots, and the GitHub Pages deployment.
- [Updating a Contributed Package](/Documentation/Development/Contributed-Packages.md) --- the steps that bring a contributed package's section up to a new version of the package: its snapshot, pages, samples and test cases, and the runs that check them.
- [Tools and Scripts](/Documentation/Development/Tools.md) --- reference for every script, batch file, and CLI flag exposed by the documentation toolchain, on a landing page for the batch wrappers and pages of tools grouped by what they work on (intended audience: doc contributors).
- [tbdocs Builder](/Documentation/Development/Builder.md) --- detailed technical documentation for the `tbdocs` static site generator that lives under [`builder/`](https://github.com/twinbasic/documentation/tree/main/builder). Read this when modifying the build pipeline itself. Sub-pages:
    - [Pipeline Stages](/Documentation/Development/Pipeline-Stages.md) --- complete interface reference: per-task signatures and per-module export tables, plus the scheduler-level concepts (flag bits, task lifecycle, SAB layout).
    - [Book Configuration](/Documentation/Development/Book-Configuration.md) --- `_book.yml` key reference for the PDF chapter manifest.
    - [Extending the Builder](/Documentation/Development/Extending.md) --- tutorial for adding a new pipeline task, markdown-it plugin, render-worker sub-stage, or verification gate.
- [Wisdom](/Documentation/Development/Wisdom.md) --- the Discord knowledge harvester: a three-phase tool (export, process, extract) that mines the twinBASIC Discord for actionable technical knowledge and drafts documentation additions for human review.
- [PDF Generation](/Documentation/Development/PDF-Generation.md) --- internals of the PDF renderer: `render-book.mjs`, paged.browser.js, and the pdf-lib shims.
- [Library Patches](/Documentation/Development/Fixes.md) --- every modification to `paged.browser.js` and the `fast-*.mjs` pdf-lib shims: upstream problem, applied fix, and mechanism.
