Expand description
Deterministic, rule-based formatter for the Julia language.
This crate is the formatting engine of the fatou CLI,
extracted so embedders (such as a dprint Wasm plugin) can use it without
the CLI’s filesystem and process machinery. It formats a source string or
an already-parsed fatou_parser CST; batch file walking, caching, and
config discovery stay host-side.
§Main entry points
format()/format_with_style— format a source string.format_verified()/format_verified_with_style— format and prove that the result preserves the parsed program and comments.format_node/format_range— format an already-parsedfatou_parser::syntax::SyntaxNode, whole or a byte range of it.FormatStyle— the layout knobs, withDefaultmatching the fatou CLI’s defaults.verify::verify_format— verify two source strings directly.verify::ast_shape— the formatting-invariant shape of a source string, for checking that formatting preserved the program (ast(x) == ast(format(x))).
The crate is wasm32-unknown-unknown-compatible: no filesystem, process,
thread, or clock use.
§Features
serde—Serialize/DeserializeforFormatStyleandLineEnding, spelled like theirfatou.tomlcounterparts.schema— additionally derivesschemars::JsonSchema, so an embedder (e.g. a dprint plugin) can generate a config schema.
Re-exports§
pub use formatter::FormatError;pub use formatter::FormatOptions;pub use formatter::FormatStyle;pub use formatter::LineEnding;pub use formatter::RangeFormatted;pub use formatter::VerifiedFormatError;pub use formatter::format;pub use formatter::format_node;pub use formatter::format_node_with_options;pub use formatter::format_range;pub use formatter::format_range_with_options;pub use formatter::format_verified;pub use formatter::format_verified_with_options;pub use formatter::format_verified_with_style;pub use formatter::format_with_options;pub use formatter::format_with_style;pub use formatter::print_document;pub use verify::VerificationError;pub use rowan;
Modules§
- formatter
- The formatter: consumes the CST and produces formatted text via a
Wadler/Prettier-style document IR (
ir) printed by a single best-fit layout engine (printer) that makes all line-break decisions. - parser
- Re-export of
fatou_parser::parserso internalcrate::parserpaths resolve unchanged in the sources shared with the fatou CLI. - syntax
- Re-export of
fatou_parser::syntaxso internalcrate::syntaxpaths resolve unchanged in the sources shared with the fatou CLI. - verify
- Formatting-invariant AST shape — the basis of
ast(x) == ast(format(x)).