Skip to main content

Crate asbuilt_core

Crate asbuilt_core 

Source
Expand description

The language-agnostic core of asbuilt.

A front-end (one per language; asbuilt-rust is the first) reads a code base and produces a Model: elements with ids, kinds, titles and paths, and relations between them labeled with the item names they reference. This crate owns that model, the asbuilt.toml Config that adds what no code can state (externals, the theme, the documentation settings), the .c4 emitter and its reader, the drift check, and the generator of the documentation tree. It never spawns a process.

Re-exports§

pub use check::Change;
pub use check::ElementField;
pub use check::Outcome;
pub use check::compare;
pub use check::summarize;
pub use config::ColorScheme;
pub use config::Config;
pub use config::DocsConfig;
pub use config::External;
pub use config::ExternalRelation;
pub use config::OutputConfig;
pub use config::ThemeColor;
pub use docs::DocsOptions;
pub use docs::Site;
pub use emit::EmitOptions;
pub use emit::emit;
pub use emit::view_ids;
pub use error::Error;
pub use error::Result;
pub use frontend::Frontend;
pub use frontend::survey;
pub use model::Deployment;
pub use model::Element;
pub use model::ElementKind;
pub use model::Id;
pub use model::Model;
pub use model::Relation;
pub use model::RelationKind;
pub use read::Written;
pub use read::WrittenElement;
pub use read::WrittenRelation;
pub use read::read;

Modules§

check
The drift check: the committed model against a fresh survey, as a unified diff when they differ, and as the changes behind it (an element added, a relation’s items) when the committed model is one asbuilt wrote. Line endings are normalized first so a consumer with autocrlf gets a clean check.
config
asbuilt.toml: the release it is written for, the output path, the externals nothing static in the code can state, and every front-end’s own table kept raw for it to parse.
docs
The documentation generator: a Model and the SVGs asbuilt render produced, to a static HTML tree that mounts anywhere. A view LikeC4 drew is inlined into its page (crate::svg) and colored by theme.css (crate::theme) for the system’s light or dark scheme or a visitor’s choice; theme.js, the tree’s one script, carries that choice and is left out when scheme_toggle is off.
emit
The LikeC4 emitter: a Model to the text of one .c4 file.
error
Errors that name the offending input, so a message reads without a rerun.
externals
Externals from asbuilt.toml: elements outside the code (a spawned process, a browser) and the edges from surveyed modules to them. Nothing static in the code states these, so the config does, and a from that names no element is an error rather than a missing edge.
frontend
The front-end contract and the survey that runs every front-end that recognizes a root, merges their models, and applies the config.
model
The architecture model every front-end produces and the emitter consumes.
read
A model asbuilt wrote, read back: the elements and relations in the model block of a .c4 file, as the file spells them. The inverse of emit for the model block it writes, so the drift check can say what changed rather than only which lines did. The specification and views are derived from the model block and are not read.
svg
A rendered view inlined into a page, so the page’s colors reach it.
theme
Diagram colors for the documentation pages. Per element kind, a light and a dark fill come from [theme] (LikeC4’s default blue for a kind with none), and each fill’s text, secondary text and outline are derived from it. theme.css sets them as --c4-<kind>-* variables for the system’s light and dark schemes and for a visitor’s explicit choice (data-theme on the root), then applies them to the nodes of an inlined view. Group boxes, edges and edge labels take their colors from the page tokens (--bg, --fg, --muted), so a host stylesheet that restates those restyles the diagrams with the page.