Skip to content

Commit

Permalink
Merge pull request uutils#5432 from sylvestre/doc-ls-dired
Browse files Browse the repository at this point in the history
ls --dired: document the whole thing
  • Loading branch information
cakebaker committed Oct 20, 2023
2 parents eede467 + 4472acf commit f7a7589
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/uu/ls/src/dired.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@
// file that was distributed with this source code.
// spell-checker:ignore dired subdired

/// `dired` Module Documentation
///
/// This module handles the --dired output format, representing file and
/// directory listings.
///
/// Key Mechanisms:
/// 1. **Position Tracking**:
/// - The module tracks byte positions for each file or directory entry.
/// - `BytePosition`: Represents a byte range with start and end positions.
/// - `DiredOutput`: Contains positions for DIRED and SUBDIRED outputs and
/// maintains a padding value.
///
/// 2. **Padding**:
/// - Padding is used when dealing with directory names or the "total" line.
/// - The module adjusts byte positions by adding padding for these cases.
/// - This ensures correct offset for subsequent files or directories.
///
/// 3. **Position Calculation**:
/// - Functions like `calculate_dired`, `calculate_subdired`, and
/// `calculate_and_update_positions` compute byte positions based on output
/// length, previous positions, and padding.
///
/// 4. **Output**:
/// - The module provides functions to print the DIRED output
/// (`print_dired_output`) based on calculated positions and configuration.
/// - Helpers like `print_positions` print positions with specific prefixes.
///
/// Overall, the module ensures each entry in the DIRED output has the correct
/// byte position, considering additional lines or padding affecting positions.
///
use crate::Config;
use std::fmt;
use std::io::{BufWriter, Stdout, Write};
Expand Down

0 comments on commit f7a7589

Please sign in to comment.