Skip to content

Commit 2907d9c

Browse files
committed
docs: add function-level rustdoc comments (#12)
1 parent 231a2fa commit 2907d9c

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/config/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ fn db_path() -> PathBuf {
5454
}
5555
}
5656

57+
/// Prints the resolved SQLite database path.
5758
pub fn print_db_path() {
5859
println!("{}", db_path().display());
5960
}
@@ -273,6 +274,7 @@ async fn add_friend(friend_info: FriendInfo) {
273274
}
274275
}
275276

277+
/// Removes a friend by exact name.
276278
pub async fn remove_friend(name: String) {
277279
let mut config = match read_config().await {
278280
Ok(config) => config,
@@ -294,6 +296,7 @@ pub async fn remove_friend(name: String) {
294296
}
295297
}
296298

299+
/// Edits friend name and/or level.
297300
pub async fn edit_friend(name: String, new_name: Option<String>, new_level: Option<String>) {
298301
if new_name.is_none() && new_level.is_none() {
299302
println!("No changes requested");
@@ -340,24 +343,28 @@ pub async fn edit_friend(name: String, new_name: Option<String>, new_level: Opti
340343
}
341344
}
342345

346+
/// Adds an `aji` friend.
343347
pub async fn add_aji(name: String) {
344348
if let Some(friend_info) = make_friend(name, "aji") {
345349
add_friend(friend_info).await;
346350
}
347351
}
348352

353+
/// Adds a `ki` friend.
349354
pub async fn add_ki(name: String) {
350355
if let Some(friend_info) = make_friend(name, "ki") {
351356
add_friend(friend_info).await;
352357
}
353358
}
354359

360+
/// Adds a `chi` friend.
355361
pub async fn add_chi(name: String) {
356362
if let Some(friend_info) = make_friend(name, "chi") {
357363
add_friend(friend_info).await;
358364
}
359365
}
360366

367+
/// Adds multiple friends with the same level.
361368
pub async fn add_many_friends(level: String, names: Vec<String>) {
362369
if names.is_empty() {
363370
println!("Please specify at least one name");
@@ -402,6 +409,7 @@ pub async fn add_many_friends(level: String, names: Vec<String>) {
402409
}
403410
}
404411

412+
/// Lists friends, optionally filtered by level and/or sorted by chance.
405413
pub async fn list_friends(level_filter: Option<String>, sort_chance: bool) {
406414
let config = match read_config().await {
407415
Ok(config) => config,
@@ -423,6 +431,7 @@ pub async fn list_friends(level_filter: Option<String>, sort_chance: bool) {
423431
println!("{rendered_list}");
424432
}
425433

434+
/// Searches friends by case-insensitive partial name.
426435
pub async fn search_friends(query: String) {
427436
let config = match read_config().await {
428437
Ok(config) => config,
@@ -435,6 +444,7 @@ pub async fn search_friends(query: String) {
435444
println!("{}", utils::search_friends(&config, &query));
436445
}
437446

447+
/// Suggests one friend using weighted random chance.
438448
pub async fn suggest() {
439449
let config = match read_config().await {
440450
Ok(config) => config,
@@ -506,22 +516,27 @@ async fn add_memory(kind: &str, reduction: f64, names: &[String]) {
506516
}
507517
}
508518

519+
/// Records a `hangout` memory.
509520
pub async fn add_hangout(names: &[String]) {
510521
add_memory("hangout", default_reduction::HANGOUT, names).await
511522
}
512523

524+
/// Records a `video-call` memory.
513525
pub async fn add_video_call(names: &[String]) {
514526
add_memory("video-call", default_reduction::VIDEO_CALL, names).await
515527
}
516528

529+
/// Records a `call` memory.
517530
pub async fn add_call(names: &[String]) {
518531
add_memory("call", default_reduction::CALL, names).await
519532
}
520533

534+
/// Records a `text` memory.
521535
pub async fn add_text(names: &[String]) {
522536
add_memory("text", default_reduction::TEXT, names).await
523537
}
524538

539+
/// Undoes the latest recorded memory.
525540
pub async fn undo_memory() {
526541
let memories = match read_memories().await {
527542
Ok(memories) => memories,
@@ -552,6 +567,7 @@ pub async fn undo_memory() {
552567
}
553568
}
554569

570+
/// Removes a memory by database id.
555571
pub async fn remove_memory(id: i64) {
556572
match delete_memory(id).await {
557573
Ok(true) => {}

src/friend.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub struct FriendCommandBase {
88
}
99

1010
#[derive(ValueEnum, Clone)]
11+
/// Supported friend closeness levels.
1112
pub enum FriendLevel {
1213
Aji,
1314
Ki,
@@ -50,6 +51,7 @@ pub struct ChangeTypeCommand {
5051

5152
#[derive(Subcommand)]
5253
#[command(about = "Add or list friends")]
54+
/// Friend-related subcommands.
5355
pub enum FriendCommand {
5456
Aji(FriendCommandBase),
5557
Ki(FriendCommandBase),
@@ -64,11 +66,13 @@ pub enum FriendCommand {
6466
}
6567

6668
#[derive(Parser)]
69+
/// Root wrapper for `akc friend ...`.
6770
pub struct Friend {
6871
#[command(subcommand)]
6972
command: FriendCommand,
7073
}
7174

75+
/// Executes parsed friend commands.
7276
pub async fn handle(args: Friend) {
7377
match args.command {
7478
FriendCommand::Aji(name_wrapper) => config::add_aji(name_wrapper.name).await,

src/memory.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct MemoryIdCommandBase {
1414

1515
#[derive(Subcommand)]
1616
#[command(about = "Add a memory with one or more friends")]
17+
/// Memory-related subcommands.
1718
pub enum MemoryCommand {
1819
Hangout(MemoryCommandBase),
1920
VideoCall(MemoryCommandBase),
@@ -25,11 +26,13 @@ pub enum MemoryCommand {
2526
}
2627

2728
#[derive(Parser)]
29+
/// Root wrapper for `akc memory ...`.
2830
pub struct Memory {
2931
#[command(subcommand)]
3032
command: MemoryCommand,
3133
}
3234

35+
/// Executes parsed memory commands.
3336
pub async fn handle(args: Memory) {
3437
match args.command {
3538
MemoryCommand::Hangout(names_wrapper) => config::add_hangout(&names_wrapper.names).await,

src/suggest.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ use crate::config;
44

55
#[derive(Parser)]
66
#[command(about = "Suggests a friend to connect with randomly")]
7+
/// Command wrapper for `akc suggest`.
78
pub struct SuggestCommand {}
89

10+
/// Runs suggestion flow.
911
pub async fn handle() {
1012
config::suggest().await
1113
}

0 commit comments

Comments
 (0)