Skip to content

doc(kpm): correct stale backend docs + document KPM public API (#226) - #231

Merged
kalwalt merged 3 commits into
devfrom
doc/api-reference-226
Jul 17, 2026
Merged

doc(kpm): correct stale backend docs + document KPM public API (#226)#231
kalwalt merged 3 commits into
devfrom
doc/api-reference-226

Conversation

@kalwalt

@kalwalt kalwalt commented Jul 16, 2026

Copy link
Copy Markdown
Member

First slice of #226, covering the consumer-facing KPM/NFT surface. #226 stays open — the remaining modules are listed below.

The important part: docs that actively misled

Two places documented the pre-M9-3 world and told users the wrong thing:

Both now match reality. The quick start is a real RustFreakMatcherset_ref_data_setkpm_matchingget_pose flow, pointing at simple_nft and WasmKpmHandle; the module-layout table gained the missing freak and rust_backend rows.

Also in this slice

  • 22 missing_docs sites filled across the kpm tree: Point3d, Point2f/Point2i, FeaturePoint, HoughMatch, HoughSimilarityVoting fields, and the pyramid error-variant fields.
  • 2 broken intra-doc links fixed: kpm::KpmRefDataSet::generatekpm::types::KpmRefDataSet::generate, and the feature-gated cpp_backend / CppFreakMatcher links (unresolvable without ffi-backend).
  • #![warn(missing_docs)] on kpm/mod.rs — the KPM tree is now at 100% rustdoc coverage, and CI's clippy -D warnings escalates the lint, so a new undocumented pub item in KPM fails the build.

Remaining for #226 (later slices)

Slice Scope Items
JS/TS WASM integration walkthrough + README cross-links doc
types.rs C-port struct fields 116
ar2/tracking.rs + icp.rs 146
Crate-wide #![warn(missing_docs)] + the 43 remaining broken intra-doc links

Crate-wide missing_docs went 358 → 336; lib.rs and kpm/** are now doc-warning free.

Verification

  • cargo doc — no warnings originating in any touched file
  • cargo fmt --check clean; clippy --all-targets --features simd,log-helpers -D warnings clean
  • cargo test --lib — 432 passed

Note: I couldn't run --all-features locally — bindgen 0.72.1 panics in build.rs on this machine (32-bit libclang vs 64-bit target: left: 4, right: 8). That's a local toolchain issue, not code; CI covers --all-features on Ubuntu.

🤖 Generated with Claude Code

First slice of the #226 documentation pass, covering the consumer-facing
KPM/NFT surface.

Fix docs that actively misled:
- kpm/mod.rs described `ffi-backend` as "(default)" and pure-Rust as
  "(future)" — backwards since M9-3 (#142). Pure Rust is the default and
  needs no C++ toolchain; ffi-backend is opt-in for cross-validation.
  Rewrote the quick start around RustFreakMatcher with a real
  load -> kpm_matching -> get_pose flow, and added the missing `freak` and
  `rust_backend` rows to the module layout table.
- lib.rs recommended `--features ffi-backend` for NFT marker generation;
  since #179 nft_marker_gen produces .iset + .fset + .fset3 entirely in
  pure Rust, so no C++ toolchain is needed.

Fill the 22 missing_docs sites across the kpm tree (Point3d, Point2f/2i,
FeaturePoint, HoughMatch, HoughSimilarityVoting fields, and the pyramid
error-variant fields), and fix two broken intra-doc links in lib.rs /
kpm/mod.rs (KpmRefDataSet path; feature-gated cpp_backend items).

Add `#![warn(missing_docs)]` to kpm/mod.rs: the KPM tree is now at 100%
rustdoc coverage, and CI's `clippy -D warnings` escalates the lint, so a
new undocumented `pub` item there fails the build. Remaining modules
(types.rs, ar2/tracking.rs, icp.rs) are tracked for later slices in #226.

Refs #226

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

#226)

The `#![warn(missing_docs)]` gate added to kpm/mod.rs fires on the
bindgen output included into kpm_ffi's `bindings` module (34 errors under
`--features ffi-backend`, escalated by CI's `clippy -D warnings`). Those
items are generated verbatim from kpm_c_api.h by build.rs, so there is no
source to attach rustdoc to.

Add `#![allow(missing_docs)]` alongside the existing bindgen naming-lint
allows in the same module, with a rationale. The module-level docs already
describe the surface, and consumers are pointed at the safe CppFreakMatcher
wrapper.

Only surfaced in CI: this path needs --features ffi-backend, which cannot
be built locally here (bindgen 0.72.1 panics on a 32-bit libclang vs a
64-bit target).

Refs #226

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kalwalt kalwalt self-assigned this Jul 16, 2026
@kalwalt kalwalt added documentation Improvements or additions to documentation enhancement New feature or request nft kpm labels Jul 16, 2026
@kalwalt kalwalt added this to the Stabilization & DX milestone Jul 16, 2026
@kalwalt kalwalt moved this from Backlog to In progress in Plan to port KPM to rust Jul 16, 2026
…ilure (#226)

Opting into `--features ffi-backend` (or `--all-features` / `dual-mode`)
fails in build.rs with a bindgen panic — `assertion left == right failed`,
`left: 4, right: 8` — when LIBCLANG_PATH points at a libclang built for a
32-bit target. The assertion prints the same triple on both sides, so the
cause is not obvious from the message.

A common trigger on Windows is a cross-compilation toolchain's libclang on
LIBCLANG_PATH, e.g. the Xtensa clang from the esp-rs toolchain (32-bit
ESP32). Add a Troubleshooting section covering the symptom, the cause, and
the per-session fix (point LIBCLANG_PATH at an x86_64 libclang), plus why
we don't ship a .cargo/config.toml [env] override (it would need
force = true and has no per-OS conditionals, so it would break Linux CI).

Also notes that the default build is pure Rust and needs no C++ toolchain
at all — this only affects contributors who opt into the FFI backend.

Refs #226

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kalwalt
kalwalt merged commit f6cb29a into dev Jul 17, 2026
22 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in Plan to port KPM to rust Jul 17, 2026
kalwalt added a commit that referenced this pull request Jul 20, 2026
The npm package (@webarkit/webarkitlib-wasm) shipped with no consumer-facing
usage guide — the README only said "see npm for API docs". Add a full
walkthrough at docs/wasm-js-integration.md covering:

- loading + initializing the module (init / init_wasm / init_panic_hook)
- the standard vs SIMD engines (the package `exports` map) + a runtime probe
- the three handles: WasmARHandle (square markers), WasmKpmHandle (NFT
  detection), WasmNFTHandle (AR2 tracking)
- the NFT detect-then-track loop with the real serialized shapes
  ({ pose, page, error } and { found, matrix, error, cont_num })
- the 3x4 row-major pose-matrix layout, TypeScript usage, memory management
  (free()), and common pitfalls (RGBA length, load-before-detect, etc.)

All snippets are checked against the actual crates/wasm/src/lib.rs API.

Link from the README's WASM section using an absolute GitHub URL so it also
works for consumers reading the README on npmjs.com (only README.md is
published to the package, not docs/). The root README is the source copied
to pkg/README.md by build-dual at build time; pkg/README.md refreshes on the
next `npm run build`.

Second slice of the #226 documentation pass (after the KPM rustdoc slice in
#231).

Refs #226

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request kpm nft

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant