Skip to content

Commit 63fdd6b

Browse files
authored
Merge pull request #375 from godot-rust/qol/rustdoc-lints
Enforce rustdoc checks in CI
2 parents 720824a + 558fd9e commit 63fdd6b

File tree

20 files changed

+78
-47
lines changed

20 files changed

+78
-47
lines changed

.github/workflows/full-ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ jobs:
4747
run: cargo fmt --all -- --check
4848

4949

50+
# Needs to be its own job (apart from sync-doc), because lints don't work with --no-deps, and because it contributes to ci-status.
51+
doc-lints:
52+
runs-on: ubuntu-20.04
53+
steps:
54+
- uses: actions/checkout@v3
55+
56+
- name: "Install Rust"
57+
uses: ./.github/composite/rust
58+
with:
59+
components: rustdoc
60+
61+
- name: "Check rustdoc"
62+
env:
63+
RUSTDOCFLAGS: >
64+
-D rustdoc::broken-intra-doc-links -D rustdoc::private-intra-doc-links -D rustdoc::invalid-codeblock-attributes
65+
-D rustdoc::invalid-rust-codeblocks -D rustdoc::invalid-html-tags -D rustdoc::bare-urls -D rustdoc::unescaped-backticks
66+
run: cargo doc -p godot
67+
68+
5069
clippy:
5170
runs-on: ubuntu-20.04
5271
steps:
@@ -299,6 +318,7 @@ jobs:
299318
if: always() && (github.event_name == 'merge_group' || github.event_name == 'push')
300319
needs:
301320
- rustfmt
321+
- doc-lints
302322
- clippy
303323
- unit-test
304324
- godot-itest

.github/workflows/minimal-ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ jobs:
5252
run: cargo fmt --all -- --check
5353

5454

55+
# Needs to be its own job (apart from sync-doc), because lints don't work with --no-deps, and because it contributes to ci-status.
56+
doc-lints:
57+
runs-on: ubuntu-20.04
58+
steps:
59+
- uses: actions/checkout@v3
60+
61+
- name: "Install Rust"
62+
uses: ./.github/composite/rust
63+
with:
64+
components: rustdoc
65+
66+
- name: "Check rustdoc"
67+
env:
68+
RUSTDOCFLAGS: >
69+
-D rustdoc::broken-intra-doc-links -D rustdoc::private-intra-doc-links -D rustdoc::invalid-codeblock-attributes
70+
-D rustdoc::invalid-rust-codeblocks -D rustdoc::invalid-html-tags -D rustdoc::bare-urls -D rustdoc::unescaped-backticks
71+
run: cargo doc -p godot
72+
73+
5574
clippy:
5675
runs-on: ubuntu-20.04
5776
steps:
@@ -201,6 +220,7 @@ jobs:
201220
if: always()
202221
needs:
203222
- rustfmt
223+
- doc-lints
204224
- clippy
205225
- unit-test
206226
- godot-itest

godot-core/src/builtin/array.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ use sys::{ffi_methods, interface_fn, GodotFfi};
3535
/// refer to the same underlying array, and changes to one are visible in the other.
3636
///
3737
/// To create a copy that shares data with the original array, use [`Share::share()`]. If you want
38-
/// to create a copy of the data, use [`duplicate_shallow()`] or [`duplicate_deep()`].
38+
/// to create a copy of the data, use [`duplicate_shallow()`][Self::duplicate_shallow] or
39+
/// [`duplicate_deep()`][Self::duplicate_deep].
3940
///
4041
/// # Thread safety
4142
///
@@ -243,8 +244,8 @@ impl<T: VariantMetadata> Array<T> {
243244
/// Returns a shallow copy of the array. All array elements are copied, but any reference types
244245
/// (such as `Array`, `Dictionary` and `Object`) will still refer to the same value.
245246
///
246-
/// To create a deep copy, use [`duplicate_deep()`] instead. To create a new reference to the
247-
/// same array data, use [`share()`].
247+
/// To create a deep copy, use [`duplicate_deep()`][Self::duplicate_deep] instead.
248+
/// To create a new reference to the same array data, use [`share()`][Share::share].
248249
pub fn duplicate_shallow(&self) -> Self {
249250
let duplicate: VariantArray = self.as_inner().duplicate(false);
250251
// SAFETY: duplicate() returns a typed array with the same type as Self
@@ -255,8 +256,8 @@ impl<T: VariantMetadata> Array<T> {
255256
/// will not be shared with the original array. Note that any `Object`-derived elements will
256257
/// still be shallow copied.
257258
///
258-
/// To create a shallow copy, use [`duplicate_shallow()`] instead. To create a new reference to
259-
/// the same array data, use [`share()`].
259+
/// To create a shallow copy, use [`duplicate_shallow()`][Self::duplicate_shallow] instead.
260+
/// To create a new reference to the same array data, use [`share()`][Share::share].
260261
pub fn duplicate_deep(&self) -> Self {
261262
let duplicate: VariantArray = self.as_inner().duplicate(true);
262263
// SAFETY: duplicate() returns a typed array with the same type as Self
@@ -273,7 +274,7 @@ impl<T: VariantMetadata> Array<T> {
273274
///
274275
/// Array elements are copied to the slice, but any reference types (such as `Array`,
275276
/// `Dictionary` and `Object`) will still refer to the same value. To create a deep copy, use
276-
/// [`subarray_deep()`] instead.
277+
/// [`subarray_deep()`][Self::subarray_deep] instead.
277278
#[doc(alias = "slice")]
278279
pub fn subarray_shallow(&self, begin: usize, end: usize, step: Option<isize>) -> Self {
279280
self.subarray_impl(begin, end, step, false)
@@ -289,7 +290,7 @@ impl<T: VariantMetadata> Array<T> {
289290
///
290291
/// All nested arrays and dictionaries are duplicated and will not be shared with the original
291292
/// array. Note that any `Object`-derived elements will still be shallow copied. To create a
292-
/// shallow copy, use [`subarray_shallow()`] instead.
293+
/// shallow copy, use [`subarray_shallow()`][Self::subarray_shallow] instead.
293294
#[doc(alias = "slice")]
294295
pub fn subarray_deep(&self, begin: usize, end: usize, step: Option<isize>) -> Self {
295296
self.subarray_impl(begin, end, step, true)

godot-core/src/builtin/callable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl Callable {
150150

151151
/// Returns true if this callable has no target to call the method on.
152152
///
153-
/// This is not the negated form of [`is_valid`], as `is_valid` will return `false` if the callable has a
153+
/// This is not the negated form of [`is_valid`][Self::is_valid], as `is_valid` will return `false` if the callable has a
154154
/// target but the method does not exist.
155155
///
156156
/// _Godot equivalent: `is_null`_

godot-core/src/builtin/color.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ impl Color {
242242
}
243243

244244
/// Creates a new color resulting by making this color darker by the specified amount (ratio
245-
/// from 0.0 to 1.0). See also [`lightened`].
245+
/// from 0.0 to 1.0). See also [`lightened`][Self::lightened].
246246
#[must_use]
247247
pub fn darkened(self, amount: f64) -> Self {
248248
self.as_inner().darkened(amount)
249249
}
250250

251251
/// Creates a new color resulting by making this color lighter by the specified amount, which
252-
/// should be a ratio from 0.0 to 1.0. See also [`darken`].
252+
/// should be a ratio from 0.0 to 1.0. See also [`darkened`][Self::darkened].
253253
#[must_use]
254254
pub fn lightened(self, amount: f64) -> Self {
255255
self.as_inner().lightened(amount)

godot-core/src/builtin/math/float.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub trait FloatExt: private::Sealed + Copy {
2525
fn lerp(self, to: Self, weight: Self) -> Self;
2626

2727
/// Check if two angles are approximately equal, by comparing the distance
28-
/// between the points on the unit circle with 0 using [`is_equal_approx`].
28+
/// between the points on the unit circle with 0 using [`real::approx_eq`].
2929
fn is_angle_equal_approx(self, other: Self) -> bool;
3030

3131
/// Check if `self` is within [`Self::CMP_EPSILON`] of `0.0`.
@@ -38,7 +38,7 @@ pub trait FloatExt: private::Sealed + Copy {
3838

3939
/// Godot's `sign` function, returns `0.0` when self is `0.0`.
4040
///
41-
/// See also [`signum`](Self::signum), which always returns `-1.0` or `1.0` (or `NaN`).
41+
/// See also [`f32::signum`] and [`f64::signum`], which always return `-1.0` or `1.0` (or `NaN`).
4242
fn sign(self) -> Self;
4343

4444
/// Returns the derivative at the given `t` on a one-dimensional Bézier curve defined by the given
@@ -69,8 +69,8 @@ pub trait FloatExt: private::Sealed + Copy {
6969
/// Linearly interpolates between two angles (in radians) by a `weight` value
7070
/// between 0.0 and 1.0.
7171
///
72-
/// Similar to [`lerp`], but interpolates correctly when the angles wrap around
73-
/// [`TAU`].
72+
/// Similar to [`lerp`][Self::lerp], but interpolates correctly when the angles wrap around
73+
/// [`TAU`][crate::builtin::real_consts::TAU].
7474
///
7575
/// The resulting angle is not normalized.
7676
///

godot-core/src/builtin/plane.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl Plane {
127127
/// Finds whether a point is inside the plane or not.
128128
///
129129
/// A point is considered part of the plane if its distance to it is less or equal than
130-
/// [`CMP_EPSILON`][crate::builtin::CMP_EPSILON].
130+
/// [`CMP_EPSILON`][FloatExt::CMP_EPSILON].
131131
///
132132
/// _Godot equivalent: `Plane.has_point(Vector3 point, float tolerance=1e-05)`_
133133
#[inline]

godot-core/src/builtin/real.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mod real_mod {
3535
/// This type is `f32` by default, and `f64` when the Cargo feature `double-precision` is enabled.
3636
///
3737
/// This is not the `float` type in GDScript; that type is always 64-bits. Rather, many structs in Godot may use
38-
/// either 32-bit or 64-bit floats, for example [`Vector2`](super::Vector2). To convert between [`real`] and [`f32`] or
38+
/// either 32-bit or 64-bit floats, for example [`Vector2`][crate::builtin::Vector2]. To convert between [`real`] and [`f32`] or
3939
/// [`f64`], see [`RealConv`](super::RealConv).
4040
///
4141
/// See also the [Godot docs on float](https://docs.godotengine.org/en/stable/classes/class_float.html).

godot-core/src/builtin/string/godot_string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl GodotString {
4949

5050
/// Gets the internal chars slice from a [`GodotString`].
5151
///
52-
/// Note: This operation is *O*(*n*). Consider using [`chars_unchecked`]
52+
/// Note: This operation is *O*(*n*). Consider using [`chars_unchecked`][Self::chars_unchecked]
5353
/// if you can make sure the string is a valid UTF-32.
5454
pub fn chars_checked(&self) -> &[char] {
5555
unsafe {

godot-core/src/builtin/transform2d.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ use std::ops::{Mul, MulAssign};
2424
/// [ a.x b.x origin.x ]
2525
/// [ a.y b.y origin.y ]
2626
/// ```
27-
///
28-
/// For methods that don't take translation into account, see [`Basis2D`].
2927
#[derive(Default, Copy, Clone, PartialEq, Debug)]
3028
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3129
#[repr(C)]
@@ -72,7 +70,7 @@ impl Transform2D {
7270

7371
/// Create a new `Transform2D` with the given column vectors.
7472
///
75-
/// _Godot equivalent: `Transform2D(Vector2 x_axis, Vector2 y_axis, Vector2 origin)_
73+
/// _Godot equivalent: `Transform2D(Vector2 x_axis, Vector2 y_axis, Vector2 origin)`_
7674
pub const fn from_cols(a: Vector2, b: Vector2, origin: Vector2) -> Self {
7775
Self { a, b, origin }
7876
}

0 commit comments

Comments
 (0)