docs: add rustdoc comments for public API (P4.12 partial)
- Add comprehensive documentation for TdClient: * Struct-level docs with examples * Authentication methods (send_phone_number, send_code, send_password) * Chat methods (load_chats, load_folder_chats, leave_chat, get_profile_info) * All methods now have parameter docs, return types, and error descriptions - Add comprehensive documentation for App: * Struct-level docs with state machine explanation * Constructor documentation * Examples for common usage patterns - Progress: +60 doc comment lines (210 → 270) - Update REFACTORING_ROADMAP.md (P4.12 partial completion) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,41 @@ use crate::tdlib::{ChatInfo, TdClient};
|
||||
use crate::types::{ChatId, MessageId};
|
||||
use ratatui::widgets::ListState;
|
||||
|
||||
/// Main application state for the Telegram TUI client.
|
||||
///
|
||||
/// Manages all application state including authentication, chats, messages,
|
||||
/// and UI state. Integrates with TDLib через `TdClient` and handles user input.
|
||||
///
|
||||
/// # State Machine
|
||||
///
|
||||
/// The app uses a type-safe state machine (`ChatState`) for chat-related operations:
|
||||
/// - `Normal` - default state
|
||||
/// - `MessageSelection` - selecting a message
|
||||
/// - `Editing` - editing a message
|
||||
/// - `Reply` - replying to a message
|
||||
/// - `Forward` - forwarding a message
|
||||
/// - `DeleteConfirmation` - confirming deletion
|
||||
/// - `ReactionPicker` - choosing a reaction
|
||||
/// - `Profile` - viewing profile
|
||||
/// - `SearchInChat` - searching within chat
|
||||
/// - `PinnedMessages` - viewing pinned messages
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// use tele_tui::app::App;
|
||||
/// use tele_tui::config::Config;
|
||||
///
|
||||
/// let config = Config::default();
|
||||
/// let mut app = App::new(config);
|
||||
///
|
||||
/// // Navigate through chats
|
||||
/// app.next_chat();
|
||||
/// app.previous_chat();
|
||||
///
|
||||
/// // Open a chat
|
||||
/// app.select_chat();
|
||||
/// ```
|
||||
pub struct App {
|
||||
pub config: crate::config::Config,
|
||||
pub screen: AppScreen,
|
||||
@@ -42,6 +77,18 @@ pub struct App {
|
||||
}
|
||||
|
||||
impl App {
|
||||
/// Creates a new App instance with the given configuration.
|
||||
///
|
||||
/// Initializes TDLib client, sets up empty chat list, and configures
|
||||
/// the app to start on the Loading screen.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `config` - Application configuration loaded from config.toml
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A new `App` instance ready to start authentication.
|
||||
pub fn new(config: crate::config::Config) -> App {
|
||||
let mut state = ListState::default();
|
||||
state.select(Some(0));
|
||||
|
||||
Reference in New Issue
Block a user