From a303fc4d834f43bb6721aad21c21fa4e7a4ca02d Mon Sep 17 00:00:00 2001 From: Mattia Penati Date: Tue, 10 Mar 2026 00:45:29 +0100 Subject: [PATCH 1/2] Fix documentation links --- src/array.rs | 7 ++++--- src/borrow/mod.rs | 6 +++--- src/datetime.rs | 2 +- src/dtype.rs | 4 ++-- src/untyped_array.rs | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/array.rs b/src/array.rs index b00e3f01c..0f734c11f 100644 --- a/src/array.rs +++ b/src/array.rs @@ -43,7 +43,7 @@ use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods}; /// These methods transfers ownership of the Rust allocation into a suitable Python object /// and uses the memory as the internal buffer backing the NumPy array. /// -/// Please note that some destructive methods like [`resize`][Self::resize] will fail +/// Please note that some destructive methods like [`resize`][PyArrayMethods::resize] will fail /// when used with this kind of array as NumPy cannot reallocate the internal buffer. /// /// - Allocated by NumPy: Constructed via other methods, like [`ToPyArray`] or @@ -94,6 +94,7 @@ use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods}; /// }); /// ``` /// +/// [`PyObject`]: pyo3::ffi::PyObject /// [ndarray]: https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html /// [pyo3-memory]: https://pyo3.rs/main/memory.html #[repr(transparent)] @@ -183,7 +184,7 @@ impl PyArray { /// into Python's heap, which NumPy will automatically zero-initialize. /// /// However, the elements themselves will not be valid and should be initialized manually - /// using raw pointers obtained via [`uget_raw`][Self::uget_raw]. Before that, all methods + /// using raw pointers obtained via [`uget_raw`][PyArrayMethods::uget_raw]. Before that, all methods /// which produce references to the elements invoke undefined behaviour. In particular, /// zero-initialized pointers are _not_ valid instances of `PyObject`. /// @@ -721,7 +722,7 @@ pub trait PyArrayMethods<'py, T, D>: PyUntypedArrayMethods<'py> + Sized { /// Returns a pointer to the first element of the array. fn data(&self) -> *mut T; - /// Same as [`shape`][PyUntypedArray::shape], but returns `D` instead of `&[usize]`. + /// Same as [`shape`][PyUntypedArrayMethods::shape], but returns `D` instead of `&[usize]`. #[inline(always)] fn dims(&self) -> D where diff --git a/src/borrow/mod.rs b/src/borrow/mod.rs index e29ab2b11..10bf79c60 100644 --- a/src/borrow/mod.rs +++ b/src/borrow/mod.rs @@ -161,7 +161,7 @@ //! //! This does limit the set of programs that can be written using safe Rust in way similar to rustc itself //! which ensures that all accepted programs are memory safe but does not necessarily accept all memory safe programs. -//! However, the unsafe method [`PyArray::as_array_mut`] can be used as an escape hatch. +//! However, the unsafe method [`PyArrayMethods::as_array_mut`] can be used as an escape hatch. //! More involved cases like the example from above may be supported in the future. //! //! [base]: https://numpy.org/doc/stable/reference/c-api/types-and-structures.html#c.NPY_AO.base @@ -529,7 +529,7 @@ where /// /// Calling this will prevent any further [PyReadwriteArray]s from being taken out. Python /// space can reset this flag, unless the additional flag [`OWNDATA`][owndata] is unset. Such - /// an array can be created from Rust space by using [PyArray::borrow_from_array_bound]. + /// an array can be created from Rust space by using [PyArray::borrow_from_array]. /// /// [writeable]: https://numpy.org/doc/stable/reference/c-api/array.html#c.NPY_ARRAY_WRITEABLE /// [owndata]: https://numpy.org/doc/stable/reference/c-api/array.html#c.NPY_ARRAY_OWNDATA @@ -604,7 +604,7 @@ where { /// Extends or truncates the dimensions of an array. /// - /// Safe wrapper for [`PyArray::resize`]. + /// Safe wrapper for [`PyArrayMethods::resize`]. /// /// Note that as this mutates a pointed-to object, the [`PyReadwriteArray`] must be the only /// Python reference to the object. There cannot be `PyArray` pointers or even `Bound` diff --git a/src/datetime.rs b/src/datetime.rs index cdd66b16e..8c1a20d8e 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -171,7 +171,7 @@ impl fmt::Debug for Datetime { } } -/// Corresponds to the [`timedelta64`][scalars-datetime64] scalar type +/// Corresponds to the [`timedelta64`][scalars-timedelta64] scalar type /// /// [scalars-timedelta64]: https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.timedelta64 #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] diff --git a/src/dtype.rs b/src/dtype.rs index b6316161c..3e04de7b9 100644 --- a/src/dtype.rs +++ b/src/dtype.rs @@ -166,7 +166,7 @@ pub trait PyArrayDescrMethods<'py>: Sealed { /// /// Equivalent to [`numpy.dtype.itemsize`][dtype-itemsize]. /// - /// [dtype-itemsiize]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.itemsize.html + /// [dtype-itemsize]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.itemsize.html fn itemsize(&self) -> usize; /// Returns the required alignment (bytes) of this type descriptor according to the compiler. @@ -296,7 +296,7 @@ pub trait PyArrayDescrMethods<'py>: Sealed { /// This method will return an error if this type descriptor is not structured, /// or if it does not contain a field with a given name. /// - /// The list of all names can be found via [`PyArrayDescr::names`]. + /// The list of all names can be found via [`PyArrayDescrMethods::names`]. /// /// Equivalent to retrieving a single item from [`numpy.dtype.fields`][dtype-fields]. /// diff --git a/src/untyped_array.rs b/src/untyped_array.rs index 7293b9119..e49991ea8 100644 --- a/src/untyped_array.rs +++ b/src/untyped_array.rs @@ -234,7 +234,7 @@ pub trait PyUntypedArrayMethods<'py>: Sealed { /// Returns a slice which contains dimensions of the array. /// - /// See also [`ndarray.shape`][ndaray-shape] and [`PyArray_DIMS`][PyArray_DIMS]. + /// See also [`ndarray.shape`][ndarray-shape] and [`PyArray_DIMS`][PyArray_DIMS]. /// /// # Example /// From 267afc64b574e723de366550b4ae3a5e4e67e4d6 Mon Sep 17 00:00:00 2001 From: Mattia Penati Date: Tue, 10 Mar 2026 00:56:33 +0100 Subject: [PATCH 2/2] Check documentation links --- x.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x.py b/x.py index e95014dd6..9970e4565 100755 --- a/x.py +++ b/x.py @@ -7,8 +7,10 @@ from pathlib import Path -def run(*args): - subprocess.run([*args], check=True) +def run(*args, env=None): + if env is not None: + env = {**os.environ, **env} + subprocess.run([*args], check=True, env=env) def can_run(*args): @@ -55,6 +57,7 @@ def default(args): def check(args): + run("cargo", "doc", "--no-deps", env={"RUSTDOCFLAGS": "--deny warnings"}) run("cargo", "fmt", "--", "--check") run("cargo", "clippy", "--all-features", "--tests", "--", *DENY_WARNINGS)