okf_validator/lib.rs
1//! # okf-validator: conformance checking and linting for OKF bundles
2//!
3//! Companion to [`okf-core`](https://docs.rs/okf-core), the pure-Rust
4//! implementation of the [Open Knowledge Format (OKF) v0.2][spec]. This crate
5//! judges bundles; okf-core models them.
6//!
7//! - [`validate`] checks conformance: [`validate_bundle`] reports true spec
8//! violations as [`Severity::Error`], and material data integrity issues,
9//! temporal checks, broken references, contract discrepancies, and script syntax
10//! errors as [`Severity::Warning`] or [`Severity::Info`].
11//! - [`lint`] is the opinionated companion: [`lint_bundle`] evaluates 12
12//! bundle formatting, structure, and authoring hygiene rules, each finding tagged with a stable rule code (`L1`..`L12`).
13//! - [`syntax`] provides in-process syntax checking for Python,
14//! JavaScript, TypeScript, Rust, SQL, JSON, YAML, and Bash.
15//!
16//! Staleness checks depend on the wall clock, so they are opt-in via
17//! [`validate_bundle_at`] and [`lint_bundle_at`], which take the date to
18//! compare against; the plain variants are deterministic.
19//!
20//! Most users get this crate through the [`okf`](https://docs.rs/okf) crate,
21//! which re-exports it alongside okf-core and ships the `okf` CLI.
22//!
23//! ```no_run
24//! use okf_core::Bundle;
25//! use okf_validator::validate_bundle;
26//!
27//! let bundle = Bundle::load("./my_bundle")?;
28//! let report = validate_bundle(&bundle);
29//! if report.is_conformant() {
30//! println!("conformant OKF v0.2 bundle");
31//! }
32//! # Ok::<(), okf_core::BundleError>(())
33//! ```
34//!
35//! [spec]: https://github.com/GoogleCloudPlatform/open-knowledge-format/blob/main/SPEC.md
36
37#![forbid(unsafe_code)]
38#![warn(missing_docs)]
39// Pedantic and nursery lints keep the published crate tidy; the few cases
40// where a lint is genuinely wrong for this codebase are silenced inline with a
41// justification.
42#![warn(clippy::pedantic, clippy::nursery)]
43
44pub mod lint;
45pub mod syntax;
46pub mod validate;
47
48#[doc(inline)]
49pub use lint::{lint_bundle, lint_bundle_at};
50#[doc(inline)]
51pub use syntax::{
52 FencedCodeBlock, Language, SyntaxError, check_syntax, extract_fenced_code_blocks,
53};
54#[doc(inline)]
55pub use validate::{
56 Diagnostic, ParseSeverityError, Report, Severity, validate_bundle, validate_bundle_at,
57};