Skip to content

Commit 90a6d2f

Browse files
committed
add examples of how API options affect the ouptut
1 parent 9225148 commit 90a6d2f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,43 @@ func main() {
8686

8787
Create a table with `NewTable` or `NewWriter`, configure it using options or a `Config` struct, add data with `Append` or `Bulk`, and render to an `io.Writer`. Use renderers like `Blueprint` (ASCII), `HTML`, `Markdown`, `Colorized`, or `Ocean` (streaming).
8888

89+
Here's how the API primitives map to the generated ASCII table:
90+
91+
```
92+
API Call ASCII Table Component
93+
-------- ---------------------
94+
95+
table.Header([]string{"NAME", "AGE"}) ┌──────┬─────┐ ← Borders.Top
96+
│ NAME │ AGE │ ← Header row
97+
├──────┼─────┤ ← Lines.ShowTop (header separator)
98+
99+
table.Append([]string{"Alice", "25"}) │ Alice│ 25 │ ← Data row
100+
├──────┼─────┤ ← Separators.BetweenRows
101+
102+
table.Append([]string{"Bob", "30"}) │ Bob │ 30 │ ← Data row
103+
├──────┼─────┤ ← Lines.ShowBottom (footer separator)
104+
105+
table.Footer([]string{"Total", "2"}) │ Total│ 2 │ ← Footer row
106+
└──────┴─────┘ ← Borders.Bottom
107+
```
108+
109+
The core components include:
110+
111+
- **Renderer** - Implements the core interface for converting table data into output formats. Available renderers include Blueprint (ASCII), HTML, Markdown, Colorized (ASCII with color), Ocean (streaming ASCII), and SVG.
112+
113+
- **Config** - The root configuration struct that controls all table behavior and appearance
114+
- **Behavior** - Controls high-level rendering behaviors including auto-hiding empty columns, trimming row whitespace, header/footer visibility, and compact mode for optimized merged cell calculations
115+
- **CellConfig** - The comprehensive configuration template used for table sections (header, row, footer). Combines formatting, padding, alignment, filtering, callbacks, and width constraints with global and per-column control
116+
- **StreamConfig** - Configuration for streaming mode including enable/disable state and strict column validation
117+
118+
- **Rendition** - Defines how a renderer formats tables and contains the complete visual styling configuration
119+
- **Borders** - Control the outer frame visibility (top, bottom, left, right edges) of the table
120+
- **Lines** - Control horizontal boundary lines (above/below headers, above footers) that separate different table sections
121+
- **Separators** - Control the visibility of separators between rows and between columns within the table content
122+
- **Symbols** - Define the characters used for drawing table borders, corners, and junctions
123+
124+
These components can be configured with various `tablewriter.With*()` functional options when creating a new table.
125+
89126
## Examples
90127

91128
### Basic Examples

0 commit comments

Comments
 (0)