arity_formatter/lib.rs
1//! Deterministic, rule-based formatter for the R language.
2//!
3//! This crate is the formatting engine of [arity](https://arity.cc),
4//! extracted so that other tools (e.g. a dprint plugin) can embed it. Output
5//! is decided solely by the formatter's rules and its best-fit layout engine;
6//! the input's existing line breaks never influence the result. The target
7//! style is the tidyverse R style guide.
8//!
9//! The primary entry points are [`format`] and [`format_with_style`], configured
10//! via [`FormatStyle`]. Their [`format_verified`] counterparts additionally
11//! check normalized syntax, ordinary comments, and idempotence. With the
12//! `serde` feature, `FormatStyle` is (de)serializable; the `schema` feature
13//! additionally derives `schemars::JsonSchema`.
14//!
15//! A package's `DESCRIPTION` is a second grammar with its own entry point,
16//! [`format_description`]; see [`formatter::description`].
17
18pub mod formatter;
19
20pub mod ast;
21pub mod dcf;
22pub mod parser;
23pub mod syntax;
24
25/// The `rowan` version this crate's CST types are built on.
26///
27/// [`format_range`] takes a `rowan::TextRange`, so an embedder has to be able
28/// to name it. Re-exporting the dependency keeps that caller version-matched
29/// with us instead of making them guess a compatible `rowan` in their own
30/// `Cargo.toml`.
31pub use rowan;
32
33pub use formatter::{
34 DeclineReason, DescriptionFormatError, FormatAnalysis, FormatError, FormatStyle,
35 FormatVerificationError, LineEnding, RangeFormatted, analyze_format_with_options, format,
36 format_description, format_description_with_style, format_node, format_range, format_verified,
37 format_verified_with_options, format_verified_with_style, format_with_options,
38 format_with_style,
39};