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..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 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