Skip to content

Commit 99e41fa

Browse files
committed
ls --dired: document the whole thing
1 parent c27fcc4 commit 99e41fa

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/uu/ls/src/dired.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,36 @@
44
// file that was distributed with this source code.
55
// spell-checker:ignore dired subdired
66

7+
/// `dired` Module Documentation
8+
///
9+
/// This module handles the --dired output format, representing file and
10+
/// directory listings.
11+
///
12+
/// Key Mechanisms:
13+
/// 1. **Position Tracking**:
14+
/// - The module tracks byte positions for each file or directory entry.
15+
/// - `BytePosition`: Represents a byte range with start and end positions.
16+
/// - `DiredOutput`: Contains positions for DIRED and SUBDIRED outputs and
17+
/// maintains a padding value.
18+
///
19+
/// 2. **Padding**:
20+
/// - Padding is used when dealing with directory names or the "total" line.
21+
/// - The module adjusts byte positions by adding padding for these cases.
22+
/// - This ensures correct offset for subsequent files or directories.
23+
///
24+
/// 3. **Position Calculation**:
25+
/// - Functions like `calculate_dired`, `calculate_subdired`, and
26+
/// `calculate_and_update_positions` compute byte positions based on output
27+
/// length, previous positions, and padding.
28+
///
29+
/// 4. **Output**:
30+
/// - The module provides functions to print the DIRED output
31+
/// (`print_dired_output`) based on calculated positions and configuration.
32+
/// - Helpers like `print_positions` print positions with specific prefixes.
33+
///
34+
/// Overall, the module ensures each entry in the DIRED output has the correct
35+
/// byte position, considering additional lines or padding affecting positions.
36+
///
737
use crate::Config;
838
use std::fmt;
939
use std::io::{BufWriter, Stdout, Write};

0 commit comments

Comments
 (0)