Skip to content

Commit

Permalink
Merge pull request #553 from jonaspleyer/patch-doc_cfg
Browse files Browse the repository at this point in the history
docs - annotate objects who depend on features
  • Loading branch information
AaronErhardt authored Feb 27, 2024
2 parents bb25570 + fa5bfb5 commit b42a78e
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plotters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,8 @@ wasm-bindgen-test = "0.3.24"
name = "benchmark"
harness = false
path = "benches/main.rs"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "doc_cfg"]

1 change: 1 addition & 0 deletions plotters/src/coord/ranged1d/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(feature = "chrono")]
mod datetime;
#[cfg(feature = "chrono")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "chrono")))]
pub use datetime::{
IntoMonthly, IntoYearly, Monthly, RangedDate, RangedDateTime, RangedDuration, Yearly,
};
Expand Down
4 changes: 4 additions & 0 deletions plotters/src/element/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,25 @@ pub use composable::{ComposedElement, EmptyElement};
#[cfg(feature = "candlestick")]
mod candlestick;
#[cfg(feature = "candlestick")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "candlestick")))]
pub use candlestick::CandleStick;

#[cfg(feature = "errorbar")]
mod errorbar;
#[cfg(feature = "errorbar")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "errorbar")))]
pub use errorbar::{ErrorBar, ErrorBarOrientH, ErrorBarOrientV};

#[cfg(feature = "boxplot")]
mod boxplot;
#[cfg(feature = "boxplot")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "boxplot")))]
pub use boxplot::Boxplot;

#[cfg(feature = "bitmap_backend")]
mod image;
#[cfg(feature = "bitmap_backend")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "bitmap_backend")))]
pub use self::image::BitMapElement;

mod dynelem;
Expand Down
2 changes: 2 additions & 0 deletions plotters/src/evcxr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use plotters_backend::DrawingBackend;
use plotters_svg::SVGBackend;

#[cfg(feature = "evcxr_bitmap")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "evcxr_bitmap")))]
use plotters_bitmap::BitMapBackend;

/// The wrapper for the generated SVG
Expand Down Expand Up @@ -47,6 +48,7 @@ pub fn evcxr_figure<

/// Start drawing an evcxr figure
#[cfg(feature = "evcxr_bitmap")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "evcxr_bitmap")))]
pub fn evcxr_bitmap_figure<
Draw: FnOnce(DrawingArea<BitMapBackend, Shift>) -> Result<(), Box<dyn std::error::Error>>,
>(
Expand Down
21 changes: 21 additions & 0 deletions plotters/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(missing_docs)]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
/*!
# Plotters - A Rust drawing library focusing on data plotting for both WASM and native applications 🦀📈🚀
Expand Down Expand Up @@ -796,12 +797,14 @@ pub mod style;

/// Evaluation Context for Rust. See [the evcxr crate](https://crates.io/crates/evcxr) for more information.
#[cfg(feature = "evcxr")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "evcxr")))]
pub mod evcxr;

#[cfg(test)]
pub use crate::drawing::{check_color, create_mocked_drawing_area};

#[cfg(feature = "palette_ext")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "palette_ext")))]
pub use palette;

/// The module imports the most commonly used types and modules in Plotters
Expand All @@ -825,6 +828,7 @@ pub mod prelude {
pub use crate::coord::combinators::LogRange;

#[cfg(feature = "chrono")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "chrono")))]
pub use crate::coord::types::{
IntoMonthly, IntoYearly, RangedDate, RangedDateTime, RangedDuration,
};
Expand All @@ -836,23 +840,30 @@ pub mod prelude {

// Series helpers
#[cfg(feature = "area_series")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "area_series")))]
pub use crate::series::AreaSeries;
#[cfg(feature = "histogram")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "histogram")))]
pub use crate::series::Histogram;
#[cfg(feature = "point_series")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "point_series")))]
pub use crate::series::PointSeries;
#[cfg(feature = "surface_series")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "surface_series")))]
pub use crate::series::SurfaceSeries;
#[cfg(feature = "line_series")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "line_series")))]
pub use crate::series::{DashedLineSeries, DottedLineSeries, LineSeries};

// Styles
pub use crate::style::{BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, TRANSPARENT, WHITE, YELLOW};

#[cfg(feature = "full_palette")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "full_palette")))]
pub use crate::style::full_palette;

#[cfg(feature = "colormaps")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "colormaps")))]
pub use crate::style::colors::colormaps::*;

pub use crate::style::{
Expand All @@ -868,20 +879,25 @@ pub mod prelude {
};

#[cfg(feature = "boxplot")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "boxplot")))]
pub use crate::element::Boxplot;
#[cfg(feature = "candlestick")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "candlestick")))]
pub use crate::element::CandleStick;
#[cfg(feature = "errorbar")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "errorbar")))]
pub use crate::element::ErrorBar;

#[cfg(feature = "bitmap_backend")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "bitmap_backend")))]
pub use crate::element::BitMapElement;

// Data
pub use crate::data::Quartiles;

// TODO: This should be deprecated and completely removed
#[cfg(feature = "deprecated_items")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "deprecated_items")))]
#[allow(deprecated)]
pub use crate::element::Path;

Expand All @@ -893,25 +909,30 @@ pub mod prelude {
Result<T, crate::drawing::DrawingAreaErrorKind<D::ErrorType>>;

#[cfg(feature = "evcxr")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "evcxr")))]
pub use crate::evcxr::evcxr_figure;

// Re-export tier 1 backends for backward compatibility
#[cfg(feature = "bitmap_backend")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "bitmap_backend")))]
pub use plotters_bitmap::BitMapBackend;

#[cfg(feature = "svg_backend")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "svg_backend")))]
pub use plotters_svg::SVGBackend;
}

/// This module contains some useful re-export of backend related types.
pub mod backend {
pub use plotters_backend::DrawingBackend;
#[cfg(feature = "bitmap_backend")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "bitmap_backend")))]
pub use plotters_bitmap::{
bitmap_pixel::{BGRXPixel, PixelFormat, RGBPixel},
BitMapBackend,
};
#[cfg(feature = "svg_backend")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "svg_backend")))]
pub use plotters_svg::SVGBackend;
}

Expand Down
5 changes: 5 additions & 0 deletions plotters/src/series/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ mod point_series;
mod surface;

#[cfg(feature = "area_series")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "area_series")))]
pub use area_series::AreaSeries;
#[cfg(feature = "histogram")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "histogram")))]
pub use histogram::Histogram;
#[cfg(feature = "line_series")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "line_series")))]
pub use line_series::{DashedLineSeries, DottedLineSeries, LineSeries};
#[cfg(feature = "point_series")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "point_series")))]
pub use point_series::PointSeries;
#[cfg(feature = "surface_series")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "surface_series")))]
pub use surface::SurfaceSeries;
2 changes: 2 additions & 0 deletions plotters/src/style/colors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ define_color!(MAGENTA, 255, 0, 255, "Magenta");
define_color!(TRANSPARENT, 0, 0, 0, 0.0, "Transparent");

#[cfg(feature = "colormaps")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "colormaps")))]
/// Colormaps can be used to simply go from a scalar value to a color value which will be more/less
/// intense corresponding to the value of the supplied scalar.
/// These colormaps can also be defined by the user and be used with lower and upper bounds.
pub mod colormaps;
#[cfg(feature = "full_palette")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "full_palette")))]
pub mod full_palette;
1 change: 1 addition & 0 deletions plotters/src/style/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub use color::{Color, HSLColor, PaletteColor, RGBAColor, RGBColor};
pub use colors::{BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, TRANSPARENT, WHITE, YELLOW};

#[cfg(feature = "full_palette")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "full_palette")))]
pub use colors::full_palette;

#[cfg(all(not(target_arch = "wasm32"), feature = "ab_glyph"))]
Expand Down

0 comments on commit b42a78e

Please sign in to comment.