From 1d70c479cf79b33fa2150ffb4e9918cacc4a9cec Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Tue, 8 Feb 2022 17:17:47 -0800 Subject: [PATCH] Add #![deny(missing_docs)], document all items --- riven/src/consts/champion.rs | 5 +++++ riven/src/consts/division.rs | 6 ++++++ riven/src/consts/game_mode.rs | 2 +- riven/src/consts/queue_type.rs | 12 ++++++------ riven/src/consts/route.rs | 7 +++++++ riven/src/consts/tier.rs | 6 +++--- riven/src/lib.rs | 1 + riven/src/meta.rs | 2 ++ riven/src/models.rs | 2 ++ riven/srcgen/consts/champion.rs.dt | 4 ++++ riven/srcgen/consts/game_mode.rs.dt | 2 +- riven/srcgen/lib.rs.dt | 1 + riven/srcgen/meta.rs.dt | 2 ++ riven/srcgen/models.rs.dt | 2 ++ 14 files changed, 43 insertions(+), 11 deletions(-) diff --git a/riven/src/consts/champion.rs b/riven/src/consts/champion.rs index 5436812..80a0038 100644 --- a/riven/src/consts/champion.rs +++ b/riven/src/consts/champion.rs @@ -871,6 +871,11 @@ impl Champion { } } +/// The error used for failures in [`Champion`]'s +/// [`FromStr`](std::str::FromStr) implementation. +/// +/// Currently only internally stores the four characters used to parse the +/// champion, but may change in the future. #[derive(Debug)] pub struct ParseChampionError([char; 4]); impl std::fmt::Display for ParseChampionError { diff --git a/riven/src/consts/division.rs b/riven/src/consts/division.rs index 0611592..0f7238b 100644 --- a/riven/src/consts/division.rs +++ b/riven/src/consts/division.rs @@ -17,10 +17,16 @@ use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr }; #[derive(IntoPrimitive, TryFromPrimitive)] #[repr(u8)] pub enum Division { + /// Division 1, the best/highest division in a [`Tier`](crate::consts::Tier), or the only division in + /// [apex tiers](crate::consts::Tier::is_apex). I = 1, + /// Division 2, the second highest division. II = 2, + /// Division 3, the third highest division. III = 3, + /// Division 4, the fourth and lowest division since 2019. IV = 4, + /// Division 5, the lowest division, only used before 2019. #[deprecated(note="Removed for 2019.")] V = 5, } diff --git a/riven/src/consts/game_mode.rs b/riven/src/consts/game_mode.rs index fea1f86..0414861 100644 --- a/riven/src/consts/game_mode.rs +++ b/riven/src/consts/game_mode.rs @@ -16,7 +16,7 @@ use strum_macros::{ EnumString, IntoStaticStr }; #[derive(EnumString, IntoStaticStr)] #[repr(u8)] pub enum GameMode { - // Catch-all variant for new, unknown game modes. + /// Catch-all variant for new, unknown game modes. #[strum(default)] UNKNOWN(String), diff --git a/riven/src/consts/queue_type.rs b/riven/src/consts/queue_type.rs index 8900985..8eb39bb 100644 --- a/riven/src/consts/queue_type.rs +++ b/riven/src/consts/queue_type.rs @@ -6,17 +6,17 @@ use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr }; #[derive(Eq, PartialEq, Hash)] #[derive(EnumString, Display, AsRefStr, IntoStaticStr)] pub enum QueueType { - // League of Legends, Summoner's Rift (5v5), Ranked Solo Queue. + /// League of Legends, Summoner's Rift (5v5), Ranked Solo Queue. RANKED_SOLO_5x5, - // League of Legends, Summoner's Rift (5v5), Flex Queue. + /// League of Legends, Summoner's Rift (5v5), Flex Queue. RANKED_FLEX_SR, - // League of Legends, Twisted Treeline (3v3), Flex Queue. + /// League of Legends, Twisted Treeline (3v3), Flex Queue. RANKED_FLEX_TT, - // Ranked Teamfight Tactics. + /// Ranked Teamfight Tactics. RANKED_TFT, - // Ranked Teamfight Tactics, Hyper Roll gamemode. + /// Ranked Teamfight Tactics, Hyper Roll gamemode. RANKED_TFT_TURBO, - // Ranked Teamfight Tactics, Double Up gamemode. + /// Ranked Teamfight Tactics, Double Up gamemode. RANKED_TFT_PAIRS } diff --git a/riven/src/consts/route.rs b/riven/src/consts/route.rs index 554e671..cdf6aae 100644 --- a/riven/src/consts/route.rs +++ b/riven/src/consts/route.rs @@ -82,6 +82,8 @@ pub enum PlatformRoute { } impl PlatformRoute { + /// Converts this [`PlatformRoute`] into its corresponding +/// [`RegionalRoute`]. Useful, for example, in [`match-v5` endpoints](crate::endpoints::MatchV5). pub fn to_regional(self) -> RegionalRoute { match self { Self::BR1 => RegionalRoute::AMERICAS, @@ -160,8 +162,11 @@ pub enum ValPlatformRoute { #[repr(u8)] #[non_exhaustive] pub enum Route { + /// Sub-variant for [`RegionalRoute`]s. Regional(RegionalRoute), + /// Sub-variant for [`PlatformRoute`]s. Platform(PlatformRoute), + /// Sub-variant for [`ValPlatformRoute`]s. ValPlatform(ValPlatformRoute), } @@ -232,6 +237,8 @@ impl std::str::FromStr for Route { } impl Route { + /// Returns an iterator over all routes. Starts with [`Self::Regional`], + /// then [`Self::Platform`], and finally [`Self::ValPlatform`]. pub fn iter() -> impl Iterator { use strum::IntoEnumIterator; diff --git a/riven/src/consts/tier.rs b/riven/src/consts/tier.rs index e98eb60..5ff35de 100644 --- a/riven/src/consts/tier.rs +++ b/riven/src/consts/tier.rs @@ -41,8 +41,8 @@ pub enum Tier { serde_string!(Tier); impl Tier { - /// If this tier is an apex tier: master, grandmaster, or challenger. - /// Returns false for unranked. + /// If this tier is an apex tier: [`Self::MASTER`], [`Self::GRANDMASTER`], + /// or [`Self::CHALLENGER`]. Returns false for [`Self::UNRANKED`]. /// /// These tiers are NOT queryable by LeagueV4Endpoints::get_league_entries(...). pub const fn is_apex(self) -> bool { @@ -53,7 +53,7 @@ impl Tier { /// If this tier is a "standard" tier: iron through diamond. /// Returns false for unranked. /// - /// ONLY these tiers are queryable by LeagueV4Endpoints::get_league_entries(...). + /// ONLY these tiers are queryable by [`LeagueV4::get_league_entries(...)`](crate::endpoints::LeagueV4::get_league_entries). pub fn is_standard(self) -> bool { // Casts needed for const. ((Self::UNRANKED as u8) < (self as u8)) && ((self as u8) < (Self::MASTER as u8)) diff --git a/riven/src/lib.rs b/riven/src/lib.rs index 8c1f4f8..06044cd 100644 --- a/riven/src/lib.rs +++ b/riven/src/lib.rs @@ -7,6 +7,7 @@ /////////////////////////////////////////////// #![forbid(unsafe_code)] +#![deny(missing_docs)] //!

//! Riven
diff --git a/riven/src/meta.rs b/riven/src/meta.rs index a403f0d..e57d405 100644 --- a/riven/src/meta.rs +++ b/riven/src/meta.rs @@ -13,6 +13,8 @@ //! //! Note: this modules is automatically generated. +/// Metadata for endpoints. Each tuple corresponds to one endpoint and contains +/// the HTTP [`Method`](reqwest::Method), `str` path, and the method's `str` ID. pub static ALL_ENDPOINTS: [(reqwest::Method, &str, &str); 70] = [ (reqwest::Method::GET, "/riot/account/v1/accounts/by-puuid/{puuid}", "account-v1.getByPuuid"), (reqwest::Method::GET, "/riot/account/v1/accounts/by-riot-id/{gameName}/{tagLine}", "account-v1.getByRiotId"), diff --git a/riven/src/models.rs b/riven/src/models.rs index 23e05c7..79c5695 100644 --- a/riven/src/models.rs +++ b/riven/src/models.rs @@ -9,6 +9,8 @@ // http://www.mingweisamuel.com/riotapi-schema/tool/ // Version be7cba85eef6d2262d61d1befff94fe2d6628d8e +#![allow(missing_docs)] + //! Data transfer structs. //! //! Separated into separate modules for each endpoint. diff --git a/riven/srcgen/consts/champion.rs.dt b/riven/srcgen/consts/champion.rs.dt index 9ac48b4..e276003 100644 --- a/riven/srcgen/consts/champion.rs.dt +++ b/riven/srcgen/consts/champion.rs.dt @@ -107,6 +107,10 @@ impl Champion { } } +/// The error used for failures in [`Champion::from_str`]. +/// +/// Currently only internally stores the four characters used to parse the +/// champion, but may change in the future. #[derive(Debug)] pub struct ParseChampionError([char; 4]); impl std::fmt::Display for ParseChampionError { diff --git a/riven/srcgen/consts/game_mode.rs.dt b/riven/srcgen/consts/game_mode.rs.dt index 8a4ad43..463402a 100644 --- a/riven/srcgen/consts/game_mode.rs.dt +++ b/riven/srcgen/consts/game_mode.rs.dt @@ -13,7 +13,7 @@ use strum_macros::{ EnumString, IntoStaticStr }; #[derive(EnumString, IntoStaticStr)] #[repr(u8)] pub enum GameMode { - // Catch-all variant for new, unknown game modes. + /// Catch-all variant for new, unknown game modes. #[strum(default)] UNKNOWN(String), diff --git a/riven/srcgen/lib.rs.dt b/riven/srcgen/lib.rs.dt index eb59ca3..13f21e0 100644 --- a/riven/srcgen/lib.rs.dt +++ b/riven/srcgen/lib.rs.dt @@ -4,6 +4,7 @@ }}{{= dotUtils.preamble() }} #![forbid(unsafe_code)] +#![deny(missing_docs)] {{~ readme :line }} //! {{= line }} diff --git a/riven/srcgen/meta.rs.dt b/riven/srcgen/meta.rs.dt index 256ade2..79837c6 100644 --- a/riven/srcgen/meta.rs.dt +++ b/riven/srcgen/meta.rs.dt @@ -18,6 +18,8 @@ //! //! Note: this modules is automatically generated. +/// Metadata for endpoints. Each tuple corresponds to one endpoint and contains +/// the HTTP [`Method`](reqwest::Method), `str` path, and the method's `str` ID. pub static ALL_ENDPOINTS: [(reqwest::Method, &str, &str); {{= operations.length }}] = [ {{ for (const { route, method, operation } of operations) { diff --git a/riven/srcgen/models.rs.dt b/riven/srcgen/models.rs.dt index 8a5c30f..994d636 100644 --- a/riven/srcgen/models.rs.dt +++ b/riven/srcgen/models.rs.dt @@ -6,6 +6,8 @@ // http://www.mingweisamuel.com/riotapi-schema/tool/ // Version {{= spec.info.version }} +#![allow(missing_docs)] + //! Data transfer structs. //! //! Separated into separate modules for each endpoint.