From 8d628eecef27e3f4267fd2c0baf4d907e5b89438 Mon Sep 17 00:00:00 2001 From: "Simeon H.K. Fitch" Date: Fri, 2 Sep 2022 19:35:18 -0400 Subject: [PATCH 1/2] Enabled docs.rs feature gate flag rendering. --- Cargo.toml | 7 +++++++ src/errors.rs | 1 + src/lib.rs | 3 +++ src/raster/mdarray.rs | 1 + src/raster/rasterband.rs | 2 ++ 5 files changed, 14 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 3b526268..2b31def1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,3 +35,10 @@ trybuild = "1.0" [workspace] members = ["gdal-sys"] + +# docs.rs-specific configuration +[package.metadata.docs.rs] +# include `array` feature in documentation +features = ["array"] +# define attribute `docsrs` for feature badges +rustdoc-args = ["--cfg", "docsrs"] \ No newline at end of file diff --git a/src/errors.rs b/src/errors.rs index 7a081f9b..41acff3f 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -16,6 +16,7 @@ pub enum GdalError { #[error("StrUtf8Error")] StrUtf8Error(#[from] std::str::Utf8Error), #[cfg(feature = "ndarray")] + #[cfg_attr(docsrs, doc(cfg(feature = "array")))] #[error("NdarrayShapeError")] NdarrayShapeError(#[from] ndarray::ShapeError), #[error("CPL error class: '{class:?}', error number: '{number}', error msg: '{msg}'")] diff --git a/src/lib.rs b/src/lib.rs index 6eed654d..83c5c8e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,6 +171,9 @@ //! ... //! ``` +// Enable `doc_cfg` features when `docsrs` is defined by docs.rs config +#![cfg_attr(docsrs, feature(doc_cfg))] + pub use version::version_info; pub mod config; diff --git a/src/raster/mdarray.rs b/src/raster/mdarray.rs index cff58f66..ecc822ba 100644 --- a/src/raster/mdarray.rs +++ b/src/raster/mdarray.rs @@ -229,6 +229,7 @@ impl<'a> MDArray<'a> { } #[cfg(feature = "ndarray")] + #[cfg_attr(docsrs, doc(cfg(feature = "array")))] /// Read a 'Array2' from this band. T implements 'GdalType'. /// /// # Arguments diff --git a/src/raster/rasterband.rs b/src/raster/rasterband.rs index 46d41d9d..80c02a37 100644 --- a/src/raster/rasterband.rs +++ b/src/raster/rasterband.rs @@ -311,6 +311,7 @@ impl<'a> RasterBand<'a> { } #[cfg(feature = "ndarray")] + #[cfg_attr(docsrs, doc(cfg(feature = "array")))] /// Read a 'Array2' from this band. T implements 'GdalType'. /// /// # Arguments @@ -348,6 +349,7 @@ impl<'a> RasterBand<'a> { } #[cfg(feature = "ndarray")] + #[cfg_attr(docsrs, doc(cfg(feature = "array")))] /// Read a 'Array2' from a 'Dataset' block. T implements 'GdalType' /// # Arguments /// * block_index - the block index From 9001832ab1d175d390386f2de21e70fdb4d9a0c5 Mon Sep 17 00:00:00 2001 From: "Simeon H.K. Fitch" Date: Fri, 2 Sep 2022 19:42:39 -0400 Subject: [PATCH 2/2] cargo fmt --- src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 83c5c8e0..dc9aac4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,7 @@ #![crate_name = "gdal"] #![crate_type = "lib"] +// Enable `doc_cfg` features when `docsrs` is defined by docs.rs config +#![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] //! ## Examples @@ -171,9 +173,6 @@ //! ... //! ``` -// Enable `doc_cfg` features when `docsrs` is defined by docs.rs config -#![cfg_attr(docsrs, feature(doc_cfg))] - pub use version::version_info; pub mod config;