From 8e43cd2afabdec8cfec46a5cca0d548164baa8d5 Mon Sep 17 00:00:00 2001 From: Antonios Barotsis Date: Sat, 27 Jan 2024 11:20:12 +0100 Subject: [PATCH] Change existing method docs to valid rustdoc --- src/commands/decompress.rs | 12 ++++++------ src/commands/list.rs | 4 ++-- src/extension.rs | 2 +- tests/integration.rs | 20 ++++++++++---------- tests/utils.rs | 8 ++++---- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/commands/decompress.rs b/src/commands/decompress.rs index b36fc5b..5e611f9 100644 --- a/src/commands/decompress.rs +++ b/src/commands/decompress.rs @@ -18,12 +18,12 @@ use crate::{ QuestionAction, QuestionPolicy, BUFFER_CAPACITY, }; -// Decompress a file -// -// File at input_file_path is opened for reading, example: "archive.tar.gz" -// formats contains each format necessary for decompression, example: [Gz, Tar] (in decompression order) -// output_dir it's where the file will be decompressed to, this function assumes that the directory exists -// output_file_path is only used when extracting single file formats, not archive formats like .tar or .zip +/// Decompress a file +/// +/// File at input_file_path is opened for reading, example: "archive.tar.gz" +/// formats contains each format necessary for decompression, example: [Gz, Tar] (in decompression order) +/// output_dir it's where the file will be decompressed to, this function assumes that the directory exists +/// output_file_path is only used when extracting single file formats, not archive formats like .tar or .zip pub fn decompress_file( input_file_path: &Path, formats: Vec, diff --git a/src/commands/list.rs b/src/commands/list.rs index 448b51c..05e37c3 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -13,8 +13,8 @@ use crate::{ QuestionAction, QuestionPolicy, BUFFER_CAPACITY, }; -// File at input_file_path is opened for reading, example: "archive.tar.gz" -// formats contains each format necessary for decompression, example: [Gz, Tar] (in decompression order) +/// File at input_file_path is opened for reading, example: "archive.tar.gz" +/// formats contains each format necessary for decompression, example: [Gz, Tar] (in decompression order) pub fn list_archive_contents( archive_path: &Path, formats: Vec, diff --git a/src/extension.rs b/src/extension.rs index 4880d09..d602ec7 100644 --- a/src/extension.rs +++ b/src/extension.rs @@ -197,7 +197,7 @@ pub fn extensions_from_path(path: &Path) -> Vec { extensions } -// Panics if formats has an empty list of compression formats +/// Panics if formats has an empty list of compression formats pub fn split_first_compression_format(formats: &[Extension]) -> (CompressionFormat, Vec) { let mut extensions: Vec = flatten_compression_formats(formats); let first_extension = extensions.remove(0); diff --git a/tests/integration.rs b/tests/integration.rs index cfdbc7f..bc20a0e 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -12,7 +12,7 @@ use test_strategy::{proptest, Arbitrary}; use crate::utils::{assert_same_directory, write_random_content}; -// tar and zip extensions +/// tar and zip extensions #[derive(Arbitrary, Debug, Display)] #[display(style = "lowercase")] enum DirectoryExtension { @@ -30,7 +30,7 @@ enum DirectoryExtension { Zip, } -// extensions of single file compression formats +/// Extensions of single file compression formats #[derive(Arbitrary, Debug, Display)] #[display(style = "lowercase")] enum FileExtension { @@ -51,7 +51,7 @@ enum Extension { File(FileExtension), } -// converts a list of extension structs to string +/// Converts a list of extension structs to string fn merge_extensions(ext: impl ToString, exts: Vec) -> String { once(ext.to_string()) .chain(exts.into_iter().map(|x| x.to_string())) @@ -59,7 +59,7 @@ fn merge_extensions(ext: impl ToString, exts: Vec) -> String { .join(".") } -// create random nested directories and files under the specified directory +/// Create random nested directories and files under the specified directory fn create_random_files(dir: impl Into, depth: u8, rng: &mut SmallRng) { if depth == 0 { return; @@ -81,7 +81,7 @@ fn create_random_files(dir: impl Into, depth: u8, rng: &mut SmallRng) { } } -// compress and decompress a single empty file +/// Compress and decompress a single empty file #[proptest(cases = 200)] fn single_empty_file(ext: Extension, #[any(size_range(0..8).lift())] exts: Vec) { let dir = tempdir().unwrap(); @@ -100,7 +100,7 @@ fn single_empty_file(ext: Extension, #[any(size_range(0..8).lift())] exts: Vec { @@ -49,15 +49,15 @@ pub fn create_files_in(dir: &Path, files: &[&str]) { } } -// write random content to a file +/// Write random content to a file pub fn write_random_content(file: &mut impl Write, rng: &mut impl RngCore) { let mut data = vec![0; rng.gen_range(0..4096)]; rng.fill_bytes(&mut data); file.write_all(&data).unwrap(); } -// check that two directories have the exact same content recursively -// checks equility of file types if preserve_permissions is true, ignored on non-unix +/// Check that two directories have the exact same content recursively. +/// Checks equility of file types if preserve_permissions is true, ignored on non-unix // Silence clippy warning that triggers because of the `#[cfg(unix)]` on Windows. #[allow(clippy::only_used_in_recursion)] pub fn assert_same_directory(x: impl Into, y: impl Into, preserve_permissions: bool) {