From 53f25bb772c2b814490b58a9540f545a43551113 Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Wed, 2 Aug 2023 11:10:50 +0200 Subject: [PATCH 1/2] Add typos workflow --- .github/workflows/typos.yml | 15 +++++++++++++++ .typos.toml | 16 ++++++++++++++++ examples/gio_task/main.rs | 2 +- gio/Gir.toml | 12 ++++++------ glib-macros/src/downgrade_derive/fields.rs | 4 ++-- glib-macros/src/lib.rs | 4 ++-- glib-macros/src/properties.rs | 2 +- glib/Gir.toml | 2 +- glib/src/gobject/binding_group.rs | 2 +- glib/src/log.rs | 4 ++-- glib/src/object.rs | 2 +- glib/src/property.rs | 2 +- glib/src/subclass/object.rs | 2 +- glib/src/value.rs | 2 +- pango/src/enums.rs | 2 +- 15 files changed, 52 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/typos.yml create mode 100644 .typos.toml diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml new file mode 100644 index 000000000000..3c7f20c450eb --- /dev/null +++ b/.github/workflows/typos.yml @@ -0,0 +1,15 @@ +name: CI +on: + pull_request: + push: + branches: + - "master" +jobs: + typos: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v3 + - name: Check spelling + uses: crate-ci/typos@master diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 000000000000..d6492320e734 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,16 @@ +[files] +extend-exclude = ["auto", "sys", "gobject-sys", "*.svg"] + +[default.extend-words] +# Ignore false-positives +gir = "gir" +mak = "mak" +anid = "anid" +lamda = "lamda" +inout = "inout" +relm = "relm" +ba = "ba" +ue = "ue" +ot = "ot" +siz = "siz" +vai = "vai" diff --git a/examples/gio_task/main.rs b/examples/gio_task/main.rs index def62a3eefe4..56d07d111c9a 100644 --- a/examples/gio_task/main.rs +++ b/examples/gio_task/main.rs @@ -31,7 +31,7 @@ fn main() { main_loop.run(); } -// This function mimicks what the C code using the exported async/finish API would do. It first defines a +// This function mimics what the C code using the exported async/finish API would do. It first defines a // callback of type GAsyncResult that internally calls get_file_size_finish to retrieve the Task // result, and simply prints it out. Then it invokes the my_file_size_get_file_size_async method, passing the // callback to it as parameter. diff --git a/gio/Gir.toml b/gio/Gir.toml index d2926b648450..999627dfdde0 100644 --- a/gio/Gir.toml +++ b/gio/Gir.toml @@ -398,7 +398,7 @@ manual_traits = ["CancellableExtManual"] ignore = true [[object.function]] name = "source_new" - # Only for use with other souce implementations + # Only for use with other source implementations ignore = true [[object.signal]] name = "cancelled" @@ -491,7 +491,7 @@ generate_builder = true [[object.function]] name = "read_line_utf8" - #redudant length returned + #redundant length returned manual = true [[object.function]] @@ -1022,11 +1022,11 @@ name = "Gio.MenuAttributeIter" status = "generate" [[object.function]] name = "get_name" - # Users shoud use `next` (automatically renamed from `get_next`). + # Users should use `next` (automatically renamed from `get_next`). ignore= true [[object.function]] name = "get_value" - # Users shoud use `next` (automatically renamed from `get_next`). + # Users should use `next` (automatically renamed from `get_next`). ignore= true [[object.function]] name = "next" @@ -1040,11 +1040,11 @@ name = "Gio.MenuLinkIter" status = "generate" [[object.function]] name = "get_name" - # Users shoud use `next` (automatically renamed from `get_next`). + # Users should use `next` (automatically renamed from `get_next`). ignore= true [[object.function]] name = "get_value" - # Users shoud use `next` (automatically renamed from `get_next`). + # Users should use `next` (automatically renamed from `get_next`). ignore= true [[object.function]] name = "next" diff --git a/glib-macros/src/downgrade_derive/fields.rs b/glib-macros/src/downgrade_derive/fields.rs index 65e6c03198b9..efb5eda5daf5 100644 --- a/glib-macros/src/downgrade_derive/fields.rs +++ b/glib-macros/src/downgrade_derive/fields.rs @@ -66,8 +66,8 @@ pub struct DowngradeStructParts { /// let Named { ref x, ref y } = ; /// /// match { -/// Choise::This (ref _0, ref _1) => ... , -/// Choise::That { ref x, ref y } => ... , +/// Choice::This (ref _0, ref _1) => ... , +/// Choice::That { ref x, ref y } => ... , /// } /// ``` /// diff --git a/glib-macros/src/lib.rs b/glib-macros/src/lib.rs index c14479ed12a3..ce67e77c39ea 100644 --- a/glib-macros/src/lib.rs +++ b/glib-macros/src/lib.rs @@ -545,7 +545,7 @@ pub fn error_domain_derive(input: TokenStream) -> TokenStream { /// Derive macro for defining a [`BoxedType`]`::type_` function and /// the [`glib::Value`] traits. Optionally, the type can be marked as -/// `nullable` to get an implemention of `glib::value::ToValueOptional`. +/// `nullable` to get an implementation of `glib::value::ToValueOptional`. /// /// # Example /// @@ -574,7 +574,7 @@ pub fn boxed_derive(input: TokenStream) -> TokenStream { /// Derive macro for defining a [`SharedType`]`::get_type` function and /// the [`glib::Value`] traits. Optionally, the type can be marked as -/// `nullable` to get an implemention of `glib::value::ToValueOptional`. +/// `nullable` to get an implementation of `glib::value::ToValueOptional`. /// /// # Example /// diff --git a/glib-macros/src/properties.rs b/glib-macros/src/properties.rs index 3d63464db4a7..f70a6df938c6 100644 --- a/glib-macros/src/properties.rs +++ b/glib-macros/src/properties.rs @@ -288,7 +288,7 @@ impl PropDesc { }); let ty = ty.unwrap_or_else(|| field_ty.clone()); - // Now that everything is set and safe, return the final proprety description + // Now that everything is set and safe, return the final property description Ok(Self { attrs_span, field_ident, diff --git a/glib/Gir.toml b/glib/Gir.toml index 91348cda9840..313c4b095212 100644 --- a/glib/Gir.toml +++ b/glib/Gir.toml @@ -89,7 +89,7 @@ status = "generate" ignore = true # needs manual wrappers to make their usage nicer [[object.function]] pattern = "compute_.*_for_string" - ignore = true # needs manual wrapper to avoid an unecessary copy of the string + ignore = true # needs manual wrapper to avoid an unnecessary copy of the string [[object.function]] pattern = "(idle_remove_by_data|qsort_with_data)" ignore = true # Unsafe functions diff --git a/glib/src/gobject/binding_group.rs b/glib/src/gobject/binding_group.rs index 78cba7d245dc..03a594822d9e 100644 --- a/glib/src/gobject/binding_group.rs +++ b/glib/src/gobject/binding_group.rs @@ -198,7 +198,7 @@ impl<'a> BindingGroupBuilder<'a> { ) })?; - // This is NUL-termianted from the C side + // This is NUL-terminated from the C side source_property.name().as_ptr() } else { // This is a Rust &str and needs to be NUL-terminated first diff --git a/glib/src/log.rs b/glib/src/log.rs index 276d736c9d0f..9790c2eb1e34 100644 --- a/glib/src/log.rs +++ b/glib/src/log.rs @@ -378,7 +378,7 @@ impl<'a> LogField<'a> { // rustdoc-stripper-ignore-next /// Creates a field with an empty value and `data` as a user data key. Fields created with this /// function are ignored by the default log writer. These fields are used to pass custom data - /// into a writer function set with [`log_set_writer_func`], where it can be retreived using + /// into a writer function set with [`log_set_writer_func`], where it can be retrieved using /// [`Self::user_data`]. /// /// The passed `usize` can be used by the log writer as a key into a static data structure. @@ -395,7 +395,7 @@ impl<'a> LogField<'a> { ) } // rustdoc-stripper-ignore-next - /// Retreives the field key. + /// Retrieves the field key. pub fn key(&self) -> &str { unsafe { std::ffi::CStr::from_ptr(self.0.key as *const _) } .to_str() diff --git a/glib/src/object.rs b/glib/src/object.rs index 6588d9b79e71..c26fb8a31610 100644 --- a/glib/src/object.rs +++ b/glib/src/object.rs @@ -285,7 +285,7 @@ impl Cast for T {} /// Convenience trait mirroring `Cast`, implemented on `Option` types. /// /// # Warning -/// Inveitably this trait will discard informations about a downcast failure: +/// Inevitably this trait will discard information about a downcast failure: /// you don't know if the object was not of the expected type, or if it was `None`. /// If you need to handle the downcast error, use `Cast` over a `glib::Object`. /// diff --git a/glib/src/property.rs b/glib/src/property.rs index e6db701abc63..b63a69c95bd4 100644 --- a/glib/src/property.rs +++ b/glib/src/property.rs @@ -53,7 +53,7 @@ impl Property for std::cell::OnceCell { impl Property for std::sync::OnceLock { type Value = T::Value; } -// Handle smart pointers trasparently +// Handle smart pointers transparently impl Property for Rc { type Value = T::Value; } diff --git a/glib/src/subclass/object.rs b/glib/src/subclass/object.rs index ef84967c43f1..848204eaa6e5 100644 --- a/glib/src/subclass/object.rs +++ b/glib/src/subclass/object.rs @@ -701,7 +701,7 @@ mod test { assert!(name_changed_triggered.load(Ordering::Relaxed)); } - // Note: can't test type mismatch in signals since panics accross FFI boundaries + // Note: can't test type mismatch in signals since panics across FFI boundaries // are UB. See https://github.com/gtk-rs/glib/issues/518 #[test] diff --git a/glib/src/value.rs b/glib/src/value.rs index 6a3521ee1aa6..8468e8b327b0 100644 --- a/glib/src/value.rs +++ b/glib/src/value.rs @@ -372,7 +372,7 @@ pub trait ToValue { fn to_value(&self) -> Value; // rustdoc-stripper-ignore-next - /// Returns the type identifer of `self`. + /// Returns the type identifier of `self`. /// /// This is the type of the value to be returned by `to_value`. fn value_type(&self) -> Type; diff --git a/pango/src/enums.rs b/pango/src/enums.rs index c2ee19928141..ea0593406efc 100644 --- a/pango/src/enums.rs +++ b/pango/src/enums.rs @@ -73,7 +73,7 @@ impl FromGlib for LayoutDeserializeError { #[cfg(feature = "v1_50")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))] impl ErrorDomain for LayoutDeserializeError { - // TODO: figure out why gir picks a non-existant quark function + // TODO: figure out why gir picks a non-existent quark function #[doc(alias = "pango_layout_deserialize_error_quark")] fn domain() -> Quark { unsafe { from_glib(ffi::pango_layout_deserialize_error_quark()) } From 442f83ce1c74af7daaed63a08930508b1602f097 Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Wed, 2 Aug 2023 11:17:13 +0200 Subject: [PATCH 2/2] Fix remaining typos manually --- glib/src/gobject/binding_group.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glib/src/gobject/binding_group.rs b/glib/src/gobject/binding_group.rs index 03a594822d9e..d5a922db2a01 100644 --- a/glib/src/gobject/binding_group.rs +++ b/glib/src/gobject/binding_group.rs @@ -188,7 +188,7 @@ impl<'a> BindingGroupBuilder<'a> { let _ = Box::from_raw(data as *mut (TransformFn, TransformFn, String, ParamSpec)); } - let mut _source_propery_name_cstr = None; + let mut _source_property_name_cstr = None; let source_property_name = if let Some(source) = self.group.source() { let source_property = source.find_property(self.source_property).ok_or_else(|| { bool_error!( @@ -202,9 +202,9 @@ impl<'a> BindingGroupBuilder<'a> { source_property.name().as_ptr() } else { // This is a Rust &str and needs to be NUL-terminated first - let source_propery_name = std::ffi::CString::new(self.source_property).unwrap(); - let source_property_name_ptr = source_propery_name.as_ptr() as *const u8; - _source_propery_name_cstr = Some(source_propery_name); + let source_property_name = std::ffi::CString::new(self.source_property).unwrap(); + let source_property_name_ptr = source_property_name.as_ptr() as *const u8; + _source_property_name_cstr = Some(source_property_name); source_property_name_ptr };