Skip to content

Commit eb029c4

Browse files
authored
documentation updates (#381)
1 parent 0238324 commit eb029c4

File tree

5 files changed

+401
-80
lines changed

5 files changed

+401
-80
lines changed

list/README.md

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
## List
1+
# List
22
[![Go Reference](https://pkg.go.dev/badge/github.com/jedib0t/go-pretty/v6/list.svg)](https://pkg.go.dev/github.com/jedib0t/go-pretty/v6/list)
33

44
Pretty-print lists with multiple levels/indents into ASCII/Unicode strings.
55

6-
- Append Items one-by-one or as a group
7-
- Indent/UnIndent as you like
8-
- Support Items with Multiple-lines
9-
- Mirror output to an io.Writer object (like os.StdOut)
10-
- Completely customizable styles
11-
- Many ready-to-use styles: [style.go](style.go)
12-
- Render as:
13-
- (ASCII/Unicode) List
14-
- HTML List (with custom CSS Class)
15-
- Markdown List
6+
## Sample List Output
167

178
```
189
■ Game Of Thrones
@@ -28,3 +19,56 @@ Pretty-print lists with multiple levels/indents into ASCII/Unicode strings.
2819

2920
A demonstration of all the capabilities can be found here:
3021
[../cmd/demo-list](../cmd/demo-list)
22+
23+
## Features
24+
25+
### Core List Building
26+
27+
- Append items one-by-one or as a group
28+
- Support items with multiple lines (newlines preserved)
29+
- Automatic handling of tabs (converted to spaces)
30+
- Reset list to initial state for reuse
31+
32+
### Indentation Control
33+
34+
- Indent following items to create nested levels
35+
- UnIndent to move back to previous level
36+
- UnIndentAll to return to root level
37+
- Smart indentation prevents invalid nesting
38+
39+
### Rendering Formats
40+
41+
- **ASCII/Unicode List** - Human-readable pretty format with customizable bullets and connectors
42+
- **HTML List** - Generate nested `<ul>` and `<li>` elements with custom CSS classes
43+
- Automatic CSS class numbering for nested levels (e.g., `class-1`, `class-2`)
44+
- HTML entity escaping for safe rendering
45+
- Multi-line support with `<br/>` tags
46+
- **Markdown List** - Generate markdown-compatible list format
47+
- Automatically uses markdown-appropriate styling
48+
49+
### Customization & Styling
50+
51+
- Completely customizable styles
52+
- Many ready-to-use styles: [style.go](style.go)
53+
- `StyleDefault` - Simple asterisk bullets (*)
54+
- `StyleBulletCircle` - Circle bullets (●)
55+
- `StyleBulletFlower` - Flower bullets (✽)
56+
- `StyleBulletSquare` - Square bullets (■)
57+
- `StyleBulletStar` - Star bullets (★)
58+
- `StyleBulletTriangle` - Triangle bullets (▶)
59+
- `StyleConnectedBold` - Bold box-drawing connectors (┏━, ┣━, ┗━)
60+
- `StyleConnectedDouble` - Double box-drawing connectors (╔═, ╠═, ╚═)
61+
- `StyleConnectedLight` - Light box-drawing connectors (┌─, ├─, └─)
62+
- `StyleConnectedRounded` - Rounded box-drawing connectors (╭─, ├─, ╰─)
63+
- `StyleMarkdown` - Markdown-compatible styling
64+
- Customize bullet characters for different positions (top, first, middle, bottom, single)
65+
- Customize vertical connectors between levels
66+
- Set line prefix for all lines
67+
- Apply text formatting (colors, styles) using `text.Format`
68+
- HTML CSS class customization for styled HTML output
69+
70+
### Output Control
71+
72+
- Mirror output to an io.Writer object (like os.StdOut) while rendering
73+
- Get rendered output as string for further processing
74+
- Length() method to get the number of items in the list

progress/README.md

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,70 @@
44
Track the Progress of one or more Tasks (like downloading multiple files in
55
parallel).
66

7+
## Sample Progress Tracking
8+
9+
<img src="images/demo.gif" width="640px"/>
10+
11+
A demonstration of all the capabilities can be found here:
12+
[../cmd/demo-progress](../cmd/demo-progress)
13+
14+
## Features
15+
16+
### Core Tracking
17+
718
- Track one or more Tasks at the same time
19+
- Support for both determinate (with Total) and indeterminate (without Total)
20+
trackers
21+
- Error tracking with `MarkAsErrored()` for failed tasks
22+
- ETA (Estimated Time of Arrival) calculation for each tracker
23+
- Speed calculation (items/bytes per second) with customizable formatters
24+
- Overall progress tracker that aggregates progress across all trackers
25+
26+
### Tracker Management
27+
828
- Dynamically add one or more Task Trackers while `Render()` is in progress
29+
- Sort trackers by Message, Percentage, or Value (ascending/descending)
30+
- Tracker options
31+
- `DeferStart` - Delay tracker start until manually triggered
32+
- `RemoveOnCompletion` - Hide tracker when done instead of showing completion
33+
- `AutoStopDisabled` - Prevent auto-completion when value exceeds total
34+
35+
### Display & Rendering
36+
937
- Choose to have the Writer auto-stop the Render when no more Trackers are
1038
in queue, or manually stop using `Stop()`
1139
- Redirect output to an io.Writer object (like os.StdOut)
40+
- Pinned messages that stay visible above all trackers
41+
- Log messages during rendering that appear temporarily
42+
- Automatic terminal width detection to prevent line wrapping
43+
- Flexible tracker positioning (left or right of message)
44+
- Configurable update frequency for smooth rendering
45+
46+
### Customization & Styling
47+
1248
- Completely customizable styles
1349
- Many ready-to-use styles: [style.go](style.go)
50+
- `StyleDefault` - ASCII characters
51+
- `StyleBlocks` - UNICODE Block Drawing characters
52+
- `StyleCircle` - UNICODE Circle runes
53+
- `StyleRhombus` - UNICODE Rhombus runes
1454
- Colorize various parts of the Tracker using `StyleColors`
1555
- Customize how Trackers get rendered using `StyleOptions`
56+
- Control visibility of components (ETA, Speed, Time, Value, etc.)
57+
- Custom renderers for determinate and indeterminate progress bars
58+
- Multiple indeterminate indicator animations
59+
- Moving back and forth
60+
- Moving left to right
61+
- Moving right to left
62+
- Dominoes effect
63+
- Pac-Man chomping animation
64+
- Colored variants
1665

17-
A demonstration of all the capabilities can be found here:
18-
[../cmd/demo-progress](../cmd/demo-progress)
19-
20-
## Sample Progress Tracking
21-
22-
<img src="images/demo.gif" width="640px"/>
23-
24-
# TODO
66+
### Units & Formatting
2567

26-
- Optimize CPU and Memory Usage
68+
- Built-in unit formatters
69+
- `UnitsDefault` - Regular numbers (K, M, B, T, Q notation)
70+
- `UnitsBytes` - Storage units (B, KB, MB, GB, TB, PB)
71+
- `UnitsCurrencyDollar` - Dollar amounts ($x.yzK, etc.)
72+
- `UnitsCurrencyEuro` - Euro amounts (₠x.yzK, etc.)
73+
- `UnitsCurrencyPound` - Pound amounts (£x.yzK, etc.)

progress/progress_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,36 @@ func TestProgress_OverallTrackerDisappearsCase(t *testing.T) {
255255

256256
assert.Equal(t, false, p.overallTracker.IsDone())
257257
}
258+
259+
func TestProgress_watchTerminalSize(t *testing.T) {
260+
p := &Progress{}
261+
// Set up a cancellable context for watchTerminalSize
262+
p.renderContext, p.renderContextCancel = context.WithCancel(context.Background())
263+
264+
// Call watchTerminalSize in a goroutine
265+
done := make(chan bool)
266+
go func() {
267+
p.watchTerminalSize()
268+
done <- true
269+
}()
270+
271+
// Wait a bit to let the ticker fire at least once (covers case <-ticker.C)
272+
time.Sleep(150 * time.Millisecond)
273+
p.renderContextCancel()
274+
275+
// Wait for the goroutine to exit (with timeout)
276+
select {
277+
case <-done:
278+
// Success: goroutine exited after context cancellation
279+
case <-time.After(1 * time.Second):
280+
t.Fatal("watchTerminalSize goroutine did not exit after context cancellation")
281+
}
282+
283+
// Verify the context was cancelled
284+
select {
285+
case <-p.renderContext.Done():
286+
// Context is cancelled, which is expected
287+
default:
288+
t.Fatal("Expected context to be cancelled")
289+
}
290+
}

0 commit comments

Comments
 (0)