From 05ac78d59a1946ce95b62b1e34a00aec03ddc771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9E=97=E4=BC=9F?= Date: Sun, 5 Nov 2023 00:48:13 +0800 Subject: [PATCH] Enable doc test (#222) * Add geo-types dep * Enable doc-test * Remove geo-types dep --- Cargo.toml | 3 +-- src/algorithm/geo/dimensions.rs | 2 +- src/algorithm/geo/minimum_rotated_rect.rs | 2 +- src/array/geometrycollection/array.rs | 10 ++++++---- src/array/linestring/array.rs | 9 +++++---- src/array/multipoint/array.rs | 9 +++++---- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 83020f4f..41e5b3fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,8 +56,7 @@ geozero = { version = "0.11", features = ["with-wkb"] } parquet = "48" [lib] -# TODO: fix docstrings -doctest = false +doctest = true [[example]] name = "gdal" diff --git a/src/algorithm/geo/dimensions.rs b/src/algorithm/geo/dimensions.rs index 72308101..9e7729e9 100644 --- a/src/algorithm/geo/dimensions.rs +++ b/src/algorithm/geo/dimensions.rs @@ -11,7 +11,7 @@ pub trait HasDimensions { /// Types like `Point` and `Rect`, which have at least one coordinate by construction, can /// never be considered empty. /// ``` - /// use geo_types::{Point, coord, LineString}; + /// use geo::{Point, coord, LineString}; /// use geo::HasDimensions; /// /// let line_string = LineString::new(vec![ diff --git a/src/algorithm/geo/minimum_rotated_rect.rs b/src/algorithm/geo/minimum_rotated_rect.rs index 03d6e46f..f46c9813 100644 --- a/src/algorithm/geo/minimum_rotated_rect.rs +++ b/src/algorithm/geo/minimum_rotated_rect.rs @@ -12,7 +12,7 @@ use geo::MinimumRotatedRect as _MinimumRotatedRect; /// # Examples /// /// ``` -/// use geo_types::{line_string, polygon, LineString, Polygon}; +/// use geo::{line_string, polygon, LineString, Polygon}; /// use geo::MinimumRotatedRect; /// let poly: Polygon = polygon![(x: 3.3, y: 30.4), (x: 1.7, y: 24.6), (x: 13.4, y: 25.1), (x: 14.4, y: 31.0),(x:3.3,y:30.4)]; /// let mbr = MinimumRotatedRect::minimum_rotated_rect(&poly).unwrap(); diff --git a/src/array/geometrycollection/array.rs b/src/array/geometrycollection/array.rs index c96f1f15..0ee172b6 100644 --- a/src/array/geometrycollection/array.rs +++ b/src/array/geometrycollection/array.rs @@ -129,12 +129,14 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for GeometryCollectionArray< /// This operation is `O(1)` as it amounts to increase two ref counts. /// # Examples /// ``` - /// use arrow2::array::PrimitiveArray; + /// use arrow::array::PrimitiveArray; + /// use arrow_array::types::Int32Type; /// - /// let array = PrimitiveArray::from_vec(vec![1, 2, 3]); - /// assert_eq!(format!("{:?}", array), "Int32[1, 2, 3]"); + /// let array: PrimitiveArray = PrimitiveArray::from(vec![1, 2, 3]); + /// assert_eq!(format!("{:?}", array), "PrimitiveArray\n[\n 1,\n 2,\n 3,\n]"); /// let sliced = array.slice(1, 1); - /// assert_eq!(format!("{:?}", sliced), "Int32[2]"); + /// assert_eq!(format!("{:?}", sliced), "PrimitiveArray\n[\n 2,\n]"); + /// /// // note: `sliced` and `array` share the same memory region. /// ``` /// # Panic diff --git a/src/array/linestring/array.rs b/src/array/linestring/array.rs index af5b1580..0d71c558 100644 --- a/src/array/linestring/array.rs +++ b/src/array/linestring/array.rs @@ -184,12 +184,13 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for LineStringArray { /// This operation is `O(1)` as it amounts to increase two ref counts. /// # Examples /// ``` - /// use arrow2::array::PrimitiveArray; + /// use arrow::array::PrimitiveArray; + /// use arrow_array::types::Int32Type; /// - /// let array = PrimitiveArray::from_vec(vec![1, 2, 3]); - /// assert_eq!(format!("{:?}", array), "Int32[1, 2, 3]"); + /// let array: PrimitiveArray = PrimitiveArray::from(vec![1, 2, 3]); + /// assert_eq!(format!("{:?}", array), "PrimitiveArray\n[\n 1,\n 2,\n 3,\n]"); /// let sliced = array.slice(1, 1); - /// assert_eq!(format!("{:?}", sliced), "Int32[2]"); + /// assert_eq!(format!("{:?}", sliced), "PrimitiveArray\n[\n 2,\n]"); /// // note: `sliced` and `array` share the same memory region. /// ``` /// # Panic diff --git a/src/array/multipoint/array.rs b/src/array/multipoint/array.rs index 7062dbe1..c2d272c4 100644 --- a/src/array/multipoint/array.rs +++ b/src/array/multipoint/array.rs @@ -182,12 +182,13 @@ impl<'a, O: OffsetSizeTrait> GeometryArrayTrait<'a> for MultiPointArray { /// This operation is `O(1)` as it amounts to increase two ref counts. /// # Examples /// ``` - /// use arrow2::array::PrimitiveArray; + /// use arrow::array::PrimitiveArray; + /// use arrow_array::types::Int32Type; /// - /// let array = PrimitiveArray::from_vec(vec![1, 2, 3]); - /// assert_eq!(format!("{:?}", array), "Int32[1, 2, 3]"); + /// let array: PrimitiveArray = PrimitiveArray::from(vec![1, 2, 3]); + /// assert_eq!(format!("{:?}", array), "PrimitiveArray\n[\n 1,\n 2,\n 3,\n]"); /// let sliced = array.slice(1, 1); - /// assert_eq!(format!("{:?}", sliced), "Int32[2]"); + /// assert_eq!(format!("{:?}", sliced), "PrimitiveArray\n[\n 2,\n]"); /// // note: `sliced` and `array` share the same memory region. /// ``` /// # Panic