docs: Add Rustdoc for pages.rs structs and functions

Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-10 15:56:45 -03:00
parent e9ab630a74
commit 11ec6cf01e
2 changed files with 43 additions and 3 deletions

View File

@@ -13,9 +13,9 @@ Private helpers (e.g., internal `fn` without `pub`) are not flagged, as they don
### Files with Incomplete Rustdoc ### Files with Incomplete Rustdoc
1. **src/modes/server/pages.rs** [DONE] 1. **src/modes/server/pages.rs** [DONE]
- `ListQueryParams` struct: Missing doc comment entirely. - `ListQueryParams` struct: [DONE]
- `default_sort()` and `default_count()` functions: No doc comments. - `default_sort()` and `default_count()` functions: [DONE]
- `add_routes()` function: Partial doc (missing examples or errors). - `add_routes()` function: [DONE]
- `list_items()` function: No doc comment. - `list_items()` function: No doc comment.
- `build_item_list()` function: No doc comment. - `build_item_list()` function: No doc comment.
- `style_css()` function: No doc comment. - `style_css()` function: No doc comment.

View File

@@ -12,6 +12,17 @@ use crate::config::ColumnConfig;
use std::collections::HashMap; use std::collections::HashMap;
#[derive(Deserialize)] #[derive(Deserialize)]
/// Query parameters for the item list endpoint.
///
/// This struct defines the query parameters used to filter, sort, and paginate
/// the list of items displayed on the main page.
///
/// # Fields
///
/// * `sort` - Sorting order, defaults to "newest".
/// * `tags` - Optional comma-separated list of tags to filter by.
/// * `count` - Number of items per page, defaults to 1000.
/// * `start` - Starting index for pagination, defaults to 0.
pub struct ListQueryParams { pub struct ListQueryParams {
#[serde(default = "default_sort")] #[serde(default = "default_sort")]
sort: String, sort: String,
@@ -27,10 +38,39 @@ fn default_sort() -> String {
"newest".to_string() "newest".to_string()
} }
/// Provides the default sorting order for item lists.
///
/// # Returns
///
/// A string representing the default sort order: "newest".
fn default_count() -> usize { fn default_count() -> usize {
1000 1000
} }
/// Provides the default number of items to display per page.
///
/// # Returns
///
/// The default count: 1000.
/// Adds the web page routes to the Axum router.
///
/// This function configures the routes for the web interface, including the
/// main item list, individual item details, and static CSS styles.
///
/// # Arguments
///
/// * `app` - The existing Axum router with application state.
///
/// # Returns
///
/// The updated router with web routes added.
///
/// # Examples
///
/// ```
/// let app = pages::add_routes(axum::Router::new());
/// ```
pub fn add_routes(app: axum::Router<AppState>) -> axum::Router<AppState> { pub fn add_routes(app: axum::Router<AppState>) -> axum::Router<AppState> {
app app
.route("/", axum::routing::get(list_items)) .route("/", axum::routing::get(list_items))