Build & Test
Build
Default Build
Build the workspace with default features (mmap):
cargo build
Build with Training Support
Include CRF-based dictionary training functionality:
cargo build --features train
Build CLI Only
cargo build -p lindera-cli
The CLI has the train feature enabled by default.
Test
Single Test
Run a specific test within a crate (recommended for development):
cargo test -p <crate> <test_name>
Training Feature Tests
cargo test -p lindera-trainer
All Features for a Crate
Run the full test suite for a single crate:
cargo test -p <crate> --all-features
Note: CI does not use
--all-features-- it runs each crate with a curated, crate-specific feature combination (see.github/workflows/regression.yml). The Makefile's per-crate pattern targets (make test-<crate>,make lint-<crate>) apply the same feature combinations CI uses and are the closest local equivalent. CI also testslindera-segmenterandlinderaonce more with every dictionary embedded (on Linux only), which runs the tests gated on the other dictionaries; to do the same locally, runcargo test -p lindera --features embed-ipadic,embed-ipadic-neologd,embed-unidic,embed-sudachidict,embed-ko-dic,embed-cc-cedict,embed-jieba(and likewise forlindera-segmenter).
Workspace-Wide Tests
cargo test
Quality Checks
Format Check
Verify code formatting matches the project style:
cargo fmt --all -- --check
To auto-fix formatting:
cargo fmt --all
Note:
cargo fmtformats the Rust code only. For a language binding,make format-lindera-<binding>also formats the binding's Python, JavaScript, Ruby or PHP code, with the tools and versionsmake lint-lindera-<binding>checks it with (see below).make format-scriptsdoes the same for the files outside the crates thatmake lint-scriptschecks.
Lint
Run Clippy with warnings treated as errors:
cargo clippy -- -D warnings
Note: CI runs
cargo clippy --all-targets -- -D warningsfor each crate, with the features it tests that crate with (see.github/workflows/test-crate.yml, and the language binding jobs in.github/workflows/regression.yml), so the test code is linted too.make lint-<crate>runs the same clippy command. Run clippy locally (e.g. viamake lint) before opening a PR.For a language binding,
make lint-lindera-<binding>then runs the binding's language-side linter, as the binding's CI job does: ruff for Python, Prettier for Node.js and WASM, RuboCop for Ruby, and PHP CS Fixer for PHP. Their versions are pinned (ruff and Prettier in theMakefile, RuboCop inlindera-ruby/Gemfile, PHP CS Fixer incomposer.json), so a new release of a tool cannot fail CI on unchanged code. The targets install the pinned versions themselves, which needs the language's toolchain (Python 3, Node.js with npx, Bundler, Composer) and network access.
make lint-scriptslints the hand-written files that belong to no binding, as theLint scriptsCI job does: the benchmark harness inscripts/benchmarks/, which the bindings share, and the JavaScript the docs load (docs/mermaid-init.js). It runs the same pinned tools, and checks each file with the rules of the binding written in its language, so it needs all four toolchains.make lintruns it after the crates.
Documentation
API Documentation
Generate and open Rust API documentation:
cargo doc --no-deps --open
Check the crates' API documentation for rustdoc warnings, such as a broken intra-doc link or a public item linking to a private one:
make check-docs
Note: CI runs
make check-docsand fails on any rustdoc warning. It documents every crate but the language bindings with all features: the libraries twice, once with public items only, as docs.rs publishes them, and once with private items too, whose doc comments only that second pass checks; thenlindera-cli's binary, where the CLI's code lives, with its private items. It builds with dummy dictionaries (DOCS_RS=1) in its own target directory,target/check-docs, so it downloads no dictionary and leavestarget/alone.
The language bindings are checked one at a time, since building each needs its language's toolchain:
make check-docs-lindera-python # also -nodejs, -ruby, -php, -wasm
Note: Each binding's CI job runs its target and fails on any rustdoc warning. The target documents the binding twice, public items only and then with private items too, with default features, which already enable every feature that adds or removes an item; no dictionary is built.
lindera-rubyruns through the same RbConfig wrapper asmake test-lindera-ruby, andlindera-wasmis documented forwasm32-unknown-unknown.
mdBook Documentation
Build the user-facing documentation:
mdbook build docs
Preview locally at http://localhost:3000:
mdbook serve docs
Markdown Lint
Check documentation for Markdown style issues:
markdownlint-cli2 "docs/src/**/*.md"
Rules are configured in .markdownlint.json at the repository root.