diff --git a/cursive-core/Cargo.toml b/cursive-core/Cargo.toml index 0a02d1a..55067e4 100644 --- a/cursive-core/Cargo.toml +++ b/cursive-core/Cargo.toml @@ -12,7 +12,7 @@ version = "0.2.2" edition = "2018" [package.metadata.docs.rs] -features = ["unstable_scroll", "markdown", "toml"] +all-features = true [badges.travis-ci] repository = "gyscos/cursive" @@ -47,8 +47,9 @@ optional = true version = "0.8" [features] +doc-cfg = [] markdown = ["pulldown-cmark"] -unstable_scroll = [] +unstable_scroll = [] # Deprecated feature, remove in next version [lib] name = "cursive_core" diff --git a/cursive-core/src/lib.rs b/cursive-core/src/lib.rs index dcb2251..22b7a07 100644 --- a/cursive-core/src/lib.rs +++ b/cursive-core/src/lib.rs @@ -8,6 +8,8 @@ //! //! [`cursive`]: https://docs.rs/cursive #![deny(missing_docs)] +#![cfg_attr(feature = "doc-cfg", feature(doc_cfg))] + macro_rules! new_default( ($c:ident<$t:ident>) => { impl<$t> Default for $c<$t> { diff --git a/cursive-core/src/theme/mod.rs b/cursive-core/src/theme/mod.rs index b43a62b..61ebd2f 100644 --- a/cursive-core/src/theme/mod.rs +++ b/cursive-core/src/theme/mod.rs @@ -242,6 +242,7 @@ impl Default for Theme { impl Theme { #[cfg(feature = "toml")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))] fn load_toml(&mut self, table: &toml::value::Table) { if let Some(&toml::Value::Boolean(shadow)) = table.get("shadow") { self.shadow = shadow; @@ -264,11 +265,13 @@ pub enum Error { Io(io::Error), #[cfg(feature = "toml")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))] /// An error occured when parsing the toml content. Parse(toml::de::Error), } #[cfg(feature = "toml")] +#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))] impl From for Error { fn from(err: io::Error) -> Self { Error::Io(err) @@ -276,16 +279,18 @@ impl From for Error { } #[cfg(feature = "toml")] +#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))] impl From for Error { fn from(err: toml::de::Error) -> Self { Error::Parse(err) } } -#[cfg(feature = "toml")] /// Loads a theme from file. /// /// Must have the `toml` feature enabled. +#[cfg(feature = "toml")] +#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))] pub fn load_theme_file>(filename: P) -> Result { let content = { let mut content = String::new(); @@ -301,6 +306,7 @@ pub fn load_theme_file>(filename: P) -> Result { /// /// Must have the `toml` feature enabled. #[cfg(feature = "toml")] +#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))] pub fn load_toml(content: &str) -> Result { let table = toml::de::from_str(content)?; diff --git a/cursive-core/src/utils/markup/markdown.rs b/cursive-core/src/utils/markup/markdown.rs index b3e60cc..da96eaa 100644 --- a/cursive-core/src/utils/markup/markdown.rs +++ b/cursive-core/src/utils/markup/markdown.rs @@ -1,6 +1,8 @@ //! Parse markdown text. //! //! Needs the `markdown` feature to be enabled. +#![cfg(feature = "markdown")] +#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "markdown")))] use std::borrow::Cow; diff --git a/cursive-core/src/utils/markup/mod.rs b/cursive-core/src/utils/markup/mod.rs index 2f80884..d1f08da 100644 --- a/cursive-core/src/utils/markup/mod.rs +++ b/cursive-core/src/utils/markup/mod.rs @@ -2,7 +2,6 @@ //! //! Each module is optional and relies on a feature. -#[cfg(feature = "markdown")] pub mod markdown; use crate::theme::Style; diff --git a/cursive-core/src/view/mod.rs b/cursive-core/src/view/mod.rs index dce8d2c..164f82c 100644 --- a/cursive-core/src/view/mod.rs +++ b/cursive-core/src/view/mod.rs @@ -91,16 +91,17 @@ mod size_cache; mod size_constraint; mod view_trait; -// Helper bases -mod nameable; -mod resizable; #[macro_use] pub mod scroll; -mod scroll_base; +// Helper bases +mod into_boxed_view; +mod nameable; +mod resizable; mod scrollable; -mod into_boxed_view; +// That one is deprecated +mod scroll_base; pub use self::any::AnyView; pub use self::finder::{Finder, Selector}; diff --git a/cursive-core/src/view/scroll/mod.rs b/cursive-core/src/view/scroll/mod.rs index 0c66073..34d21a2 100644 --- a/cursive-core/src/view/scroll/mod.rs +++ b/cursive-core/src/view/scroll/mod.rs @@ -1,7 +1,6 @@ //! Core mechanisms to implement scrolling. //! //! *This module is still unstable and may go through breaking changes.* -//! In addition, it is private unless you enable the `unstable_scroll` feature. //! //! This modules defines: //! diff --git a/cursive/Cargo.toml b/cursive/Cargo.toml index cec2b75..d276904 100644 --- a/cursive/Cargo.toml +++ b/cursive/Cargo.toml @@ -12,7 +12,7 @@ version = "0.16.4-alpha.0" edition = "2018" [package.metadata.docs.rs] -features = ["unstable_scroll", "markdown", "toml"] +all-features = true [dependencies] cursive_core = { path = "../cursive-core", version= "0.2.2"} @@ -50,6 +50,7 @@ optional = true version = "0.19" [features] +doc-cfg = ["cursive_core/doc-cfg"] # Enable doc_cfg, a nightly-only doc feature. blt-backend = ["bear-lib-terminal"] default = ["ncurses-backend"] ncurses-backend = ["ncurses", "maplit", "term_size"] @@ -57,7 +58,7 @@ pancurses-backend = ["pancurses", "maplit", "term_size"] termion-backend = ["termion"] crossterm-backend = ["crossterm"] markdown = ["cursive_core/markdown"] -unstable_scroll = ["cursive_core/unstable_scroll"] +unstable_scroll = [] # Deprecated feature, remove in next version toml = ["cursive_core/toml"] [lib] diff --git a/cursive/src/backends/blt.rs b/cursive/src/backends/blt.rs index acc6735..4e7d5d9 100644 --- a/cursive/src/backends/blt.rs +++ b/cursive/src/backends/blt.rs @@ -2,6 +2,7 @@ //! //! Requires the `blt-backend` feature. #![cfg(feature = "bear-lib-terminal")] +#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "blt-backend")))] pub use bear_lib_terminal; diff --git a/cursive/src/backends/crossterm.rs b/cursive/src/backends/crossterm.rs index 1d38f70..06b650d 100644 --- a/cursive/src/backends/crossterm.rs +++ b/cursive/src/backends/crossterm.rs @@ -1,8 +1,8 @@ //! Backend using the pure-rust crossplatform crossterm library. //! //! Requires the `crossterm-backend` feature. - #![cfg(feature = "crossterm")] +#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "crossterm-backend")))] use std::{ cell::{Cell, RefCell, RefMut}, diff --git a/cursive/src/backends/curses/n.rs b/cursive/src/backends/curses/n.rs index 8c089bc..a3d941f 100644 --- a/cursive/src/backends/curses/n.rs +++ b/cursive/src/backends/curses/n.rs @@ -1,5 +1,6 @@ //! Ncurses-specific backend. #![cfg(feature = "ncurses-backend")] +#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "ncurses-backend")))] pub use ncurses; use log::{debug, warn}; diff --git a/cursive/src/backends/curses/pan.rs b/cursive/src/backends/curses/pan.rs index 2d33521..9b3d317 100644 --- a/cursive/src/backends/curses/pan.rs +++ b/cursive/src/backends/curses/pan.rs @@ -1,5 +1,6 @@ //! Pancuses-specific backend. #![cfg(feature = "pancurses-backend")] +#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "pancurses-backend")))] pub use pancurses; diff --git a/cursive/src/backends/termion.rs b/cursive/src/backends/termion.rs index 442d6fa..084b46e 100644 --- a/cursive/src/backends/termion.rs +++ b/cursive/src/backends/termion.rs @@ -2,6 +2,7 @@ //! //! Requires the `termion-backend` feature. #![cfg(feature = "termion")] +#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "termion-backend")))] pub use termion; diff --git a/cursive/src/cursive_ext.rs b/cursive/src/cursive_ext.rs index 74b8bf0..516357c 100644 --- a/cursive/src/cursive_ext.rs +++ b/cursive/src/cursive_ext.rs @@ -37,22 +37,27 @@ pub trait CursiveExt { /// Creates a new Cursive root using a ncurses backend. #[cfg(feature = "ncurses-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "ncurses-backend")))] fn run_ncurses(&mut self) -> std::io::Result<()>; /// Creates a new Cursive root using a pancurses backend. #[cfg(feature = "pancurses-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "pancurses-backend")))] fn run_pancurses(&mut self) -> std::io::Result<()>; /// Creates a new Cursive root using a termion backend. #[cfg(feature = "termion-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "termion-backend")))] fn run_termion(&mut self) -> std::io::Result<()>; /// Creates a new Cursive root using a crossterm backend. #[cfg(feature = "crossterm-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "crossterm-backend")))] fn run_crossterm(&mut self) -> Result<(), crossterm::ErrorKind>; /// Creates a new Cursive root using a bear-lib-terminal backend. #[cfg(feature = "blt-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "blt-backend")))] fn run_blt(&mut self); } @@ -77,26 +82,31 @@ impl CursiveExt for cursive_core::Cursive { } #[cfg(feature = "ncurses-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "curses-backend")))] fn run_ncurses(&mut self) -> std::io::Result<()> { self.try_run_with(crate::backends::curses::n::Backend::init) } #[cfg(feature = "pancurses-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "pancurses-backend")))] fn run_pancurses(&mut self) -> std::io::Result<()> { self.try_run_with(crate::backends::curses::pan::Backend::init) } #[cfg(feature = "termion-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "termion-backend")))] fn run_termion(&mut self) -> std::io::Result<()> { self.try_run_with(crate::backends::termion::Backend::init) } #[cfg(feature = "crossterm-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "crossterm-backend")))] fn run_crossterm(&mut self) -> Result<(), crossterm::ErrorKind> { self.try_run_with(crate::backends::crossterm::Backend::init) } #[cfg(feature = "blt-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "blt-backend")))] fn run_blt(&mut self) { self.run_with(crate::backends::blt::Backend::init) } diff --git a/cursive/src/cursive_runnable.rs b/cursive/src/cursive_runnable.rs index 192cd28..51bfb54 100644 --- a/cursive/src/cursive_runnable.rs +++ b/cursive/src/cursive_runnable.rs @@ -140,6 +140,7 @@ impl CursiveRunnable { /// /// _Requires the `ncurses-backend` feature._ #[cfg(feature = "ncurses-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "ncurses-backend")))] pub fn ncurses() -> Self { Self::new(backends::curses::n::Backend::init) } @@ -148,6 +149,7 @@ impl CursiveRunnable { /// /// _Requires the `panncurses-backend` feature._ #[cfg(feature = "pancurses-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "pancurses-backend")))] pub fn pancurses() -> Self { Self::new(backends::curses::pan::Backend::init) } @@ -156,6 +158,7 @@ impl CursiveRunnable { /// /// _Requires the `termion-backend` feature._ #[cfg(feature = "termion-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "termion-backend")))] pub fn termion() -> Self { Self::new(backends::termion::Backend::init) } @@ -164,6 +167,7 @@ impl CursiveRunnable { /// /// _Requires the `crossterm-backend` feature._ #[cfg(feature = "crossterm-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "crossterm-backend")))] pub fn crossterm() -> Self { Self::new(backends::crossterm::Backend::init) } @@ -172,6 +176,7 @@ impl CursiveRunnable { /// /// _Requires the `blt-backend` feature._ #[cfg(feature = "blt-backend")] + #[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "blt-backend")))] pub fn blt() -> Self { Self::new::(|| { Ok(backends::blt::Backend::init()) diff --git a/cursive/src/lib.rs b/cursive/src/lib.rs index 8d12d3a..939e4f8 100644 --- a/cursive/src/lib.rs +++ b/cursive/src/lib.rs @@ -63,6 +63,7 @@ //! //! [`cursive::theme`]: ./theme/index.html #![deny(missing_docs)] +#![cfg_attr(feature = "doc-cfg", feature(doc_cfg))] pub use cursive_core::*; @@ -96,30 +97,35 @@ pub fn default() -> CursiveRunnable { /// Creates a new Cursive root using a ncurses backend. #[cfg(feature = "ncurses-backend")] +#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "ncurses-backend")))] pub fn ncurses() -> CursiveRunnable { CursiveRunnable::ncurses() } /// Creates a new Cursive root using a pancurses backend. #[cfg(feature = "pancurses-backend")] +#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "pancurses-backend")))] pub fn pancurses() -> CursiveRunnable { CursiveRunnable::pancurses() } /// Creates a new Cursive root using a termion backend. #[cfg(feature = "termion-backend")] +#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "termion-backend")))] pub fn termion() -> CursiveRunnable { CursiveRunnable::termion() } /// Creates a new Cursive root using a crossterm backend. #[cfg(feature = "crossterm-backend")] +#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "crossterm-backend")))] pub fn crossterm() -> CursiveRunnable { CursiveRunnable::crossterm() } /// Creates a new Cursive root using a bear-lib-terminal backend. #[cfg(feature = "blt-backend")] +#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "blt-backend")))] pub fn blt() -> CursiveRunnable { CursiveRunnable::blt() }