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 24a3571f..ad94d889 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -14,6 +14,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 90a5908a..b97ee66a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,9 @@ #![crate_name = "gdal"] #![crate_type = "lib"] +// 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 be98d64f..9b296136 100644 --- a/src/raster/mdarray.rs +++ b/src/raster/mdarray.rs @@ -226,6 +226,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