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
}

godot-core/src/builtin/transform3d.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ impl Transform3D {
6161

6262
/// Create a new transform from a [`Basis`] and a [`Vector3`].
6363
///
64-
/// _Godot equivalent: Transform3D(Basis basis, Vector3 origin)_
64+
/// _Godot equivalent: `Transform3D(Basis basis, Vector3 origin)`_
6565
pub const fn new(basis: Basis, origin: Vector3) -> Self {
6666
Self { basis, origin }
6767
}
6868

6969
/// Create a new transform from 4 matrix-columns.
7070
///
71-
/// _Godot equivalent: Transform3D(Vector3 x_axis, Vector3 y_axis, Vector3 z_axis, Vector3 origin)_
71+
/// _Godot equivalent: `Transform3D(Vector3 x_axis, Vector3 y_axis, Vector3 z_axis, Vector3 origin)`_
7272
pub const fn from_cols(a: Vector3, b: Vector3, c: Vector3, origin: Vector3) -> Self {
7373
Self {
7474
basis: Basis::from_cols(a, b, c),
@@ -79,7 +79,7 @@ impl Transform3D {
7979
/// Constructs a Transform3d from a Projection by trimming the last row of
8080
/// the projection matrix.
8181
///
82-
/// _Godot equivalent: Transform3D(Projection from)_
82+
/// _Godot equivalent: `Transform3D(Projection from)`_
8383
pub fn from_projection(proj: Projection) -> Self {
8484
let a = Vector3::new(proj.cols[0].x, proj.cols[0].y, proj.cols[0].z);
8585
let b = Vector3::new(proj.cols[1].x, proj.cols[1].y, proj.cols[1].z);
@@ -112,17 +112,13 @@ impl Transform3D {
112112

113113
/// Returns the inverse of the transform, under the assumption that the
114114
/// transformation is composed of rotation, scaling and translation.
115-
///
116-
/// _Godot equivalent: Transform3D.affine_inverse()_
117115
#[must_use]
118116
pub fn affine_inverse(self) -> Self {
119117
self.glam(|aff| aff.inverse())
120118
}
121119

122120
/// Returns a transform interpolated between this transform and another by
123121
/// a given weight (on the range of 0.0 to 1.0).
124-
///
125-
/// _Godot equivalent: Transform3D.interpolate_with()_
126122
#[must_use]
127123
pub fn interpolate_with(self, other: Self, weight: real) -> Self {
128124
let src_scale = self.basis.scale();
@@ -142,10 +138,8 @@ impl Transform3D {
142138
}
143139
}
144140

145-
/// Returns `true if this transform is finite by calling `is_finite` on the
141+
/// Returns true if this transform is finite by calling `is_finite` on the
146142
/// basis and origin.
147-
///
148-
/// _Godot equivalent: Transform3D.is_finite()_
149143
pub fn is_finite(&self) -> bool {
150144
self.basis.is_finite() && self.origin.is_finite()
151145
}
@@ -154,8 +148,6 @@ impl Transform3D {
154148
/// points towards the `target` position.
155149
///
156150
/// See [`Basis::new_looking_at()`] for more information.
157-
///
158-
/// _Godot equivalent: Transform3D.looking_at()_
159151
#[cfg(before_api = "4.1")]
160152
#[must_use]
161153
pub fn looking_at(self, target: Vector3, up: Vector3) -> Self {

godot-core/src/builtin/vectors/vector2i.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use std::fmt;
2020
///
2121
/// It uses integer coordinates and is therefore preferable to [`Vector2`] when exact precision is
2222
/// required. Note that the values are limited to 32 bits, and unlike [`Vector2`] this cannot be
23-
/// configured with an engine build option. Use `i64` or [`PackedInt64Array`] if 64-bit values are
24-
/// needed.
23+
/// configured with an engine build option. Use `i64` or [`PackedInt64Array`][crate::builtin::PackedInt64Array]
24+
/// if 64-bit values are needed.
2525
#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
2626
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2727
#[repr(C)]

godot-core/src/builtin/vectors/vector3i.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use crate::builtin::{real, RVec3, Vector3, Vector3Axis};
2020
///
2121
/// It uses integer coordinates and is therefore preferable to [`Vector3`] when exact precision is
2222
/// required. Note that the values are limited to 32 bits, and unlike [`Vector3`] this cannot be
23-
/// configured with an engine build option. Use `i64` or [`PackedInt64Array`] if 64-bit values are
24-
/// needed.
23+
/// configured with an engine build option. Use `i64` or [`PackedInt64Array`][crate::builtin::PackedInt64Array]
24+
/// if 64-bit values are needed.
2525
#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
2626
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2727
#[repr(C)]

godot-core/src/builtin/vectors/vector4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Vector4 {
5555
Self::new(v, v, v, v)
5656
}
5757

58-
/// Constructs a new `Vector3` from a [`Vector3i`].
58+
/// Constructs a new `Vector3` from a [`Vector3i`][crate::builtin::Vector3i].
5959
pub const fn from_vector4i(v: Vector4i) -> Self {
6060
Self {
6161
x: v.x as real,

godot-core/src/builtin/vectors/vector4i.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use std::fmt;
1818
///
1919
/// It uses integer coordinates and is therefore preferable to [`Vector4`] when exact precision is
2020
/// required. Note that the values are limited to 32 bits, and unlike [`Vector4`] this cannot be
21-
/// configured with an engine build option. Use `i64` or [`PackedInt64Array`] if 64-bit values are
22-
/// needed.
21+
/// configured with an engine build option. Use `i64` or [`PackedInt64Array`][crate::builtin::PackedInt64Array]
22+
/// if 64-bit values are needed.
2323
#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
2424
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2525
#[repr(C)]

godot-core/src/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ where
151151
///
152152
/// If the resource cannot be loaded, or is not of type `T` or inherited, this method returns `None`.
153153
///
154-
/// This method is a simplified version of [`ResourceLoader::load()`][crate::api::ResourceLoader::load],
154+
/// This method is a simplified version of [`ResourceLoader::load()`][crate::engine::ResourceLoader::load],
155155
/// which can be used for more advanced scenarios.
156156
///
157157
/// # Note:

godot-core/src/obj/gd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ impl<T: GodotClass> Gd<T> {
267267
/// ⚠️ Returns the instance ID of this object, or `None` if no instance ID is cached.
268268
///
269269
/// This function does not check that the returned instance ID points to a valid instance!
270-
/// Unless performance is a problem, use [`instance_id_or_none`].
270+
/// Unless performance is a problem, use [`instance_id_or_none`][Self::instance_id_or_none] instead.
271271
pub fn instance_id_or_none_unchecked(&self) -> Option<InstanceId> {
272272
self.cached_instance_id.get()
273273
}

godot-ffi/src/compat/compat_4_1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! The extension entry point is passed `get_proc_address` function pointer, which can be used to load all other
1010
//! GDExtension FFI functions dynamically. This is a departure from the previous struct-based approach.
1111
//!
12-
//! Relevant upstream PR: https://github.com/godotengine/godot/pull/76406
12+
//! Relevant upstream PR: <https://github.com/godotengine/godot/pull/76406>.
1313
1414
use crate as sys;
1515
use crate::compat::BindingCompat;

godot-ffi/src/godot_ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pub enum PtrcallType {
241241
/// To get a `GDExtensionObjectPtr` from a `GDExtensionRefPtr`, you must use `ref_get_object`, and to
242242
/// set a `GDExtensionRefPtr` to some object, you must use `ref_set_object`.
243243
///
244-
/// See also https://github.com/godotengine/godot-cpp/issues/954.
244+
/// See also <https://github.com/godotengine/godot-cpp/issues/954>.
245245
Virtual,
246246
}
247247

godot-macros/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ pub fn derive_native_class(input: TokenStream) -> TokenStream {
402402
translate(input, derive_godot_class::transform)
403403
}
404404

405-
/// Derive macro for [ToVariant](godot::builtin::ToVariant) on structs or enums.
405+
/// Derive macro for [ToVariant](../builtin/trait.ToVariant.html) on structs or enums.
406406
///
407407
/// # Example
408408
///
@@ -435,7 +435,7 @@ pub fn derive_to_variant(input: TokenStream) -> TokenStream {
435435
translate(input, derive_to_variant::transform)
436436
}
437437

438-
/// Derive macro for [FromVariant](godot::builtin::FromVariant) on structs or enums.
438+
/// Derive macro for [FromVariant](../builtin/trait.FromVariant.html) on structs or enums.
439439
///
440440
/// # Example
441441
///
@@ -469,7 +469,7 @@ pub fn derive_from_variant(input: TokenStream) -> TokenStream {
469469
translate(input, derive_from_variant::transform)
470470
}
471471

472-
/// Derive macro for [Property](godot::bind::property::Property) on enums.
472+
/// Derive macro for [Property](../bind/property/trait.Property.html) on enums.
473473
///
474474
/// Currently has some tight requirements which are expected to be softened as implementation expands:
475475
/// - Only works for enums, structs aren't supported by this derive macro at the moment.
@@ -512,7 +512,7 @@ pub fn derive_property(input: TokenStream) -> TokenStream {
512512
translate(input, derive_property::transform)
513513
}
514514

515-
/// Derive macro for [Export](godot::bind::property::Property) on enums.
515+
/// Derive macro for [Export](../bind/property/trait.Export.html) on enums.
516516
///
517517
/// Currently has some tight requirements which are expected to be softened as implementation expands, see requirements for [Property]
518518
#[proc_macro_derive(Export)]

0 commit comments

Comments
 (0)