Skip to content

Commit b42a78e

Browse files
authored
Merge pull request #553 from jonaspleyer/patch-doc_cfg
docs - annotate objects who depend on features
2 parents bb25570 + fa5bfb5 commit b42a78e

File tree

8 files changed

+41
-0
lines changed

8 files changed

+41
-0
lines changed

plotters/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,8 @@ wasm-bindgen-test = "0.3.24"
132132
name = "benchmark"
133133
harness = false
134134
path = "benches/main.rs"
135+
136+
[package.metadata.docs.rs]
137+
all-features = true
138+
rustdoc-args = ["--cfg", "doc_cfg"]
139+

plotters/src/coord/ranged1d/types/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#[cfg(feature = "chrono")]
22
mod datetime;
33
#[cfg(feature = "chrono")]
4+
#[cfg_attr(doc_cfg, doc(cfg(feature = "chrono")))]
45
pub use datetime::{
56
IntoMonthly, IntoYearly, Monthly, RangedDate, RangedDateTime, RangedDuration, Yearly,
67
};

plotters/src/element/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,25 @@ pub use composable::{ComposedElement, EmptyElement};
175175
#[cfg(feature = "candlestick")]
176176
mod candlestick;
177177
#[cfg(feature = "candlestick")]
178+
#[cfg_attr(doc_cfg, doc(cfg(feature = "candlestick")))]
178179
pub use candlestick::CandleStick;
179180

180181
#[cfg(feature = "errorbar")]
181182
mod errorbar;
182183
#[cfg(feature = "errorbar")]
184+
#[cfg_attr(doc_cfg, doc(cfg(feature = "errorbar")))]
183185
pub use errorbar::{ErrorBar, ErrorBarOrientH, ErrorBarOrientV};
184186

185187
#[cfg(feature = "boxplot")]
186188
mod boxplot;
187189
#[cfg(feature = "boxplot")]
190+
#[cfg_attr(doc_cfg, doc(cfg(feature = "boxplot")))]
188191
pub use boxplot::Boxplot;
189192

190193
#[cfg(feature = "bitmap_backend")]
191194
mod image;
192195
#[cfg(feature = "bitmap_backend")]
196+
#[cfg_attr(doc_cfg, doc(cfg(feature = "bitmap_backend")))]
193197
pub use self::image::BitMapElement;
194198

195199
mod dynelem;

plotters/src/evcxr.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use plotters_backend::DrawingBackend;
44
use plotters_svg::SVGBackend;
55

66
#[cfg(feature = "evcxr_bitmap")]
7+
#[cfg_attr(doc_cfg, doc(cfg(feature = "evcxr_bitmap")))]
78
use plotters_bitmap::BitMapBackend;
89

910
/// The wrapper for the generated SVG
@@ -47,6 +48,7 @@ pub fn evcxr_figure<
4748

4849
/// Start drawing an evcxr figure
4950
#[cfg(feature = "evcxr_bitmap")]
51+
#[cfg_attr(doc_cfg, doc(cfg(feature = "evcxr_bitmap")))]
5052
pub fn evcxr_bitmap_figure<
5153
Draw: FnOnce(DrawingArea<BitMapBackend, Shift>) -> Result<(), Box<dyn std::error::Error>>,
5254
>(

plotters/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![warn(missing_docs)]
2+
#![cfg_attr(doc_cfg, feature(doc_cfg))]
23
/*!
34
45
# Plotters - A Rust drawing library focusing on data plotting for both WASM and native applications 🦀📈🚀
@@ -796,12 +797,14 @@ pub mod style;
796797

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

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

804806
#[cfg(feature = "palette_ext")]
807+
#[cfg_attr(doc_cfg, doc(cfg(feature = "palette_ext")))]
805808
pub use palette;
806809

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

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

837841
// Series helpers
838842
#[cfg(feature = "area_series")]
843+
#[cfg_attr(doc_cfg, doc(cfg(feature = "area_series")))]
839844
pub use crate::series::AreaSeries;
840845
#[cfg(feature = "histogram")]
846+
#[cfg_attr(doc_cfg, doc(cfg(feature = "histogram")))]
841847
pub use crate::series::Histogram;
842848
#[cfg(feature = "point_series")]
849+
#[cfg_attr(doc_cfg, doc(cfg(feature = "point_series")))]
843850
pub use crate::series::PointSeries;
844851
#[cfg(feature = "surface_series")]
852+
#[cfg_attr(doc_cfg, doc(cfg(feature = "surface_series")))]
845853
pub use crate::series::SurfaceSeries;
846854
#[cfg(feature = "line_series")]
855+
#[cfg_attr(doc_cfg, doc(cfg(feature = "line_series")))]
847856
pub use crate::series::{DashedLineSeries, DottedLineSeries, LineSeries};
848857

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

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

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

858869
pub use crate::style::{
@@ -868,20 +879,25 @@ pub mod prelude {
868879
};
869880

870881
#[cfg(feature = "boxplot")]
882+
#[cfg_attr(doc_cfg, doc(cfg(feature = "boxplot")))]
871883
pub use crate::element::Boxplot;
872884
#[cfg(feature = "candlestick")]
885+
#[cfg_attr(doc_cfg, doc(cfg(feature = "candlestick")))]
873886
pub use crate::element::CandleStick;
874887
#[cfg(feature = "errorbar")]
888+
#[cfg_attr(doc_cfg, doc(cfg(feature = "errorbar")))]
875889
pub use crate::element::ErrorBar;
876890

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

880895
// Data
881896
pub use crate::data::Quartiles;
882897

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

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

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

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

902920
#[cfg(feature = "svg_backend")]
921+
#[cfg_attr(doc_cfg, doc(cfg(feature = "svg_backend")))]
903922
pub use plotters_svg::SVGBackend;
904923
}
905924

906925
/// This module contains some useful re-export of backend related types.
907926
pub mod backend {
908927
pub use plotters_backend::DrawingBackend;
909928
#[cfg(feature = "bitmap_backend")]
929+
#[cfg_attr(doc_cfg, doc(cfg(feature = "bitmap_backend")))]
910930
pub use plotters_bitmap::{
911931
bitmap_pixel::{BGRXPixel, PixelFormat, RGBPixel},
912932
BitMapBackend,
913933
};
914934
#[cfg(feature = "svg_backend")]
935+
#[cfg_attr(doc_cfg, doc(cfg(feature = "svg_backend")))]
915936
pub use plotters_svg::SVGBackend;
916937
}
917938

plotters/src/series/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ mod point_series;
2222
mod surface;
2323

2424
#[cfg(feature = "area_series")]
25+
#[cfg_attr(doc_cfg, doc(cfg(feature = "area_series")))]
2526
pub use area_series::AreaSeries;
2627
#[cfg(feature = "histogram")]
28+
#[cfg_attr(doc_cfg, doc(cfg(feature = "histogram")))]
2729
pub use histogram::Histogram;
2830
#[cfg(feature = "line_series")]
31+
#[cfg_attr(doc_cfg, doc(cfg(feature = "line_series")))]
2932
pub use line_series::{DashedLineSeries, DottedLineSeries, LineSeries};
3033
#[cfg(feature = "point_series")]
34+
#[cfg_attr(doc_cfg, doc(cfg(feature = "point_series")))]
3135
pub use point_series::PointSeries;
3236
#[cfg(feature = "surface_series")]
37+
#[cfg_attr(doc_cfg, doc(cfg(feature = "surface_series")))]
3338
pub use surface::SurfaceSeries;

plotters/src/style/colors/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ define_color!(MAGENTA, 255, 0, 255, "Magenta");
5757
define_color!(TRANSPARENT, 0, 0, 0, 0.0, "Transparent");
5858

5959
#[cfg(feature = "colormaps")]
60+
#[cfg_attr(doc_cfg, doc(cfg(feature = "colormaps")))]
6061
/// Colormaps can be used to simply go from a scalar value to a color value which will be more/less
6162
/// intense corresponding to the value of the supplied scalar.
6263
/// These colormaps can also be defined by the user and be used with lower and upper bounds.
6364
pub mod colormaps;
6465
#[cfg(feature = "full_palette")]
66+
#[cfg_attr(doc_cfg, doc(cfg(feature = "full_palette")))]
6567
pub mod full_palette;

plotters/src/style/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub use color::{Color, HSLColor, PaletteColor, RGBAColor, RGBColor};
1515
pub use colors::{BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, TRANSPARENT, WHITE, YELLOW};
1616

1717
#[cfg(feature = "full_palette")]
18+
#[cfg_attr(doc_cfg, doc(cfg(feature = "full_palette")))]
1819
pub use colors::full_palette;
1920

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

0 commit comments

Comments
 (0)