Include non-default-features items in docs.rs

This commit is contained in:
Alexandre Bury 2021-04-10 23:34:05 -07:00
parent 4b1efa4ec2
commit eb9f1b1a81
16 changed files with 49 additions and 13 deletions

View File

@ -12,7 +12,7 @@ version = "0.2.2"
edition = "2018" edition = "2018"
[package.metadata.docs.rs] [package.metadata.docs.rs]
features = ["unstable_scroll", "markdown", "toml"] all-features = true
[badges.travis-ci] [badges.travis-ci]
repository = "gyscos/cursive" repository = "gyscos/cursive"
@ -47,8 +47,9 @@ optional = true
version = "0.8" version = "0.8"
[features] [features]
doc-cfg = []
markdown = ["pulldown-cmark"] markdown = ["pulldown-cmark"]
unstable_scroll = [] unstable_scroll = [] # Deprecated feature, remove in next version
[lib] [lib]
name = "cursive_core" name = "cursive_core"

View File

@ -8,6 +8,8 @@
//! //!
//! [`cursive`]: https://docs.rs/cursive //! [`cursive`]: https://docs.rs/cursive
#![deny(missing_docs)] #![deny(missing_docs)]
#![cfg_attr(feature = "doc-cfg", feature(doc_cfg))]
macro_rules! new_default( macro_rules! new_default(
($c:ident<$t:ident>) => { ($c:ident<$t:ident>) => {
impl<$t> Default for $c<$t> { impl<$t> Default for $c<$t> {

View File

@ -242,6 +242,7 @@ impl Default for Theme {
impl Theme { impl Theme {
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))]
fn load_toml(&mut self, table: &toml::value::Table) { fn load_toml(&mut self, table: &toml::value::Table) {
if let Some(&toml::Value::Boolean(shadow)) = table.get("shadow") { if let Some(&toml::Value::Boolean(shadow)) = table.get("shadow") {
self.shadow = shadow; self.shadow = shadow;
@ -264,11 +265,13 @@ pub enum Error {
Io(io::Error), Io(io::Error),
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))]
/// An error occured when parsing the toml content. /// An error occured when parsing the toml content.
Parse(toml::de::Error), Parse(toml::de::Error),
} }
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))]
impl From<io::Error> for Error { impl From<io::Error> for Error {
fn from(err: io::Error) -> Self { fn from(err: io::Error) -> Self {
Error::Io(err) Error::Io(err)
@ -276,16 +279,18 @@ impl From<io::Error> for Error {
} }
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))]
impl From<toml::de::Error> for Error { impl From<toml::de::Error> for Error {
fn from(err: toml::de::Error) -> Self { fn from(err: toml::de::Error) -> Self {
Error::Parse(err) Error::Parse(err)
} }
} }
#[cfg(feature = "toml")]
/// Loads a theme from file. /// Loads a theme from file.
/// ///
/// Must have the `toml` feature enabled. /// Must have the `toml` feature enabled.
#[cfg(feature = "toml")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))]
pub fn load_theme_file<P: AsRef<Path>>(filename: P) -> Result<Theme, Error> { pub fn load_theme_file<P: AsRef<Path>>(filename: P) -> Result<Theme, Error> {
let content = { let content = {
let mut content = String::new(); let mut content = String::new();
@ -301,6 +306,7 @@ pub fn load_theme_file<P: AsRef<Path>>(filename: P) -> Result<Theme, Error> {
/// ///
/// Must have the `toml` feature enabled. /// Must have the `toml` feature enabled.
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "toml")))]
pub fn load_toml(content: &str) -> Result<Theme, Error> { pub fn load_toml(content: &str) -> Result<Theme, Error> {
let table = toml::de::from_str(content)?; let table = toml::de::from_str(content)?;

View File

@ -1,6 +1,8 @@
//! Parse markdown text. //! Parse markdown text.
//! //!
//! Needs the `markdown` feature to be enabled. //! Needs the `markdown` feature to be enabled.
#![cfg(feature = "markdown")]
#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "markdown")))]
use std::borrow::Cow; use std::borrow::Cow;

View File

@ -2,7 +2,6 @@
//! //!
//! Each module is optional and relies on a feature. //! Each module is optional and relies on a feature.
#[cfg(feature = "markdown")]
pub mod markdown; pub mod markdown;
use crate::theme::Style; use crate::theme::Style;

View File

@ -91,16 +91,17 @@ mod size_cache;
mod size_constraint; mod size_constraint;
mod view_trait; mod view_trait;
// Helper bases
mod nameable;
mod resizable;
#[macro_use] #[macro_use]
pub mod scroll; pub mod scroll;
mod scroll_base; // Helper bases
mod into_boxed_view;
mod nameable;
mod resizable;
mod scrollable; mod scrollable;
mod into_boxed_view; // That one is deprecated
mod scroll_base;
pub use self::any::AnyView; pub use self::any::AnyView;
pub use self::finder::{Finder, Selector}; pub use self::finder::{Finder, Selector};

View File

@ -1,7 +1,6 @@
//! Core mechanisms to implement scrolling. //! Core mechanisms to implement scrolling.
//! //!
//! *This module is still unstable and may go through breaking changes.* //! *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: //! This modules defines:
//! //!

View File

@ -12,7 +12,7 @@ version = "0.16.4-alpha.0"
edition = "2018" edition = "2018"
[package.metadata.docs.rs] [package.metadata.docs.rs]
features = ["unstable_scroll", "markdown", "toml"] all-features = true
[dependencies] [dependencies]
cursive_core = { path = "../cursive-core", version= "0.2.2"} cursive_core = { path = "../cursive-core", version= "0.2.2"}
@ -50,6 +50,7 @@ optional = true
version = "0.19" version = "0.19"
[features] [features]
doc-cfg = ["cursive_core/doc-cfg"] # Enable doc_cfg, a nightly-only doc feature.
blt-backend = ["bear-lib-terminal"] blt-backend = ["bear-lib-terminal"]
default = ["ncurses-backend"] default = ["ncurses-backend"]
ncurses-backend = ["ncurses", "maplit", "term_size"] ncurses-backend = ["ncurses", "maplit", "term_size"]
@ -57,7 +58,7 @@ pancurses-backend = ["pancurses", "maplit", "term_size"]
termion-backend = ["termion"] termion-backend = ["termion"]
crossterm-backend = ["crossterm"] crossterm-backend = ["crossterm"]
markdown = ["cursive_core/markdown"] markdown = ["cursive_core/markdown"]
unstable_scroll = ["cursive_core/unstable_scroll"] unstable_scroll = [] # Deprecated feature, remove in next version
toml = ["cursive_core/toml"] toml = ["cursive_core/toml"]
[lib] [lib]

View File

@ -2,6 +2,7 @@
//! //!
//! Requires the `blt-backend` feature. //! Requires the `blt-backend` feature.
#![cfg(feature = "bear-lib-terminal")] #![cfg(feature = "bear-lib-terminal")]
#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "blt-backend")))]
pub use bear_lib_terminal; pub use bear_lib_terminal;

View File

@ -1,8 +1,8 @@
//! Backend using the pure-rust crossplatform crossterm library. //! Backend using the pure-rust crossplatform crossterm library.
//! //!
//! Requires the `crossterm-backend` feature. //! Requires the `crossterm-backend` feature.
#![cfg(feature = "crossterm")] #![cfg(feature = "crossterm")]
#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "crossterm-backend")))]
use std::{ use std::{
cell::{Cell, RefCell, RefMut}, cell::{Cell, RefCell, RefMut},

View File

@ -1,5 +1,6 @@
//! Ncurses-specific backend. //! Ncurses-specific backend.
#![cfg(feature = "ncurses-backend")] #![cfg(feature = "ncurses-backend")]
#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "ncurses-backend")))]
pub use ncurses; pub use ncurses;
use log::{debug, warn}; use log::{debug, warn};

View File

@ -1,5 +1,6 @@
//! Pancuses-specific backend. //! Pancuses-specific backend.
#![cfg(feature = "pancurses-backend")] #![cfg(feature = "pancurses-backend")]
#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "pancurses-backend")))]
pub use pancurses; pub use pancurses;

View File

@ -2,6 +2,7 @@
//! //!
//! Requires the `termion-backend` feature. //! Requires the `termion-backend` feature.
#![cfg(feature = "termion")] #![cfg(feature = "termion")]
#![cfg_attr(feature = "doc-cfg", doc(cfg(feature = "termion-backend")))]
pub use termion; pub use termion;

View File

@ -37,22 +37,27 @@ pub trait CursiveExt {
/// Creates a new Cursive root using a ncurses backend. /// Creates a new Cursive root using a ncurses backend.
#[cfg(feature = "ncurses-backend")] #[cfg(feature = "ncurses-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "ncurses-backend")))]
fn run_ncurses(&mut self) -> std::io::Result<()>; fn run_ncurses(&mut self) -> std::io::Result<()>;
/// Creates a new Cursive root using a pancurses backend. /// Creates a new Cursive root using a pancurses backend.
#[cfg(feature = "pancurses-backend")] #[cfg(feature = "pancurses-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "pancurses-backend")))]
fn run_pancurses(&mut self) -> std::io::Result<()>; fn run_pancurses(&mut self) -> std::io::Result<()>;
/// Creates a new Cursive root using a termion backend. /// Creates a new Cursive root using a termion backend.
#[cfg(feature = "termion-backend")] #[cfg(feature = "termion-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "termion-backend")))]
fn run_termion(&mut self) -> std::io::Result<()>; fn run_termion(&mut self) -> std::io::Result<()>;
/// Creates a new Cursive root using a crossterm backend. /// Creates a new Cursive root using a crossterm backend.
#[cfg(feature = "crossterm-backend")] #[cfg(feature = "crossterm-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "crossterm-backend")))]
fn run_crossterm(&mut self) -> Result<(), crossterm::ErrorKind>; fn run_crossterm(&mut self) -> Result<(), crossterm::ErrorKind>;
/// Creates a new Cursive root using a bear-lib-terminal backend. /// Creates a new Cursive root using a bear-lib-terminal backend.
#[cfg(feature = "blt-backend")] #[cfg(feature = "blt-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "blt-backend")))]
fn run_blt(&mut self); fn run_blt(&mut self);
} }
@ -77,26 +82,31 @@ impl CursiveExt for cursive_core::Cursive {
} }
#[cfg(feature = "ncurses-backend")] #[cfg(feature = "ncurses-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "curses-backend")))]
fn run_ncurses(&mut self) -> std::io::Result<()> { fn run_ncurses(&mut self) -> std::io::Result<()> {
self.try_run_with(crate::backends::curses::n::Backend::init) self.try_run_with(crate::backends::curses::n::Backend::init)
} }
#[cfg(feature = "pancurses-backend")] #[cfg(feature = "pancurses-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "pancurses-backend")))]
fn run_pancurses(&mut self) -> std::io::Result<()> { fn run_pancurses(&mut self) -> std::io::Result<()> {
self.try_run_with(crate::backends::curses::pan::Backend::init) self.try_run_with(crate::backends::curses::pan::Backend::init)
} }
#[cfg(feature = "termion-backend")] #[cfg(feature = "termion-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "termion-backend")))]
fn run_termion(&mut self) -> std::io::Result<()> { fn run_termion(&mut self) -> std::io::Result<()> {
self.try_run_with(crate::backends::termion::Backend::init) self.try_run_with(crate::backends::termion::Backend::init)
} }
#[cfg(feature = "crossterm-backend")] #[cfg(feature = "crossterm-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "crossterm-backend")))]
fn run_crossterm(&mut self) -> Result<(), crossterm::ErrorKind> { fn run_crossterm(&mut self) -> Result<(), crossterm::ErrorKind> {
self.try_run_with(crate::backends::crossterm::Backend::init) self.try_run_with(crate::backends::crossterm::Backend::init)
} }
#[cfg(feature = "blt-backend")] #[cfg(feature = "blt-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "blt-backend")))]
fn run_blt(&mut self) { fn run_blt(&mut self) {
self.run_with(crate::backends::blt::Backend::init) self.run_with(crate::backends::blt::Backend::init)
} }

View File

@ -140,6 +140,7 @@ impl CursiveRunnable {
/// ///
/// _Requires the `ncurses-backend` feature._ /// _Requires the `ncurses-backend` feature._
#[cfg(feature = "ncurses-backend")] #[cfg(feature = "ncurses-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "ncurses-backend")))]
pub fn ncurses() -> Self { pub fn ncurses() -> Self {
Self::new(backends::curses::n::Backend::init) Self::new(backends::curses::n::Backend::init)
} }
@ -148,6 +149,7 @@ impl CursiveRunnable {
/// ///
/// _Requires the `panncurses-backend` feature._ /// _Requires the `panncurses-backend` feature._
#[cfg(feature = "pancurses-backend")] #[cfg(feature = "pancurses-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "pancurses-backend")))]
pub fn pancurses() -> Self { pub fn pancurses() -> Self {
Self::new(backends::curses::pan::Backend::init) Self::new(backends::curses::pan::Backend::init)
} }
@ -156,6 +158,7 @@ impl CursiveRunnable {
/// ///
/// _Requires the `termion-backend` feature._ /// _Requires the `termion-backend` feature._
#[cfg(feature = "termion-backend")] #[cfg(feature = "termion-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "termion-backend")))]
pub fn termion() -> Self { pub fn termion() -> Self {
Self::new(backends::termion::Backend::init) Self::new(backends::termion::Backend::init)
} }
@ -164,6 +167,7 @@ impl CursiveRunnable {
/// ///
/// _Requires the `crossterm-backend` feature._ /// _Requires the `crossterm-backend` feature._
#[cfg(feature = "crossterm-backend")] #[cfg(feature = "crossterm-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "crossterm-backend")))]
pub fn crossterm() -> Self { pub fn crossterm() -> Self {
Self::new(backends::crossterm::Backend::init) Self::new(backends::crossterm::Backend::init)
} }
@ -172,6 +176,7 @@ impl CursiveRunnable {
/// ///
/// _Requires the `blt-backend` feature._ /// _Requires the `blt-backend` feature._
#[cfg(feature = "blt-backend")] #[cfg(feature = "blt-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "blt-backend")))]
pub fn blt() -> Self { pub fn blt() -> Self {
Self::new::<std::convert::Infallible, _>(|| { Self::new::<std::convert::Infallible, _>(|| {
Ok(backends::blt::Backend::init()) Ok(backends::blt::Backend::init())

View File

@ -63,6 +63,7 @@
//! //!
//! [`cursive::theme`]: ./theme/index.html //! [`cursive::theme`]: ./theme/index.html
#![deny(missing_docs)] #![deny(missing_docs)]
#![cfg_attr(feature = "doc-cfg", feature(doc_cfg))]
pub use cursive_core::*; pub use cursive_core::*;
@ -96,30 +97,35 @@ pub fn default() -> CursiveRunnable {
/// Creates a new Cursive root using a ncurses backend. /// Creates a new Cursive root using a ncurses backend.
#[cfg(feature = "ncurses-backend")] #[cfg(feature = "ncurses-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "ncurses-backend")))]
pub fn ncurses() -> CursiveRunnable { pub fn ncurses() -> CursiveRunnable {
CursiveRunnable::ncurses() CursiveRunnable::ncurses()
} }
/// Creates a new Cursive root using a pancurses backend. /// Creates a new Cursive root using a pancurses backend.
#[cfg(feature = "pancurses-backend")] #[cfg(feature = "pancurses-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "pancurses-backend")))]
pub fn pancurses() -> CursiveRunnable { pub fn pancurses() -> CursiveRunnable {
CursiveRunnable::pancurses() CursiveRunnable::pancurses()
} }
/// Creates a new Cursive root using a termion backend. /// Creates a new Cursive root using a termion backend.
#[cfg(feature = "termion-backend")] #[cfg(feature = "termion-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "termion-backend")))]
pub fn termion() -> CursiveRunnable { pub fn termion() -> CursiveRunnable {
CursiveRunnable::termion() CursiveRunnable::termion()
} }
/// Creates a new Cursive root using a crossterm backend. /// Creates a new Cursive root using a crossterm backend.
#[cfg(feature = "crossterm-backend")] #[cfg(feature = "crossterm-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "crossterm-backend")))]
pub fn crossterm() -> CursiveRunnable { pub fn crossterm() -> CursiveRunnable {
CursiveRunnable::crossterm() CursiveRunnable::crossterm()
} }
/// Creates a new Cursive root using a bear-lib-terminal backend. /// Creates a new Cursive root using a bear-lib-terminal backend.
#[cfg(feature = "blt-backend")] #[cfg(feature = "blt-backend")]
#[cfg_attr(feature = "doc-cfg", doc(cfg(feature = "blt-backend")))]
pub fn blt() -> CursiveRunnable { pub fn blt() -> CursiveRunnable {
CursiveRunnable::blt() CursiveRunnable::blt()
} }