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

Code structure and coding conventions: see ARCHITECTURE.md. How to run the tests: see the “Testing” section of README.md.

Commit messages: Conventional Commits

The first line of a commit has the form <type>: <description> (in English, imperative mood). The type decides the next version and the group in CHANGELOG.md:

TypeUse forVersion bump (while 0.x)Changelog group
featA new featureminor: 0.1.0 → 0.2.0Added
fixA bug fixpatch: 0.1.0 → 0.1.1Fixed
perfFaster, less memorypatchPerformance
refactorReorganised code, same behaviourpatchChanged
docsDocumentationpatchDocumentation
testTestspatchTests
ci, buildCI, build, dependenciespatchBuild and CI
choreOther chorespatchOther
  • Breaking changes (a changed CLI option, a changed JSON output format, a changed public API): add ! after the type (feat!: ...) or a BREAKING CHANGE: ... line in the body.
  • A scope may go in parentheses: fix(tables): keep header rows at the top of a page.
  • Examples: feat: add a batch command, perf: keep embedded JPEGs instead of re-encoding them.

Older commits from before this convention use the form “Add …”, “Fix …”. The changelog still puts them in the right group.

Releases

Every merge into main is a release, and the merged commit is the release commit, except a PR that changes nothing built or tested. PRs are squash-merged, so the PR title (a Conventional Commits subject, checked by .github/workflows/pr.yml) is the commit, and it sets the version: feat → minor, breaking (! before the colon, or BREAKING CHANGE: in the description) → major (minor while 0.x), anything else → patch.

A PR of kind docs, ci, test, style or chore that is not breaking is not released: it keeps the version of the last release, has no CHANGELOG.md entry, and its merge makes no tag, no GitHub release and no package. bump leaves its version as it is. When such a PR must be published all the same (a docs change to README.md, which crates.io and PyPI show), run python3 scripts/release.py bump --pr <number> --release.

A PR that is released therefore carries its own version and changelog entry:

  1. Open the PR, then run on its branch:

    python3 scripts/release.py bump --pr <number>
    

    It reads the PR’s title and description with gh, works out the version from the last vX.Y.Z tag and the title, writes it into Cargo.toml and Cargo.lock, and writes the entry at the top of CHANGELOG.md. Commit it (chore(release): vX.Y.Z) and push. Without gh: --title "fix(tables): ..." --body-file description.md (a file in the repository or a temporary directory, or - for the standard input).

  2. Run it again after changing the title or the description: it rewrites the same entry.

  3. The PR workflow fails while the version is not the one the title asks for, or CHANGELOG.md has no entry for it.

  4. On merge, .github/workflows/release.yml tags the merged commit vX.Y.Z and creates the GitHub release with that entry as notes, then builds the binaries for Linux (x86_64, aarch64), macOS (Apple Silicon, Intel) and Windows (x86_64), with sha256 checksums, attaches them, and publishes the crate. Nothing is committed to main by the workflow.

Two open PRs cannot both keep the same version: once one is merged, the other has a conflict in Cargo.toml; update it from main and run bump again.

The PR description is the release note. The entry of a PR is its title followed by its description, cleaned first:

  • what is only for reviewers is dropped: a Summary heading, the Testing / Tests / Test plan / Verification / Snapshots sections, the “Generated by” footer and trailers;
  • headings move two levels down.

So write the description for users: what changed and why, with numbers where they help.

Pull requests that only change the documentation

scripts/ci_changes.py decides whether a PR changes anything the build or the tests read. When it does not, CI (lint, tests, Word fidelity), SonarQube and the Python tests and wheels are skipped; the “Title and version” check still runs, and such a PR is released unless its kind is one that is not (above). A PR counts as documentation only when every file it changes is a Markdown file at the root, a file under docs/, python/README.md or LICENSE, apart from Cargo.toml and python/pyproject.toml changed only in their package metadata (version, description, keywords, …) and Cargo.lock changed only in the version of kakemono. Markdown read by the tests (tests/data/word/*.md) or next to the code (src/**/README.md) is code.

Code quality: SonarQube Cloud

.github/workflows/sonar.yml sends each push to main and each pull request to SonarQube Cloud, with the clippy findings (clippy-report.json) and the test coverage from cargo llvm-cov (lcov.info). Settings are in sonar-project.properties. The job is skipped until the SONAR_TOKEN secret exists. One-time setup:

  1. Sign in to sonarcloud.io with GitHub, import the GitHub organization and add this repository as a project.
  2. In the project, Administration → Analysis Method: turn off Automatic Analysis (the workflow does the analysis; both cannot run at once, and only the workflow imports clippy and coverage).
  3. My Account → Security: generate a token, and add it to the repository as the GitHub secret SONAR_TOKEN (Settings → Secrets and variables → Actions).
  4. If SonarQube Cloud gave the organization or project another key than the ones in sonar-project.properties, change them there.