Skip to content

Commit bc4b575

Browse files
committed
glib: Make links in README.md work in both web and rustdoc
1 parent 9de8ee7 commit bc4b575

File tree

2 files changed

+55
-12
lines changed

2 files changed

+55
-12
lines changed

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/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;

0 commit comments

Comments
 (0)