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

Contributing

Bug reports, ideas and pull requests are all welcome. For anything bigger than a small fix, open an issue first so the approach can be discussed.

Building and testing

The project is a Rust workspace. The justfile has the commands CI runs:

just test     # run all tests
just clippy   # lint, with warnings as errors
just format   # format the code
just doc      # build the API docs, with warnings as errors
just docs     # build the book and check its links

Parts of the docs are generated from the code, like the table of lint rules. Tests fail when they fall behind, and just update-docs regenerates them.

Most formatter tests are insta snapshot tests. When a change alters the output, review the new snapshots with cargo insta review before accepting them. Every bug fix should come with a snapshot that shows the fixed case.

The docs are an mdBook under docs/. Run mdbook serve docs to preview them, and just docs to build them and check every link with lychee, the same way CI does.

Where things live

CrateContains
rafikiThe command line tool
monkey-c-parserThe lexer, parser and syntax tree
monkey-c-formatterThe formatter
monkey-c-linterThe lint rules and their fixes
monkey-c-lspThe language server
monkey-c-configThe rafiki.toml format
monkey-c-coverageThe source rewriting behind rafiki coverage
monkey-c-jungleA parser and printer for jungle files

Adding a lint rule

  1. Add a module under monkey-c-linter/src/rules with a check_expr or check_stmt function that returns a Diagnostic, and a fix if one is safe.
  2. Call it from the matching dispatch_* function in visit.rs.
  3. Add it to rules::ALL with a one-line summary and whether it has a fix. The command line and the Rules table are built from it.
  4. Add tests next to the rule for what it flags and what it leaves alone.
  5. Add a page at docs/src/linter/rules/<name>/README.md, list it in docs/src/SUMMARY.md and run just update-docs to add it to the rules table.