Contributing โ
Workflow โ
- Fork and clone, then verify the baseline:sh
zig build test zig build conformance - Keep changes focused: one feature or fix per pull request.
- Follow the codebase conventions:
- Tests live inline at the bottom of the source file that implements the functionality โ never in a separate
tests/tree. - Examples in
examples/consume only the public API (@import("treesitter")) and the bundled grammars; they must all run viazig build run-all-examples. - No hidden allocators: take
std.mem.Allocatorexplicitly, document ownership on every public type. - No C, no Rust, no vendored code: upstream Tree-sitter is a behavioral reference only.
- Tests live inline at the bottom of the source file that implements the functionality โ never in a separate
- Prove behavior changes with the harnesses:
- New grammar behavior โ add
src/debug/corpus/*.txtcases and list them inconformance.corpus_files. - New query syntax โ inline tests in
src/query/plus corpus or example coverage where it parses real source. - Fuzz-sensitive areas โ extend
fuzz/fuzz.zigfragments.
- New grammar behavior โ add
- Update every affected surface together: source, inline tests, examples,
README.md, and the matching pages underdocs/(guides, concepts, API reference, compatibility matrix, FAQ). - Run the full verification before opening the PR:shFrom
zig build test-all # tests + benchmark + all examples zig build conformance # differential corpus (19 cases) zig build fuzz # seeded parser/query fuzzerdocs/:npm run docs:buildmust complete with no warnings.
Docs conventions โ
- Every page starts with
descriptionfrontmatter (one accurate sentence). - Document only implemented behavior; mark partial areas honestly.
- Register new pages in
docs/.vitepress/config.ts(sidebar) or the build still passes but readers can't find them. - Never leave dead internal links: removing a page means updating its sidebar entry and every link to it.
- Code samples must be real: copy runnable snippets from
examples/or verified test output, never invented output.
Adding a bundled grammar โ
- Add
src/language/<name>.zigwith symbol table, matchers, LR tables, and metadata (plus an external scanner module if tokens need context). - Re-export from
src/language/language.zigandsrc/treesitter.zig. - Add
src/debug/corpus/<name>_*.txtcases (valid, nested, empty, error, incremental) and register them incorpus_files. - Add an
examples/<name>_parse.zigprogram and list it inbuild.zig. - Document it in
docs/guide/language-definition.md,docs/examples/languages.md,docs/api/language.md, and the compatibility matrix.
The canonical contributor file also lives at the repository root: CONTRIBUTING.md. The full test/benchmark/fuzz reference is Testing.
License โ
Contributions land under the repository's MIT license.
