From 0892d45331d78e86c6094d16e9b19501fadc62aa Mon Sep 17 00:00:00 2001 From: Adam Eury Date: Fri, 6 Sep 2024 14:13:20 -0400 Subject: [PATCH] Add doc comments. Add doc test. (#22) --- .github/workflows/nightly.yml | 6 ------ src/bytes.rs | 1 - src/lib.rs | 12 ++++++++++++ src/main.rs | 11 +++++++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e373128..d7f27e8 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,12 +6,6 @@ on: - "README.md" - "LICENSE-*" - ".gitignore" - pull_request: - branches: ["main"] - paths-ignore: - - "README.md" - - "LICENSE-*" - - ".gitignore" env: CARGO_TERM_COLOR: always diff --git a/src/bytes.rs b/src/bytes.rs index ad5b2d7..71b55c9 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -1,5 +1,4 @@ #![allow(clippy::cast_precision_loss)] - use std::fmt::Display; pub fn humanize(bytes: u64) -> String { diff --git a/src/lib.rs b/src/lib.rs index 73d2587..b14c209 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +//! Find large files on your system. mod bytes; mod files; @@ -10,6 +11,17 @@ use files::File; /// # Errors /// /// Returns an I/O error if unable to scan the provided path. +/// +/// # Examples +/// +/// ``` +/// # use spacehog::find_top_n_largest_files; +/// # fn main() { +/// let result = find_top_n_largest_files("testdata", 5).unwrap(); +/// +/// assert_eq!(result.len(), 4); +/// # } +/// ``` pub fn find_top_n_largest_files(path: &str, n: usize) -> io::Result> { let mut results = BTreeMap::new(); for file in files::from_path(path)? { diff --git a/src/main.rs b/src/main.rs index 4383370..4376460 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,14 @@ +//! A simple utility for finding large files on your system. +//! +//! Usage: spacehog [OPTIONS] [PATH] +//! +//! Arguments: +//! [PATH] [default: .] +//! +//! Options: +//! -n [default: 5] +//! -h, --help Print help +//! -V, --version Print version use clap::Parser; use spinoff::{spinners, Color, Spinner};