From 3ce998e8b8d4cdc60386d6109ba332fa8c59dfe4 Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Wed, 20 Sep 2023 10:28:43 +0300 Subject: [PATCH] Use doc attr for help message instead of `#[command(description = "...")]` --- crates/teloxide/examples/admin.rs | 14 ++++++-------- crates/teloxide/examples/buttons.rs | 7 ++++--- crates/teloxide/examples/command.rs | 10 ++++++---- crates/teloxide/examples/db_remember.rs | 7 ++++--- crates/teloxide/examples/dispatching_features.rs | 15 +++++++++------ crates/teloxide/examples/purchase.rs | 9 +++++---- 6 files changed, 34 insertions(+), 28 deletions(-) diff --git a/crates/teloxide/examples/admin.rs b/crates/teloxide/examples/admin.rs index 113d6f07..8612e5de 100644 --- a/crates/teloxide/examples/admin.rs +++ b/crates/teloxide/examples/admin.rs @@ -12,21 +12,19 @@ use teloxide::{prelude::*, types::ChatPermissions, utils::command::BotCommands}; // your commands in this format: // %GENERAL-DESCRIPTION% // %PREFIX%%COMMAND% - %DESCRIPTION% + +/// Use commands in format /%command% %num% %unit% #[derive(BotCommands, Clone)] -#[command( - rename_rule = "lowercase", - description = "Use commands in format /%command% %num% %unit%", - parse_with = "split" -)] +#[command(rename_rule = "lowercase", parse_with = "split")] enum Command { - #[command(description = "kick user from chat.")] + /// Kick user from chat. Kick, - #[command(description = "ban user in chat.")] + /// Ban user in chat. Ban { time: u64, unit: UnitOfTime, }, - #[command(description = "mute user in chat.")] + /// Mute user in chat. Mute { time: u64, unit: UnitOfTime, diff --git a/crates/teloxide/examples/buttons.rs b/crates/teloxide/examples/buttons.rs index 595189e6..c640d708 100644 --- a/crates/teloxide/examples/buttons.rs +++ b/crates/teloxide/examples/buttons.rs @@ -9,12 +9,13 @@ use teloxide::{ utils::command::BotCommands, }; +/// These commands are supported: #[derive(BotCommands)] -#[command(rename_rule = "lowercase", description = "These commands are supported:")] +#[command(rename_rule = "lowercase")] enum Command { - #[command(description = "Display this text")] + /// Display this text Help, - #[command(description = "Start")] + /// Start Start, } diff --git a/crates/teloxide/examples/command.rs b/crates/teloxide/examples/command.rs index 26848015..c1dc2d94 100644 --- a/crates/teloxide/examples/command.rs +++ b/crates/teloxide/examples/command.rs @@ -10,14 +10,16 @@ async fn main() { Command::repl(bot, answer).await; } +/// These commands are supported: #[derive(BotCommands, Clone)] -#[command(rename_rule = "lowercase", description = "These commands are supported:")] +#[command(rename_rule = "lowercase")] enum Command { - #[command(description = "display this text.")] + /// Display this text. Help, - #[command(description = "handle a username.")] + /// Handle a username. Username(String), - #[command(description = "handle a username and an age.", parse_with = "split")] + /// Handle a username and an age. + #[command(parse_with = "split")] UsernameAndAge { username: String, age: u8 }, } diff --git a/crates/teloxide/examples/db_remember.rs b/crates/teloxide/examples/db_remember.rs index 980d1357..02a9cd19 100644 --- a/crates/teloxide/examples/db_remember.rs +++ b/crates/teloxide/examples/db_remember.rs @@ -21,12 +21,13 @@ pub enum State { GotNumber(i32), } +/// These commands are supported: #[derive(Clone, BotCommands)] -#[command(rename_rule = "lowercase", description = "These commands are supported:")] +#[command(rename_rule = "lowercase")] pub enum Command { - #[command(description = "get your number.")] + /// Get your number. Get, - #[command(description = "reset your number.")] + /// Reset your number. Reset, } diff --git a/crates/teloxide/examples/dispatching_features.rs b/crates/teloxide/examples/dispatching_features.rs index 83efc6e9..8e4c52a4 100644 --- a/crates/teloxide/examples/dispatching_features.rs +++ b/crates/teloxide/examples/dispatching_features.rs @@ -95,21 +95,24 @@ struct ConfigParameters { maintainer_username: Option, } +/// Simple commands #[derive(BotCommands, Clone)] -#[command(rename_rule = "lowercase", description = "Simple commands")] +#[command(rename_rule = "lowercase")] enum SimpleCommand { - #[command(description = "shows this message.")] + /// Shows this message. Help, - #[command(description = "shows maintainer info.")] + /// Shows maintainer info. Maintainer, - #[command(description = "shows your ID.")] + /// Shows your ID. MyId, } +/// Maintainer commands #[derive(BotCommands, Clone)] -#[command(rename_rule = "lowercase", description = "Maintainer commands")] +#[command(rename_rule = "lowercase")] enum MaintainerCommands { - #[command(parse_with = "split", description = "generate a number within range")] + /// Generate a number within range + #[command(parse_with = "split")] Rand { from: u64, to: u64 }, } diff --git a/crates/teloxide/examples/purchase.rs b/crates/teloxide/examples/purchase.rs index daf27cdd..480cec5f 100644 --- a/crates/teloxide/examples/purchase.rs +++ b/crates/teloxide/examples/purchase.rs @@ -32,14 +32,15 @@ pub enum State { }, } +/// These commands are supported: #[derive(BotCommands, Clone)] -#[command(rename_rule = "lowercase", description = "These commands are supported:")] +#[command(rename_rule = "lowercase")] enum Command { - #[command(description = "display this text.")] + /// Display this text. Help, - #[command(description = "start the purchase procedure.")] + /// Start the purchase procedure. Start, - #[command(description = "cancel the purchase procedure.")] + /// Cancel the purchase procedure. Cancel, }