diff --git a/Cargo.toml b/Cargo.toml index 42f15b8..82e1efb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,19 +27,22 @@ repository = "https://github.com/CosmicHorrorDev/two-face" homepage = "https://github.com/CosmicHorrorDev/two-face" [package.metadata.docs.rs] -all-features = true +features = ["syntect-default-onig"] [features] -# TODO: I don't like having to set this as a default, but `syntect` can't -# compile without a regex impl +# `syntect` can't compile without a regex implementation, so we match it's +# default of onig default = ["syntect-onig"] +# A minimal set of `syntect` features with the onig regex implementation syntect-onig = ["syntect/regex-onig"] +# A minimal set of `syntect` features with the fancy regex implementation syntect-fancy = ["syntect/regex-fancy"] -# Don't like this, but I want to link to the functions provided by this from my -# documentation -unstable = ["syntect/default-syntaxes"] +# Toggles on `syntect`'s `default-onig` feature +syntect-default-onig = ["syntect-onig", "syntect/default-onig"] +# Toggles on `syntect`'s `default-fancy` feature +syntect-default-fancy = ["syntect-fancy", "syntect/default-fancy"] [dependencies] once_cell.workspace = true diff --git a/README.md b/README.md index f556dba..16429bc 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,13 @@ that are missing from the default set like TOML, TypeScript, and Dockerfile The following -```toml -[dependencies] -syntect = "0.5.1" -two-face = "0.2.0" +```cmd +$ cargo add two-face --features syntect-default-onig ``` ```rust +use two_face::re_exports::syntect; + const TOML_TEXT: &str = "\ [section] key = 123 @@ -61,11 +61,11 @@ implementation with the one you're using from syntect To use [`Oniguruma`](https://github.com/kkos/oniguruma) aka onig -```toml +```cmd [dependencies] # `onig` is the default syntect = "0.5.1" -two-face = "0.2.0" +two-face = "0.3.1" ``` To use [`fancy-regex`](https://github.com/fancy-regex/fancy-regex) @@ -73,7 +73,7 @@ To use [`fancy-regex`](https://github.com/fancy-regex/fancy-regex) ```toml [dependencies] syntect = { version = "0.5.1", default-features = false, features = ["default-fancy"] } -two-face = { version = "0.2.0", default-features = false, features = ["syntect-fancy"] } +two-face = { version = "0.3.1", default-features = false, features = ["syntect-fancy"] } ``` ## Legal diff --git a/src/lib.rs b/src/lib.rs index d34e053..7bdc099 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,13 +6,13 @@ //! //! # Example //! -//! ```toml -//! [dependencies] -//! syntect = "0.5.1" -//! two-face = "0.2.0" +//! ```text +//! $ cargo add two-face --features syntect-default-onig //! ``` //! //! ``` +//! use two_face::re_exports::syntect; +//! //! const TOML_TEXT: &str = "\ //! [section] //! key = 123 @@ -53,7 +53,7 @@ //! [dependencies] //! # `onig` is the default //! syntect = "0.5.1" -//! two-face = "0.2.0" +//! two-face = "0.3.1" //! ``` //! //! To use [`fancy-regex`](https://github.com/fancy-regex/fancy-regex) @@ -61,7 +61,7 @@ //! ```toml //! [dependencies] //! syntect = { version = "0.5.1", default-features = false, features = ["default-fancy"] } -//! two-face = { version = "0.2.0", default-features = false, features = ["syntect-fancy"] } +//! two-face = { version = "0.3.1", default-features = false, features = ["syntect-fancy"] } //! ``` #[cfg(doctest)] @@ -72,6 +72,19 @@ pub mod acknowledgement; pub mod syntax; pub mod theme; +/// Dependency re-exports for user's convenience +/// +/// # `syntect` +/// +/// By default `two-face` uses the minimal feature set from `syntect` required for things to work, +/// but the default features can be toggled on with the `syntect-default-onig` and +/// `syntect-default-fancy` feature flags (depending on which syntect regex implementation you're +/// using). If you need more granular features than the ones provided then you should probably +/// depend directly on `syntect` instead +pub mod re_exports { + pub use syntect; +} + // Compile error if we're using syntaxes without setting fancy vs onig #[cfg(not(any(feature = "syntect-onig", feature = "syntect-fancy")))] compile_error!(