Skip to main content

Crate aidoc_core

Crate aidoc_core 

Source
Expand description

§aidoc-core

Core library that turns rustdoc JSON output into LLM-facing documentation artifacts. This crate holds all of the logic shared by the two thin front ends in this workspace: the cargo aidoc subcommand (crates/cargo-aidoc) and the MCP server (crates/aidoc-mcp).

§Architecture

The pipeline is split into three stages:

  1. Index — read rustdoc’s JSON output (produced via cargo +nightly rustdoc -- -Z unstable-options --output-format json) and load it into an in-memory representation of the crate’s public API surface.
  2. Generate — project the index into one or more LLM-facing artifacts: an llms.txt summary, per-crate / per-module narrative markdown, llms-full.txt, and a deterministic api/<crate>.json for machine consumption (diffing, CI checks).
  3. Lint — check the index against a set of doc-coverage rules (crate root has a narrative, public modules are documented, the generated llms-full.txt fits a soft size cap) and report violations.

Both cargo-aidoc (CLI) and aidoc-mcp (MCP server) are thin front ends over this pipeline; neither crate should contain pipeline logic of its own. The single entry point for both is run, which returns a Report of generated artifacts and lint diagnostics.

Re-exports§

pub use config::Config;
pub use config::Platform;
pub use config::Preset;
pub use config::UnknownPlatform;
pub use error::Error;
pub use error::Result;
pub use error_catalog::ErrorEntry;
pub use error_catalog::Snippet;
pub use generate::Artifact;
pub use generate::ArtifactLocation;
pub use index::IndexedCrate;
pub use index::IndexedWorkspace;
pub use lint::Diagnostic;
pub use lint::Level;

Modules§

config
Configuration for the aidoc pipeline.
error
Error type for the aidoc pipeline.
error_catalog
Error-catalog extractor: build an LLM-facing catalog of every diagnostic emitted by the workspace, straight from rustdoc JSON.
generate
Generate stage: project an IndexedWorkspace into LLM-facing artifacts.
index
Indexed representation of a Rust workspace’s public API surface.
lint
Lint stage: report doc-coverage issues on top of an indexed workspace (and, for size-related lints, on top of the generated artifacts).
platform
Platform overlay dispatch: given a Config::platforms list, add the platform-specific artifacts on top of the core docs/aidoc/ output produced by crate::generate::render_all.

Structs§

DiffSummary
Detailed classification of every diff in a check-mode run.
Report
The output of a single pipeline run: everything a front end needs to either write artifacts to disk (cargo aidoc) or compare them to a checked-in tree (cargo aidoc --check).

Functions§

classify_diffs
Compare every artifact in report against its on-disk copy and return the categorised diff. See write_report for how out_dir and workspace_root are interpreted.
diff_report
Backwards-compatible wrapper around classify_diffs. Returns the same flat list of paths that earlier versions of aidoc-core produced; new callers should prefer classify_diffs so they can distinguish missing from modified artifacts.
run
Run the full index → generate → lint pipeline against the workspace rooted at workspace_root, using config for defaults, exclusions and strict-mode toggling.
write_report
Write every artifact in report to disk. out_dir is the base for artifacts whose location is ArtifactLocation::OutDir; the workspace root is the base for ArtifactLocation::WorkspaceRoot artifacts (typically platform manifests such as context7.json).