Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regenerate docs #286

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
96 changes: 58 additions & 38 deletions advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
│ hello │ howdy │
└───────┴───────┘
```javascript
var table = new Table({style:{head:[],border:[]}});
let table = new Table({ style: { head: [], border: [] } });

table.push(
[{colSpan:2,content:'greetings'}],
[{colSpan:2,content:'greetings'}],
['hello','howdy']
[{ colSpan: 2, content: 'greetings' }],
[{ colSpan: 2, content: 'greetings' }],
['hello', 'howdy']
);

```
Expand All @@ -27,12 +27,12 @@
│ greetings │
└───────────────┘
```javascript
var table = new Table({style:{head:[],border:[]}});
let table = new Table({ style: { head: [], border: [] } });

table.push(
['hello','howdy'],
[{colSpan:2,content:'greetings'}],
[{colSpan:2,content:'greetings'}]
['hello', 'howdy'],
[{ colSpan: 2, content: 'greetings' }],
[{ colSpan: 2, content: 'greetings' }]
);

```
Expand All @@ -45,10 +45,10 @@
│ │ │ howdy │
└───────────┴───────────┴───────┘
```javascript
var table = new Table({style:{head:[],border:[]}});
let table = new Table({ style: { head: [], border: [] } });

table.push(
[{rowSpan:2,content:'greetings'},{rowSpan:2,content:'greetings',vAlign:'center'},'hello'],
[{ rowSpan: 2, content: 'greetings' }, { rowSpan: 2, content: 'greetings', vAlign: 'center' }, 'hello'],
['howdy']
);

Expand All @@ -62,10 +62,10 @@
│ howdy │ │ greetings │
└───────┴───────────┴───────────┘
```javascript
var table = new Table({style:{head:[],border:[]}});
let table = new Table({ style: { head: [], border: [] } });

table.push(
['hello',{rowSpan:2,content:'greetings'},{rowSpan:2,content:'greetings',vAlign:'bottom'}],
['hello', { rowSpan: 2, content: 'greetings' }, { rowSpan: 2, content: 'greetings', vAlign: 'bottom' }],
['howdy']
);

Expand All @@ -81,12 +81,16 @@
│ o │ k │ │ │ │
└───┴───┴──┴──┴────┘
```javascript
var table = new Table({style:{head:[],border:[]}});
let table = new Table({ style: { head: [], border: [] } });

table.push(
[{content:'hello',colSpan:2},{rowSpan:2, colSpan:2,content:'sup'},{rowSpan:3,content:'hi'}],
[{content:'howdy',colSpan:2}],
['o','k','','']
[
{ content: 'hello', colSpan: 2 },
{ rowSpan: 2, colSpan: 2, content: 'sup' },
{ rowSpan: 3, content: 'hi' },
],
[{ content: 'howdy', colSpan: 2 }],
['o', 'k', '', '']
);

```
Expand All @@ -99,10 +103,10 @@
│ howdy │ │ │
└───────┴───────────┴───────────┘
```javascript
var table = new Table({style:{head:[],border:[]}});
let table = new Table({ style: { head: [], border: [] } });

table.push(
['hello',{rowSpan:2,content:'greetings\nfriends'},{rowSpan:2,content:'greetings\nfriends'}],
['hello', { rowSpan: 2, content: 'greetings\nfriends' }, { rowSpan: 2, content: 'greetings\nfriends' }],
['howdy']
);

Expand All @@ -118,12 +122,16 @@
│ o │ k │ │ │ │
└───┴───┴──┴──┴────┘
```javascript
var table = new Table({style:{head:[],border:[]}});
let table = new Table({ style: { head: [], border: [] } });

table.push(
[{content:'hello',colSpan:2},{rowSpan:2, colSpan:2,content:'sup\nman\nhey'},{rowSpan:3,content:'hi\nyo'}],
[{content:'howdy',colSpan:2}],
['o','k','','']
[
{ content: 'hello', colSpan: 2 },
{ rowSpan: 2, colSpan: 2, content: 'sup\nman\nhey' },
{ rowSpan: 3, content: 'hi\nyo' },
],
[{ content: 'howdy', colSpan: 2 }],
['o', 'k', '', '']
);

```
Expand All @@ -138,11 +146,11 @@
│ d │ │
└───┴───┘
```javascript
var table = new Table({style:{head:[],border:[]}});
let table = new Table({ style: { head: [], border: [] } });

table.push(
[{content:'a',rowSpan:2},'b'],
[{content:'c',rowSpan:2}],
[{ content: 'a', rowSpan: 2 }, 'b'],
[{ content: 'c', rowSpan: 2 }],
['d']
);

Expand All @@ -160,13 +168,13 @@
│ │ │
└───┴──────┘
```javascript
var table = new Table({style:{head:[],border:[]}});
let table = new Table({ style: { head: [], border: [] } });

//notice we only create 3 cells here, but the table ends up having 6.
table.push(
[{content:'a',rowSpan:3,colSpan:2},'b'],
[{ content: 'a', rowSpan: 3, colSpan: 2 }, 'b'],
[],
[{content:'c',rowSpan:2,colSpan:2}],
[{ content: 'c', rowSpan: 2, colSpan: 2 }],
[]
);
```
Expand All @@ -178,7 +186,10 @@
│ hi… │
└───────┘
```javascript
var table = new Table({rowHeights:[2],style:{head:[],border:[]}});
let table = new Table({
rowHeights: [2],
style: { head: [], border: [] },
});

table.push(['hello\nhi\nsup']);

Expand All @@ -192,10 +203,10 @@
│ hi │ hi │
└──────┴──────┘
```javascript
var table = new Table({style:{head:[],border:[]}});
let table = new Table({ style: { head: [], border: [] } });

table.push(
[{colSpan:2,content:'hello there'}],
[{ colSpan: 2, content: 'hello there' }],
['hi', 'hi']
);

Expand All @@ -209,11 +220,14 @@
│ hi │ hi │
└────┴────────┘
```javascript
var table = new Table({colWidths:[4],style:{head:[],border:[]}});
let table = new Table({
colWidths: [4],
style: { head: [], border: [] },
});

table.push(
[{colSpan:2,content:'hello there'}],
['hi',{hAlign:'center',content:'hi'}]
[{ colSpan: 2, content: 'hello there' }],
['hi', { hAlign: 'center', content: 'hi' }]
);

```
Expand All @@ -226,11 +240,14 @@
│ hi │ hi │
└────────┴────┘
```javascript
var table = new Table({colWidths:[null, 4],style:{head:[],border:[]}});
let table = new Table({
colWidths: [null, 4],
style: { head: [], border: [] },
});

table.push(
[{colSpan:2,content:'hello there'}],
[{hAlign:'right',content:'hi'}, 'hi']
[{ colSpan: 2, content: 'hello there' }],
[{ hAlign: 'right', content: 'hi' }, 'hi']
);

```
Expand All @@ -239,7 +256,10 @@
##### feel free to use colors in your content strings, column widths will be calculated correctly
![table image](./examples/screenshots/truncation-with-colors.png)
```javascript
var table = new Table({colWidths:[5],style:{head:[],border:[]}});
let table = new Table({
colWidths: [5],
style: { head: [], border: [] },
});

table.push([colors.red('hello')]);

Expand Down
95 changes: 47 additions & 48 deletions basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
![table image](./examples/screenshots/basic-usage-with-colors.png)
```javascript
// By default, headers will be red, and borders will be grey
var table = new Table({head:['a','b']});
let table = new Table({ head: ['a', 'b'] });

table.push(['c','d']);
table.push(['c', 'd']);

```

Expand All @@ -21,18 +21,18 @@
// For most of these examples, and most of the unit tests we disable colors.
// It makes unit tests easier to write/understand, and allows these pages to
// display the examples as text instead of screen shots.
var table = new Table({
head: ['Rel', 'Change', 'By', 'When']
, style: {
head: [] //disable colors in header cells
, border: [] //disable colors for the border
}
, colWidths: [6, 21, 25, 17] //set the widths of each column (optional)
let table = new Table({
head: ['Rel', 'Change', 'By', 'When'],
style: {
head: [], //disable colors in header cells
border: [], //disable colors for the border
},
colWidths: [6, 21, 25, 17], //set the widths of each column (optional)
});

table.push(
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago']
, ['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago']
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago'],
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago']
);

```
Expand All @@ -45,11 +45,13 @@
│v0.1│Testing something cool│
└────┴──────────────────────┘
```javascript
var table = new Table({ style: {'padding-left':0, 'padding-right':0, head:[], border:[]} });
let table = new Table({
style: { 'padding-left': 0, 'padding-right': 0, head: [], border: [] },
});

table.push(
{'v0.1': 'Testing something cool'}
, {'v0.1': 'Testing something cool'}
{ 'v0.1': 'Testing something cool' },
{ 'v0.1': 'Testing something cool' }
);

```
Expand All @@ -64,11 +66,14 @@
│Header 4│v0.1 │Testing something cool│
└────────┴────────┴──────────────────────┘
```javascript
var table = new Table({ head: ["", "Header 1", "Header 2"], style: {'padding-left':0, 'padding-right':0, head:[], border:[]} }); // clear styles to prevent color output
let table = new Table({
head: ['', 'Header 1', 'Header 2'],
style: { 'padding-left': 0, 'padding-right': 0, head: [], border: [] },
}); // clear styles to prevent color output

table.push(
{"Header 3": ['v0.1', 'Testing something cool'] }
, {"Header 4": ['v0.1', 'Testing something cool'] }
{ 'Header 3': ['v0.1', 'Testing something cool'] },
{ 'Header 4': ['v0.1', 'Testing something cool'] }
);

```
Expand All @@ -81,30 +86,30 @@
║ frob │ bar │ quuz ║
╚══════╧═════╧══════╝
```javascript
var table = new Table({
let table = new Table({
chars: {
'top': ''
, 'top-mid': ''
, 'top-left': ''
, 'top-right': ''
, 'bottom': ''
, 'bottom-mid': ''
, 'bottom-left': ''
, 'bottom-right': ''
, 'left': ''
, 'left-mid': ''
, 'right': ''
, 'right-mid': ''
top: '',
'top-mid': '',
'top-left': '',
'top-right': '',
bottom: '',
'bottom-mid': '',
'bottom-left': '',
'bottom-right': '',
left: '',
'left-mid': '',
right: '',
'right-mid': '',
},
style: {
head: []
, border: []
}
head: [],
border: [],
},
});

table.push(
['foo', 'bar', 'baz']
, ['frob', 'bar', 'quuz']
['foo', 'bar', 'baz'],
['frob', 'bar', 'quuz']
);

```
Expand All @@ -113,12 +118,9 @@
##### Use ansi colors (i.e. colors.js) to style text within the cells at will, even across multiple lines
![table image](./examples/screenshots/multi-line-colors.png)
```javascript
var table = new Table({style:{border:[],header:[]}});
let table = new Table({ style: { border: [], header: [] } });

table.push([
colors.red('Hello\nhow\nare\nyou?'),
colors.blue('I\nam\nfine\nthanks!')
]);
table.push([colors.red('Hello\nhow\nare\nyou?'), colors.blue('I\nam\nfine\nthanks!')]);

```

Expand All @@ -131,16 +133,13 @@
│ you? │ │
└───────┴─────────┘
```javascript
var table = new Table({
style:{border:[],header:[]},
colWidths:[7,9],
wordWrap:true
let table = new Table({
style: { border: [], header: [] },
colWidths: [7, 9],
wordWrap: true,
});

table.push([
'Hello how are you?',
'I am fine thanks!'
]);
table.push(['Hello how are you?', 'I am fine thanks!']);

```