Skip to content

Commit 7cd0642

Browse files
authored
Merge pull request #1395 from felinira/wip/fina/docs-cleanup
docs: Fix broken links / cleanup README
2 parents bfbba2a + bc4b575 commit 7cd0642

File tree

13 files changed

+106
-51
lines changed

13 files changed

+106
-51
lines changed

gdk-pixbuf/src/subclass/pixbuf_animation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

33
// rustdoc-stripper-ignore-next
4-
//! Traits intended for subclassing [`PixbufAnimation`](crate::PixbufAnimation).
4+
//! Traits intended for subclassing [`PixbufAnimation`].
55
66
use std::{
77
mem::MaybeUninit,

gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

33
// rustdoc-stripper-ignore-next
4-
//! Traits intended for subclassing [`PixbufAnimationIter`](crate::PixbufAnimationIter).
4+
//! Traits intended for subclassing [`PixbufAnimationIter`].
55
66
use std::{
77
sync::OnceLock,

gdk-pixbuf/src/subclass/pixbuf_loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

33
// rustdoc-stripper-ignore-next
4-
//! Traits intended for subclassing [`PixbufLoader`](crate::PixbufLoader).
4+
//! Traits intended for subclassing [`PixbufLoader`].
55
66
use glib::{prelude::*, subclass::prelude::*, translate::*};
77

glib-macros/src/lib.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,8 +1219,8 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
12191219
/// | --- | --- | --- | --- |
12201220
/// | `name = "literal"` | The name of the property | field ident where `_` (leading and trailing `_` are trimmed) is replaced into `-` | `#[property(name = "prop-name")]` |
12211221
/// | `type = expr` | The type of the property | inferred | `#[property(type = i32)]` |
1222-
/// | `get [= expr]` | Specify that the property is readable and use `PropertyGet::get` [or optionally set a custom internal getter] | | `#[property(get)]`, `#[property(get = get_prop)]`, or `[property(get = \|_\| 2)]` |
1223-
/// | `set [= expr]` | Specify that the property is writable and use `PropertySet::set` [or optionally set a custom internal setter] | | `#[property(set)]`, `#[property(set = set_prop)]`, or `[property(set = \|_, val\| {})]` |
1222+
/// | `get [= expr]` | Specify that the property is readable and use [`PropertyGet::get`] [or optionally set a custom internal getter] | | `#[property(get)]`, `#[property(get = get_prop)]`, or `[property(get = \|_\| 2)]` |
1223+
/// | `set [= expr]` | Specify that the property is writable and use [`PropertySet::set`] [or optionally set a custom internal setter] | | `#[property(set)]`, `#[property(set = set_prop)]`, or `[property(set = \|_, val\| {})]` |
12241224
/// | `override_class = expr` | The type of class of which to override the property from | | `#[property(override_class = SomeClass)]` |
12251225
/// | `override_interface = expr` | The type of interface of which to override the property from | | `#[property(override_interface = SomeInterface)]` |
12261226
/// | `nullable` | Whether to use `Option<T>` in the generated setter method | | `#[property(nullable)]` |
@@ -1256,32 +1256,32 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
12561256
/// by assigning an expression to `get`/`set` `#[property]` attributes: `#[property(get = |_| 2, set)]` or `#[property(get, set = custom_setter_func)]`.
12571257
///
12581258
/// # Supported types
1259-
/// Every type implementing the trait `Property` is supported.
1260-
/// The type `Option<T>` is supported as a property only if `Option<T>` implements `ToValueOptional`.
1259+
/// Every type implementing the trait [`Property`] is supported.
1260+
/// The type `Option<T>` is supported as a property only if `Option<T>` implements [`ToValueOptional`].
12611261
/// Optional types also require the `nullable` attribute: without it, the generated setter on the wrapper type
12621262
/// will take `T` instead of `Option<T>`, preventing the user from ever calling the setter with a `None` value.
12631263
///
12641264
/// ## Adding support for custom types
1265-
/// ### Types wrapping an existing `T: glib::value::ToValue + glib::HasParamSpec`
1265+
/// ### Types wrapping an existing <code>T: [ToValue] + [HasParamSpec]</code>
12661266
/// If you have declared a newtype as
12671267
/// ```rust
12681268
/// struct MyInt(i32);
12691269
/// ```
1270-
/// you can use it as a property by deriving `glib::ValueDelegate`.
1270+
/// you can use it as a property by deriving [`ValueDelegate`].
12711271
///
12721272
/// ### Types with inner mutability
1273-
/// The trait `glib::Property` must be implemented.
1274-
/// The traits `PropertyGet` and `PropertySet` should be implemented to enable the Properties macro
1273+
/// The trait [`Property`] must be implemented.
1274+
/// The traits [`PropertyGet`] and [`PropertySet`] should be implemented to enable the Properties macro
12751275
/// to generate a default internal getter/setter.
1276-
/// If possible, implementing `PropertySetNested` is preferred over `PropertySet`, because it
1276+
/// If possible, implementing [`PropertySetNested`] is preferred over `PropertySet`, because it
12771277
/// enables this macro to access the contained type and provide access to its fields,
12781278
/// using the `member = $structfield` syntax.
12791279
///
1280-
/// ### Types without `glib::HasParamSpec`
1281-
/// If you have encountered a type `T: glib::value::ToValue`, inside the `gtk-rs` crate, which doesn't implement `HasParamSpec`,
1280+
/// ### Types without [`HasParamSpec`][HasParamSpec]
1281+
/// If you have encountered a type <code>T: [ToValue]</code>, inside the gtk-rs crate, which doesn't implement [`HasParamSpec`][HasParamSpec],
12821282
/// then it's a bug and you should report it.
1283-
/// If you need to support a `ToValue` type with a `ParamSpec` not provided by `gtk-rs`, then you need to
1284-
/// implement `glib::HasParamSpec` on that type.
1283+
/// If you need to support a `ToValue` type with a [`ParamSpec`] not provided by gtk-rs, then you need to
1284+
/// implement `HasParamSpec` on that type.
12851285
///
12861286
/// # Example
12871287
/// ```
@@ -1348,6 +1348,18 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
13481348
/// assert_eq!(myfoo.fizz(), "custom set: test value".to_string());
13491349
/// }
13501350
/// ```
1351+
///
1352+
/// [`Property`]: ../glib/property/trait.Property.html
1353+
/// [`PropertyGet`]: ../glib/property/trait.PropertyGet.html
1354+
/// [`PropertyGet::get`]: ../glib/property/trait.PropertyGet.html#tymethod.get
1355+
/// [`PropertySet`]: ../glib/property/trait.PropertySet.html
1356+
/// [`PropertySet::set`]: ../glib/property/trait.PropertySet.html#tymethod.set
1357+
/// [`PropertySetNested`]: ../glib/property/trait.PropertySetNested.html
1358+
/// [`ObjectExt::property`]: ../glib/object/trait.ObjectExt.html#tymethod.property
1359+
/// [HasParamSpec]: ../glib/trait.HasParamSpec.html
1360+
/// [`ParamSpec`]: ../glib/struct.ParamSpec.html
1361+
/// [`ToValueOptional`]: ../glib/value/trait.ToValueOptional.html
1362+
/// [ToValue]: ../glib/value/trait.ToValue.html
13511363
#[allow(clippy::needless_doctest_main)]
13521364
#[proc_macro_derive(Properties, attributes(properties, property))]
13531365
pub fn derive_props(input: TokenStream) -> TokenStream {

glib/README.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Currently, the minimum supported Rust version is `1.70.0`.
2323
Most types in the GLib family have [`Type`] identifiers.
2424
Their corresponding Rust types implement the [`StaticType`] trait.
2525

26-
A dynamically typed [`Value`] can carry values of any [`StaticType`].
27-
[`Variant`](struct@Variant)s can carry values of [`StaticVariantType`].
26+
A dynamically typed [`Value`] can carry values of any `StaticType`.
27+
[Variants][`Variant`] can carry values of [`StaticVariantType`].
2828

2929
## Errors
3030

@@ -35,10 +35,11 @@ carry values from various [error domains](error::ErrorDomain) such as
3535
## Objects
3636

3737
Each class and interface has a corresponding smart pointer struct
38-
representing an instance of that type (e.g. [`Object`] for `GObject` or
39-
`gtk::Widget` for `GtkWidget`). They are reference counted and feature
40-
interior mutability similarly to Rust's `Rc<RefCell<T>>` idiom.
41-
Consequently, cloning objects is cheap and their methods never require
38+
representing an instance of that type (e.g. [`Object`] for [`GObject`] or
39+
[`gtk4::Widget`] for [`GtkWidget`]). They are reference counted and feature
40+
interior mutability similarly to Rust's
41+
[`Rc<RefCell<T>>`]
42+
idiom. Consequently, cloning objects is cheap and their methods never require
4243
mutable borrows. Two smart pointers are equal if they point to the same
4344
object.
4445

@@ -48,7 +49,7 @@ marker trait. The [`Cast`] trait enables upcasting
4849
and downcasting.
4950

5051
Interfaces and non-leaf classes also have corresponding traits (e.g.
51-
[`ObjectExt`] or `gtk::WidgetExt`), which are blanketly implemented for all
52+
[`ObjectExt`] or [`WidgetExt`]), which are blanketly implemented for all
5253
their subtypes.
5354

5455
You can create new subclasses of [`Object`] or other object types. Look at
@@ -60,11 +61,10 @@ GLib-based libraries largely operate on pointers to various boxed or
6061
reference counted structures so the bindings have to implement corresponding
6162
smart pointers (wrappers), which encapsulate resource management and safety
6263
checks. Such wrappers are defined via the
63-
[`wrapper`][`macro@wrapper`] macro, which uses abstractions
64-
defined in the [`wrapper`][`mod@wrapper`], [`boxed`][`mod@boxed`],
65-
[`shared`][`mod@shared`] and [`object`][`mod@object`] modules.
66-
67-
The [`translate`][`mod@translate`] module defines and partly implements
64+
[`wrapper!`] macro, which uses abstractions
65+
defined in the [`wrapper`], [`boxed`],
66+
[`shared`] and [`object`][mod@object] modules.
67+
The [`translate`] module defines and partly implements
6868
conversions between high level Rust types (including the aforementioned
6969
wrappers) and their FFI counterparts.
7070

@@ -99,3 +99,26 @@ glib = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "glib" }
9999
## License
100100

101101
__glib__ is available under the MIT License, please refer to it.
102+
103+
[`Type`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/types/struct.Type.html
104+
[`StaticType`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/types/trait.StaticType.html
105+
[`Value`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/value/struct.Value.html
106+
[`Variant`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/variant/struct.Variant.html
107+
[`StaticVariantType`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/variant/trait.StaticVariantType.html
108+
[`Error`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/error/struct.Error.html
109+
[`FileError`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/enum.FileError.html
110+
[`Object`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/object/struct.Object.html
111+
[`GObject`]: https://docs.gtk.org/gobject/class.Object.html
112+
[`gtk4::Widget`]: https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.Widget.html
113+
[`GtkWidget`]: https://docs.gtk.org/gtk4/class.Widget.html
114+
[`Rc<RefCell<T>>`]: https://doc.rust-lang.org/stable/core/cell/index.html#introducing-mutability-inside-of-something-immutable
115+
[`IsA`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/object/trait.IsA.html
116+
[`Cast`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/object/trait.Cast.html
117+
[`ObjectExt`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/object/trait.ObjectExt.html
118+
[`WidgetExt`]: https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/prelude/trait.WidgetExt.html
119+
[`wrapper!`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/macro.wrapper.html
120+
[`wrapper`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/wrapper/index.html
121+
[`boxed`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/boxed/index.html
122+
[`shared`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/shared/index.html
123+
[mod@object]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/object/index.html
124+
[`translate`]: https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib/translate/index.html

glib/src/collections/ptr_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const MIN_SIZE: usize = 16;
1111
// rustdoc-stripper-ignore-next
1212
/// Slice of elements of type `T` allocated by the GLib allocator.
1313
///
14-
/// The underlying memory is always `NULL`-terminated. [`Slice<T>`]
14+
/// The underlying memory is always `NULL`-terminated. [`Slice<T>`](crate::collections::slice::Slice)
1515
/// can be used for a non-`NULL`-terminated slice.
1616
///
1717
/// This can be used like a `&[T]`, `&mut [T]` and `Vec<T>`.

glib/src/gstring.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl GStr {
134134
///
135135
/// # Safety
136136
///
137-
/// See [`CStr::from_ptr`](CStr::from_ptr#safety).
137+
/// See [`CStr::from_ptr`](std::ffi::CStr#safety).
138138
#[inline]
139139
pub unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a Self {
140140
let cstr = CStr::from_ptr(ptr);
@@ -177,7 +177,7 @@ impl GStr {
177177
// rustdoc-stripper-ignore-next
178178
/// Converts this GLib string to a byte slice containing the trailing 0 byte.
179179
///
180-
/// This function is the equivalent of [`GStr::to_bytes`] except that it will retain the
180+
/// This function is the equivalent of [`GStr::as_bytes`] except that it will retain the
181181
/// trailing nul terminator instead of chopping it off.
182182
#[inline]
183183
pub const fn as_bytes_with_nul(&self) -> &[u8] {
@@ -669,9 +669,9 @@ impl<'a> ToGlibPtr<'a, *mut c_char> for GStr {
669669
}
670670

671671
// rustdoc-stripper-ignore-next
672-
/// `NULL`-terminated UTF-8 string as stored in [`StrV`].
672+
/// `NULL`-terminated UTF-8 string as stored in [`StrV`](crate::StrV).
673673
///
674-
/// Unlike [`&GStr`] this does not have its length stored.
674+
/// Unlike [`&GStr`](crate::GStr) this does not have its length stored.
675675
#[repr(transparent)]
676676
pub struct GStringPtr(ptr::NonNull<c_char>);
677677

@@ -685,7 +685,7 @@ impl GlibPtrDefault for GStringPtr {
685685

686686
impl GStringPtr {
687687
// rustdoc-stripper-ignore-next
688-
/// Returns the corresponding [`&GStr`].
688+
/// Returns the corresponding [`&GStr`](crate::GStr).
689689
#[inline]
690690
pub fn to_gstr(&self) -> &GStr {
691691
unsafe { GStr::from_ptr(self.0.as_ptr()) }
@@ -699,7 +699,7 @@ impl GStringPtr {
699699
}
700700

701701
// rustdoc-stripper-ignore-next
702-
/// This is just an alias for [`as_str`].
702+
/// This is just an alias for [`as_str`](GStringPtr::as_str).
703703
#[inline]
704704
#[deprecated = "Use as_str instead"]
705705
pub fn to_str(&self) -> &str {
@@ -1029,7 +1029,7 @@ impl GString {
10291029
/// [`Arguments`](std::fmt::Arguments) instance can be created with the
10301030
/// [`format_args!`](std::format_args) macro.
10311031
///
1032-
/// Please note that using [`gformat!`] might be preferable.
1032+
/// Please note that using [`gformat!`](crate::gformat) might be preferable.
10331033
pub fn format(args: fmt::Arguments) -> Self {
10341034
if let Some(s) = args.as_str() {
10351035
return Self::from(s);

glib/src/gstring_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl GStringBuilder {
146146
}
147147

148148
// rustdoc-stripper-ignore-next
149-
/// Finalizes the builder, converting it to a [`GString`].
149+
/// Finalizes the builder, converting it to a [`GString`](crate::GString).
150150
#[must_use = "String returned from the builder should probably be used"]
151151
#[inline]
152152
pub fn into_string(self) -> crate::GString {

glib/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
#![cfg_attr(docsrs, feature(doc_cfg))]
44
#![allow(clippy::missing_safety_doc)]
55
#![allow(renamed_and_removed_lints)]
6+
// Override docs references to point to locally generated docs
7+
// rustdoc-stripper-ignore-next
8+
//! [`Type`]: struct@Type
9+
//! [`StaticType`]: trait@types::StaticType
10+
//! [`Value`]: struct@Value
11+
//! [`Variant``]: struct@Variant
12+
//! [`StaticVariantType`]: trait@variant::StaticVariantType
13+
//! [`Error`]: struct@Error
14+
//! [`FileError`]: enum@FileError
15+
//! [`Object`]: struct@Object
16+
//! [`Rc<RefCell<T>>`]: mod@std::cell#introducing-mutability-inside-of-something-immutable
17+
//! [`IsA`]: trait@object::IsA
18+
//! [`Cast`]: trait@object::Cast
19+
//! [`ObjectExt`]: trait@object::ObjectExt
20+
//! [`wrapper!`]: macro@wrapper
21+
//! [`wrapper`]: mod@wrapper
22+
//! [`boxed`]: mod@boxed
23+
//! [`shared`]: mod@shared
24+
//! [mod@object]: mod@object
25+
//! [`translate`]: mod@translate
626
#![doc = include_str!("../README.md")]
727

828
pub use bitflags;

glib/src/log.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ macro_rules! g_log {
544544
///
545545
/// [g_log]: https://docs.gtk.org/glib/func.log.html
546546
///
547-
/// It is the same as calling the [`g_log!`] macro with [`LogLevel::Error`].
547+
/// It is the same as calling the [`g_log!`](crate::g_log!) macro with [`LogLevel::Error`].
548548
///
549549
/// Example:
550550
///
@@ -581,7 +581,7 @@ macro_rules! g_error {
581581
///
582582
/// [g_log]: https://docs.gtk.org/glib/func.log.html
583583
///
584-
/// It is the same as calling the [`g_log!`] macro with [`LogLevel::Critical`].
584+
/// It is the same as calling the [`g_log!`](crate::g_log!) macro with [`LogLevel::Critical`].
585585
///
586586
/// Example:
587587
///
@@ -618,7 +618,7 @@ macro_rules! g_critical {
618618
///
619619
/// [g_log]: https://docs.gtk.org/glib/func.log.html
620620
///
621-
/// It is the same as calling the [`g_log!`] macro with [`LogLevel::Warning`].
621+
/// It is the same as calling the [`g_log!`](crate::g_log!) macro with [`LogLevel::Warning`].
622622
///
623623
/// Example:
624624
///
@@ -655,7 +655,7 @@ macro_rules! g_warning {
655655
///
656656
/// [g_log]: https://docs.gtk.org/glib/func.log.html
657657
///
658-
/// It is the same as calling the [`g_log!`] macro with [`LogLevel::Message`].
658+
/// It is the same as calling the [`g_log!`](crate::g_log!) macro with [`LogLevel::Message`].
659659
///
660660
/// Example:
661661
///
@@ -692,7 +692,7 @@ macro_rules! g_message {
692692
///
693693
/// [g_log]: https://docs.gtk.org/glib/func.log.html
694694
///
695-
/// It is the same as calling the [`g_log!`] macro with [`LogLevel::Info`].
695+
/// It is the same as calling the [`g_log!`](crate::g_log!) macro with [`LogLevel::Info`].
696696
///
697697
/// Example:
698698
///
@@ -729,7 +729,7 @@ macro_rules! g_info {
729729
///
730730
/// [g_log]: https://docs.gtk.org/glib/func.log.html
731731
///
732-
/// It is the same as calling the [`g_log!`] macro with [`LogLevel::Debug`].
732+
/// It is the same as calling the [`g_log!`](crate::g_log!) macro with [`LogLevel::Debug`].
733733
///
734734
/// Example:
735735
///

0 commit comments

Comments
 (0)