Skip to content

Commit

Permalink
Improve doc formatting and linking. (#532)
Browse files Browse the repository at this point in the history
* Update to modern intradoc links that are checked by the Rust
  tools.
* Add some missing backticks and links.
* Fix some grammar errors.
* Fix `clippy::doc_markdown` lints.
  • Loading branch information
waywardmonkeys authored Aug 28, 2024
1 parent 9b96ec0 commit 94bbc0a
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 114 deletions.
4 changes: 2 additions & 2 deletions src/angle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<T> Angle<T>
where
T: Float,
{
/// Returns true if the angle is a finite number.
/// Returns `true` if the angle is a finite number.
#[inline]
pub fn is_finite(self) -> bool {
self.radians.is_finite()
Expand All @@ -143,7 +143,7 @@ impl<T> Angle<T>
where
T: Real,
{
/// Returns (sin(self), cos(self)).
/// Returns `(sin(self), cos(self))`.
pub fn sin_cos(self) -> (T, T) {
self.radians.sin_cos()
}
Expand Down
6 changes: 3 additions & 3 deletions src/approxeq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ pub trait ApproxEq<Eps> {
/// Default epsilon value
fn approx_epsilon() -> Eps;

/// Returns `true` is this object is approximately equal to the other one, using
/// Returns `true` if this object is approximately equal to the other one, using
/// a provided epsilon value.
fn approx_eq_eps(&self, other: &Self, approx_epsilon: &Eps) -> bool;

/// Returns `true` is this object is approximately equal to the other one, using
/// the `approx_epsilon()` epsilon value.
/// Returns `true` if this object is approximately equal to the other one, using
/// the [`approx_epsilon`](ApproxEq::approx_epsilon) epsilon value.
fn approx_eq(&self, other: &Self) -> bool {
self.approx_eq_eps(other, &Self::approx_epsilon())
}
Expand Down
31 changes: 19 additions & 12 deletions src/box2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ use core::ops::{Add, Div, DivAssign, Mul, MulAssign, Range, Sub};
/// - it's area is negative (`min.x > max.x` or `min.y > max.y`),
/// - it contains NaNs.
///
/// [`Rect`]: struct.Rect.html
/// [`intersection`]: #method.intersection
/// [`is_empty`]: #method.is_empty
/// [`union`]: #method.union
/// [`size`]: #method.size
/// [`intersection`]: Self::intersection
/// [`is_empty`]: Self::is_empty
/// [`union`]: Self::union
/// [`size`]: Self::size
#[repr(C)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(
Expand Down Expand Up @@ -139,7 +138,7 @@ impl<T, U> Box2D<T, U> {
}
}

/// Creates a Box2D of the given size, at offset zero.
/// Creates a `Box2D` of the given size, at offset zero.
#[inline]
pub fn from_size(size: Size2D<T, U>) -> Self
where
Expand All @@ -156,7 +155,7 @@ impl<T, U> Box2D<T, U>
where
T: PartialOrd,
{
/// Returns true if the box has a negative area.
/// Returns `true` if the box has a negative area.
///
/// The common interpretation for a negative box is to consider it empty. It can be obtained
/// by calculating the intersection of two boxes that do not intersect.
Expand All @@ -165,7 +164,7 @@ where
self.max.x < self.min.x || self.max.y < self.min.y
}

/// Returns true if the size is zero, negative or NaN.
/// Returns `true` if the size is zero, negative or NaN.
#[inline]
pub fn is_empty(&self) -> bool {
!(self.max.x > self.min.x && self.max.y > self.min.y)
Expand Down Expand Up @@ -240,7 +239,7 @@ where
///
/// The result is a negative box if the boxes do not intersect.
/// This can be useful for computing the intersection of more than two boxes, as
/// it is possible to chain multiple intersection_unchecked calls and check for
/// it is possible to chain multiple `intersection_unchecked` calls and check for
/// empty/negative result at the end.
#[inline]
pub fn intersection_unchecked(&self, other: &Self) -> Self {
Expand Down Expand Up @@ -553,7 +552,11 @@ impl<T: NumCast + Copy, U> Box2D<T, U> {
///
/// When casting from floating point to integer coordinates, the decimals are truncated
/// as one would expect from a simple cast, but this behavior does not always make sense
/// geometrically. Consider using round(), round_in or round_out() before casting.
/// geometrically. Consider using [`round`], [`round_in`] or [`round_out`] before casting.
///
/// [`round`]: Self::round
/// [`round_in`]: Self::round_in
/// [`round_out`]: Self::round_out
#[inline]
pub fn cast<NewT: NumCast>(&self) -> Box2D<NewT, U> {
Box2D::new(self.min.cast(), self.max.cast())
Expand All @@ -563,7 +566,11 @@ impl<T: NumCast + Copy, U> Box2D<T, U> {
///
/// When casting from floating point to integer coordinates, the decimals are truncated
/// as one would expect from a simple cast, but this behavior does not always make sense
/// geometrically. Consider using round(), round_in or round_out() before casting.
/// geometrically. Consider using [`round`], [`round_in`] or [`round_out`] before casting.
///
/// [`round`]: Self::round
/// [`round_in`]: Self::round_in
/// [`round_out`]: Self::round_out
pub fn try_cast<NewT: NumCast>(&self) -> Option<Box2D<NewT, U>> {
match (self.min.try_cast(), self.max.try_cast()) {
(Some(a), Some(b)) => Some(Box2D::new(a, b)),
Expand Down Expand Up @@ -627,7 +634,7 @@ impl<T: NumCast + Copy, U> Box2D<T, U> {
}

impl<T: Float, U> Box2D<T, U> {
/// Returns true if all members are finite.
/// Returns `true` if all members are finite.
#[inline]
pub fn is_finite(self) -> bool {
self.min.is_finite() && self.max.is_finite()
Expand Down
20 changes: 14 additions & 6 deletions src/box3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<T, U> Box3D<T, U> {
}
}

/// Creates a Box3D of the given size, at offset zero.
/// Creates a `Box3D` of the given size, at offset zero.
#[inline]
pub fn from_size(size: Size3D<T, U>) -> Self
where
Expand All @@ -130,7 +130,7 @@ impl<T, U> Box3D<T, U>
where
T: PartialOrd,
{
/// Returns true if the box has a negative volume.
/// Returns `true` if the box has a negative volume.
///
/// The common interpretation for a negative box is to consider it empty. It can be obtained
/// by calculating the intersection of two boxes that do not intersect.
Expand All @@ -139,7 +139,7 @@ where
self.max.x < self.min.x || self.max.y < self.min.y || self.max.z < self.min.z
}

/// Returns true if the size is zero, negative or NaN.
/// Returns `true` if the size is zero, negative or NaN.
#[inline]
pub fn is_empty(&self) -> bool {
!(self.max.x > self.min.x && self.max.y > self.min.y && self.max.z > self.min.z)
Expand Down Expand Up @@ -556,7 +556,11 @@ impl<T: NumCast + Copy, U> Box3D<T, U> {
///
/// When casting from floating point to integer coordinates, the decimals are truncated
/// as one would expect from a simple cast, but this behavior does not always make sense
/// geometrically. Consider using round(), round_in or round_out() before casting.
/// geometrically. Consider using [`round`], [`round_in`] or [`round_out`] before casting.
///
/// [`round`]: Self::round
/// [`round_in`]: Self::round_in
/// [`round_out`]: Self::round_out
#[inline]
pub fn cast<NewT: NumCast>(&self) -> Box3D<NewT, U> {
Box3D::new(self.min.cast(), self.max.cast())
Expand All @@ -566,7 +570,11 @@ impl<T: NumCast + Copy, U> Box3D<T, U> {
///
/// When casting from floating point to integer coordinates, the decimals are truncated
/// as one would expect from a simple cast, but this behavior does not always make sense
/// geometrically. Consider using round(), round_in or round_out() before casting.
/// geometrically. Consider using [`round`], [`round_in`] or [`round_out`] before casting.
///
/// [`round`]: Self::round
/// [`round_in`]: Self::round_in
/// [`round_out`]: Self::round_out
pub fn try_cast<NewT: NumCast>(&self) -> Option<Box3D<NewT, U>> {
match (self.min.try_cast(), self.max.try_cast()) {
(Some(a), Some(b)) => Some(Box3D::new(a, b)),
Expand Down Expand Up @@ -630,7 +638,7 @@ impl<T: NumCast + Copy, U> Box3D<T, U> {
}

impl<T: Float, U> Box3D<T, U> {
/// Returns true if all members are finite.
/// Returns `true` if all members are finite.
#[inline]
pub fn is_finite(self) -> bool {
self.min.is_finite() && self.max.is_finite()
Expand Down
4 changes: 2 additions & 2 deletions src/homogen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<T, U> HomogeneousVector<T, U> {
impl<T: Copy + Div<T, Output = T> + Zero + PartialOrd, U> HomogeneousVector<T, U> {
/// Convert into Cartesian 2D point.
///
/// Returns None if the point is on or behind the W=0 hemisphere.
/// Returns `None` if the point is on or behind the W=0 hemisphere.
#[inline]
pub fn to_point2d(self) -> Option<Point2D<T, U>> {
if self.w > T::zero() {
Expand All @@ -155,7 +155,7 @@ impl<T: Copy + Div<T, Output = T> + Zero + PartialOrd, U> HomogeneousVector<T, U

/// Convert into Cartesian 3D point.
///
/// Returns None if the point is on or behind the W=0 hemisphere.
/// Returns `None` if the point is on or behind the W=0 hemisphere.
#[inline]
pub fn to_point3d(self) -> Option<Point3D<T, U>> {
if self.w > T::zero() {
Expand Down
4 changes: 1 addition & 3 deletions src/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
/// expression that requires a different unit. It may be a type without values, such as an empty
/// enum.
///
/// You can multiply a `Length` by a `scale::Scale` to convert it from one unit to
/// You can multiply a `Length` by a [`Scale`] to convert it from one unit to
/// another. See the [`Scale`] docs for an example.
///
/// [`Scale`]: struct.Scale.html
#[repr(C)]
pub struct Length<T, Unit>(pub T, #[doc(hidden)] pub PhantomData<Unit>);

Expand Down
24 changes: 12 additions & 12 deletions src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl<T, U> Point2D<T, U> {
point2(Zero::zero(), Zero::zero())
}

/// The same as [`origin()`](#method.origin).
/// The same as [`Point2D::origin`].
#[inline]
pub fn zero() -> Self
where
Expand Down Expand Up @@ -509,7 +509,7 @@ impl<T: NumCast + Copy, U> Point2D<T, U> {
self.cast()
}

/// Cast into an i32 point, truncating decimals if any.
/// Cast into an `i32` point, truncating decimals if any.
///
/// When casting from floating point points, it is worth considering whether
/// to `round()`, `ceil()` or `floor()` before the cast in order to obtain
Expand All @@ -519,7 +519,7 @@ impl<T: NumCast + Copy, U> Point2D<T, U> {
self.cast()
}

/// Cast into an i64 point, truncating decimals if any.
/// Cast into an `i64` point, truncating decimals if any.
///
/// When casting from floating point points, it is worth considering whether
/// to `round()`, `ceil()` or `floor()` before the cast in order to obtain
Expand All @@ -531,7 +531,7 @@ impl<T: NumCast + Copy, U> Point2D<T, U> {
}

impl<T: Float, U> Point2D<T, U> {
/// Returns true if all members are finite.
/// Returns `true` if all members are finite.
#[inline]
pub fn is_finite(self) -> bool {
self.x.is_finite() && self.y.is_finite()
Expand Down Expand Up @@ -710,23 +710,23 @@ impl<T: Zero, U> Zero for Point2D<T, U> {
}

impl<T: Round, U> Round for Point2D<T, U> {
/// See [Point2D::round()](#method.round)
/// See [`Point2D::round`].
#[inline]
fn round(self) -> Self {
self.round()
}
}

impl<T: Ceil, U> Ceil for Point2D<T, U> {
/// See [Point2D::ceil()](#method.ceil)
/// See [`Point2D::ceil`].
#[inline]
fn ceil(self) -> Self {
self.ceil()
}
}

impl<T: Floor, U> Floor for Point2D<T, U> {
/// See [Point2D::floor()](#method.floor)
/// See [`Point2D::floor`].
#[inline]
fn floor(self) -> Self {
self.floor()
Expand Down Expand Up @@ -944,7 +944,7 @@ impl<T, U> Point3D<T, U> {
point3(Zero::zero(), Zero::zero(), Zero::zero())
}

/// The same as [`origin()`](#method.origin).
/// The same as [`Point3D::origin`].
#[inline]
pub fn zero() -> Self
where
Expand Down Expand Up @@ -1356,7 +1356,7 @@ impl<T: NumCast + Copy, U> Point3D<T, U> {
}

impl<T: Float, U> Point3D<T, U> {
/// Returns true if all members are finite.
/// Returns `true` if all members are finite.
#[inline]
pub fn is_finite(self) -> bool {
self.x.is_finite() && self.y.is_finite() && self.z.is_finite()
Expand Down Expand Up @@ -1551,23 +1551,23 @@ impl<T: Zero, U> Zero for Point3D<T, U> {
}

impl<T: Round, U> Round for Point3D<T, U> {
/// See [Point3D::round()](#method.round)
/// See [`Point3D::round`].
#[inline]
fn round(self) -> Self {
self.round()
}
}

impl<T: Ceil, U> Ceil for Point3D<T, U> {
/// See [Point3D::ceil()](#method.ceil)
/// See [`Point3D::ceil`].
#[inline]
fn ceil(self) -> Self {
self.ceil()
}
}

impl<T: Floor, U> Floor for Point3D<T, U> {
/// See [Point3D::floor()](#method.floor)
/// See [`Point3D::floor`].
#[inline]
fn floor(self) -> Self {
self.floor()
Expand Down
Loading

0 comments on commit 94bbc0a

Please sign in to comment.