From f9d9231d50bcee3e13bb2f598b2de7f047b77c2e Mon Sep 17 00:00:00 2001 From: Priec Date: Mon, 18 Aug 2025 21:10:06 +0200 Subject: [PATCH] more prod ready comments --- canvas/src/computed/mod.rs | 8 +++++++- canvas/src/computed/provider.rs | 7 ++++--- canvas/src/computed/state.rs | 17 ++++++++--------- canvas/src/editor/mod.rs | 6 +++++- canvas/src/suggestions/mod.rs | 4 ++++ canvas/src/textarea/mod.rs | 5 +++++ canvas/src/validation/formatting.rs | 13 +++++++++---- canvas/src/validation/mod.rs | 7 ++++++- 8 files changed, 48 insertions(+), 19 deletions(-) diff --git a/canvas/src/computed/mod.rs b/canvas/src/computed/mod.rs index 4fcf7eb..c040644 100644 --- a/canvas/src/computed/mod.rs +++ b/canvas/src/computed/mod.rs @@ -1,5 +1,11 @@ +//! Computed fields subsystem. +//! +//! This module exposes the provider trait and the internal state management +//! for computed (display-only) fields. Computed fields are values derived +//! from other fields in the form and are not directly editable by the user. + pub mod provider; pub mod state; pub use provider::{ComputedContext, ComputedProvider}; -pub use state::ComputedState; \ No newline at end of file +pub use state::ComputedState; diff --git a/canvas/src/computed/provider.rs b/canvas/src/computed/provider.rs index f8dd241..7d57ddb 100644 --- a/canvas/src/computed/provider.rs +++ b/canvas/src/computed/provider.rs @@ -1,6 +1,7 @@ -// ================================================================================================ -// COMPUTED FIELDS - Provider and Context -// ================================================================================================ +//! Provider interface and context for computed/display-only fields. +//! +//! Implementors provide logic to compute a field's display value from the +//! other field values in the form. /// Context information provided to computed field calculations #[derive(Debug, Clone)] diff --git a/canvas/src/computed/state.rs b/canvas/src/computed/state.rs index 4ce10b4..4eb0eef 100644 --- a/canvas/src/computed/state.rs +++ b/canvas/src/computed/state.rs @@ -1,11 +1,10 @@ -/* file: canvas/src/computed/state.rs */ -/* -Add computed state module file implementing caching and dependencies -*/ - -// ================================================================================================ -// COMPUTED FIELDS - State: caching and dependencies -// ================================================================================================ +// src/computed/state.rs +//! Computed field state: caching and dependency graph. +//! +//! This module holds the internal state necessary to track which fields are +//! computed, their dependencies, and cached computed values. It is used by the +//! editor to avoid unnecessary recomputation and to present computed fields as +//! read-only. use std::collections::{HashMap, HashSet}; @@ -85,4 +84,4 @@ impl Default for ComputedState { fn default() -> Self { Self::new() } -} \ No newline at end of file +} diff --git a/canvas/src/editor/mod.rs b/canvas/src/editor/mod.rs index 6a92da2..024e25a 100644 --- a/canvas/src/editor/mod.rs +++ b/canvas/src/editor/mod.rs @@ -1,5 +1,9 @@ // src/editor/mod.rs -// Only module declarations and re-exports. +//! Editor submodule exports. +//! +//! This module exposes the internal editor pieces (core, editing, movement, +//! navigation, mode, and optional features like suggestions, validation, and +//! computed field helpers). Only module declarations and re-exports live here. pub mod core; pub mod display; diff --git a/canvas/src/suggestions/mod.rs b/canvas/src/suggestions/mod.rs index 02354e5..2cad0eb 100644 --- a/canvas/src/suggestions/mod.rs +++ b/canvas/src/suggestions/mod.rs @@ -1,4 +1,8 @@ // src/suggestions/mod.rs +//! Suggestions subsystem - provider and optional GUI. +//! +//! Contains the suggestion provider types used by the editor and, when the GUI +//! feature is enabled, the rendering helpers for the suggestions dropdown. pub mod state; #[cfg(feature = "gui")] diff --git a/canvas/src/textarea/mod.rs b/canvas/src/textarea/mod.rs index 8a064a6..58c766a 100644 --- a/canvas/src/textarea/mod.rs +++ b/canvas/src/textarea/mod.rs @@ -1,4 +1,9 @@ // src/textarea/mod.rs +//! Text area convenience exports. +//! +//! Re-export the core textarea types and provider so consumers can use +//! `canvas::textarea::TextArea` / `TextAreaState` / `TextAreaProvider`. + pub mod provider; pub mod state; diff --git a/canvas/src/validation/formatting.rs b/canvas/src/validation/formatting.rs index 7ce6ca2..d55287c 100644 --- a/canvas/src/validation/formatting.rs +++ b/canvas/src/validation/formatting.rs @@ -1,6 +1,11 @@ -/* canvas/src/validation/formatting.rs - Add new formatting module with CustomFormatter, PositionMapper, DefaultPositionMapper, and FormattingResult -*/ +// src/validation/formatting.rs +//! Custom formatting and position mapping for validation/display. +//! +//! This module defines the CustomFormatter trait along with helpers to map +//! cursor positions between the raw stored text and the formatted display +//! representation. Implementors may provide a custom PositionMapper to handle +//! advanced formatting scenarios. + use std::sync::Arc; /// Bidirectional mapping between raw input positions and formatted display positions. @@ -214,4 +219,4 @@ mod tests { _ => panic!("expected success"), } } -} \ No newline at end of file +} diff --git a/canvas/src/validation/mod.rs b/canvas/src/validation/mod.rs index 18b898e..9cd7917 100644 --- a/canvas/src/validation/mod.rs +++ b/canvas/src/validation/mod.rs @@ -1,6 +1,11 @@ // src/validation/mod.rs +//! Validation subsystem re-exports and helpers. +//! +//! This module collects validation-related modules (limits, masks, patterns, +//! formatting, and state) and re-exports the most commonly used types so that +//! callers can import them from `crate::validation`. -// Core validation modules + // Core validation modules pub mod config; pub mod limits; pub mod state;