docs: Update function documentation to use block comments
Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
81
src/db.rs
81
src/db.rs
@@ -9,46 +9,49 @@ use std::collections::HashMap;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
/// Database module for the Keep application.
|
/*
|
||||||
///
|
Database module for the Keep application.
|
||||||
/// This module provides SQLite database operations for storing and retrieving
|
|
||||||
/// items, tags, and metadata. It includes schema migrations, CRUD operations,
|
This module provides SQLite database operations for storing and retrieving
|
||||||
/// and query utilities for efficient data access.
|
items, tags, and metadata. It includes schema migrations, CRUD operations,
|
||||||
///
|
and query utilities for efficient data access.
|
||||||
/// # Schema
|
|
||||||
///
|
# Schema
|
||||||
/// The database uses three main tables:
|
|
||||||
/// - `items`: Core item information (ID, timestamp, size, compression).
|
The database uses three main tables:
|
||||||
/// - `tags`: Item-tag associations (many-to-many).
|
- `items`: Core item information (ID, timestamp, size, compression).
|
||||||
/// - `metas`: Item-metadata associations (many-to-many).
|
- `tags`: Item-tag associations (many-to-many).
|
||||||
///
|
- `metas`: Item-metadata associations (many-to-many).
|
||||||
/// Foreign keys are enforced with cascading deletes. Indexes on tag and meta
|
|
||||||
/// names improve query performance.
|
Foreign keys are enforced with cascading deletes. Indexes on tag and meta
|
||||||
///
|
names improve query performance.
|
||||||
/// # Migrations
|
|
||||||
///
|
# Migrations
|
||||||
/// Automatic schema migrations are applied on database open using
|
|
||||||
/// `rusqlite_migration`. The current schema includes:
|
Automatic schema migrations are applied on database open using
|
||||||
/// - Items table with auto-increment ID.
|
`rusqlite_migration`. The current schema includes:
|
||||||
/// - Tags and metas tables with composite primary keys.
|
- Items table with auto-increment ID.
|
||||||
/// - Indexes on tag and meta names.
|
- Tags and metas tables with composite primary keys.
|
||||||
///
|
- Indexes on tag and meta names.
|
||||||
/// # Usage
|
|
||||||
///
|
# Usage
|
||||||
/// Open a connection:
|
|
||||||
/// ```
|
Open a connection:
|
||||||
/// let conn = db::open(PathBuf::from("keep.db"))?;
|
```
|
||||||
/// ```
|
let conn = db::open(PathBuf::from("keep.db"))?;
|
||||||
/// Insert an item:
|
```
|
||||||
/// ```
|
Insert an item:
|
||||||
/// let item = db::Item { id: None, ts: Utc::now(), size: None, compression: "lz4".to_string() };
|
```
|
||||||
/// let id = db::insert_item(&conn, item)?;
|
let item = db::Item { id: None, ts: Utc::now(), size: None, compression: "lz4".to_string() };
|
||||||
/// ```
|
let id = db::insert_item(&conn, item)?;
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Database schema migrations for the Keep application.
|
// Database schema migrations for the Keep application.
|
||||||
///
|
//
|
||||||
/// Defines the sequence of migrations to create and update the schema.
|
// Defines the sequence of migrations to create and update the schema.
|
||||||
/// Applied automatically when opening a database connection.
|
// Applied automatically when opening a database connection.
|
||||||
static ref MIGRATIONS: Migrations<'static> = Migrations::new(vec![
|
static ref MIGRATIONS: Migrations<'static> = Migrations::new(vec![
|
||||||
M::up(
|
M::up(
|
||||||
"CREATE TABLE items(
|
"CREATE TABLE items(
|
||||||
|
|||||||
@@ -60,17 +60,17 @@ use crate::common::status::{MetaPluginInfo, CompressionInfo};
|
|||||||
|
|
||||||
|
|
||||||
fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap<String, MetaPluginInfo>) -> Table {
|
fn build_meta_plugin_table(meta_plugin_info: &std::collections::HashMap<String, MetaPluginInfo>) -> Table {
|
||||||
/// Builds a formatted table displaying meta plugin information.
|
// Builds a formatted table displaying meta plugin information.
|
||||||
///
|
//
|
||||||
/// Sorts plugins by name and displays options as YAML and outputs as a list.
|
// Sorts plugins by name and displays options as YAML and outputs as a list.
|
||||||
///
|
//
|
||||||
/// # Arguments
|
// # Arguments
|
||||||
///
|
//
|
||||||
/// * `meta_plugin_info` - HashMap of meta plugin information.
|
// * `meta_plugin_info` - HashMap of meta plugin information.
|
||||||
///
|
//
|
||||||
/// # Returns
|
// # Returns
|
||||||
///
|
//
|
||||||
/// A formatted `comfy_table::Table`.
|
// A formatted `comfy_table::Table`.
|
||||||
let mut meta_plugin_table = crate::modes::common::create_table(true);
|
let mut meta_plugin_table = crate::modes::common::create_table(true);
|
||||||
|
|
||||||
meta_plugin_table.set_header(vec![
|
meta_plugin_table.set_header(vec![
|
||||||
@@ -291,20 +291,20 @@ pub fn mode_status_plugins(
|
|||||||
data_path: PathBuf,
|
data_path: PathBuf,
|
||||||
db_path: PathBuf,
|
db_path: PathBuf,
|
||||||
) -> Result<(), anyhow::Error> {
|
) -> Result<(), anyhow::Error> {
|
||||||
/// Displays status information for available plugins in the specified output format.
|
// Displays status information for available plugins in the specified output format.
|
||||||
///
|
//
|
||||||
/// Generates status using StatusService and renders as table, JSON, or YAML.
|
// Generates status using StatusService and renders as table, JSON, or YAML.
|
||||||
///
|
//
|
||||||
/// # Arguments
|
// # Arguments
|
||||||
///
|
//
|
||||||
/// * `cmd` - Mutable Clap command.
|
// * `cmd` - Mutable Clap command.
|
||||||
/// * `settings` - Application settings.
|
// * `settings` - Application settings.
|
||||||
/// * `data_path` - Data directory path.
|
// * `data_path` - Data directory path.
|
||||||
/// * `db_path` - Database path.
|
// * `db_path` - Database path.
|
||||||
///
|
//
|
||||||
/// # Returns
|
// # Returns
|
||||||
///
|
//
|
||||||
/// `Ok(())` on success, or anyhow::Error.
|
// `Ok(())` on success, or anyhow::Error.
|
||||||
debug!("STATUS_PLUGINS: Starting mode_status_plugins function");
|
debug!("STATUS_PLUGINS: Starting mode_status_plugins function");
|
||||||
|
|
||||||
let status_service = crate::services::status_service::StatusService::new();
|
let status_service = crate::services::status_service::StatusService::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user