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

fix: Updating docs #458

Merged
merged 1 commit into from
Dec 21, 2023
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
44 changes: 21 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ const { printTable } = require('console-table-printer');

//Create a table
const testCases = [
{ index: 3, text: 'I would like some gelb bananen bitte', value: 100 },
{ index: 4, text: 'I hope batch update is working', value: 300 },
{ Rank: 3, text: 'I would like some Yellow', value: 100 },
{ Rank: 4, text: 'I hope batch update is working', value: 300 },
Comment on lines -40 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to suggest changing Rank to rank because most keys I see in JavaScript start with lowercase. Thanks.

Copy link
Owner Author

@ayonious ayonious Dec 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I was about to create another PR for making this change. But then thought maybes its better because, having also some uppercase in dataset makes it look like "keys"/"Column Names" don't need to start with lowercase.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having also some uppercase in dataset makes it look like "keys"/"Column Names" don't need to start with lowercase

IMHO, given javascript syntax, I think that's already implied.

Comment on lines +40 to +41

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ Rank: 3, text: 'I would like some Yellow', value: 100 },
{ Rank: 4, text: 'I hope batch update is working', value: 300 },
{ rank: 3, text: 'I would like some Yellow', value: 100 },
{ rank: 4, text: 'I hope batch update is working', value: 300 }

];

//print
printTable(testCases);
```

![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/quick-print.png)
![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/readme-quick-1.png)

## 🚨🚨Announcement🚨🚨 Official Documentation is moved [Here](https://console-table.netlify.app/docs)

Expand All @@ -57,39 +57,39 @@ const { Table } = require('console-table-printer');
//Create a table
const p = new Table();

//add rows with color
p.addRow({ index: 1, text: 'red wine please', value: 10.212 });
p.addRow({ index: 2, text: 'green gemuse please', value: 20.0 });
// add rows with color
p.addRow({ Record: 'a', text: 'red wine please', value: 10.212 });
p.addRow({ Record: 'b', text: 'green gemuse please', value: 20.0 });
p.addRows([
//adding multiple rows are possible
{ index: 3, text: 'gelb bananen bitte', value: 100 },
{ index: 4, text: 'update is working', value: 300 },
// adding multiple rows are possible
{ Record: 'c', text: 'gelb bananen bitte', value: 100 },
{ Record: 'd', text: 'update is working', value: 300 },
]);

//print
p.printTable();
```

![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/screenshot-simple.png)
![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/readme-instance-1.png)

You can also put some color to your table like this:

```javascript
const p = new Table();
p.addRow({ index: 1, text: 'red wine', value: 10.212 }, { color: 'red' });
p.addRow({ index: 2, text: 'green gemuse', value: 20.0 }, { color: 'green' });
p.addRow({ index: 3, text: 'gelb bananen', value: 100 }, { color: 'yellow' });
p.addRow({ description: 'red wine', value: 10.212 }, { color: 'red' });
p.addRow({ description: 'green gemuse', value: 20.0 }, { color: 'green' });
p.addRow({ description: 'gelb bananen', value: 100 }, { color: 'yellow' });
p.printTable();
```

![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/screenshot-colored.png)
![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/readme-color-1.png)

You can also put properties based on columns (color/alignment/title)

```javascript
const p = new Table({
columns: [
{ name: 'index', alignment: 'left', color: 'blue' }, // with alignment and color
{ name: 'id', alignment: 'left', color: 'blue' }, // with alignment and color
{ name: 'text', alignment: 'right' },
{ name: 'is_priority_today', title: 'Is This Priority?' }, // with Title as separate Text
],
Expand All @@ -98,23 +98,21 @@ const p = new Table({
},
});

p.addRow({ index: 1, text: 'red wine', value: 10.212 }, { color: 'green' });
p.addRow({ id: 1, text: 'red wine', value: 10.212 }, { color: 'green' });
p.addRow(
{ index: 2, text: 'green gemuse', value: 20.0 },
{ id: 2, text: 'green gemuse', value: 20.0 },
{ color: 'custom_green' } // your green
);
p.addRow(
{ index: 3, text: 'gelb bananen', value: 100, is_priority_today: 'Y' },
{ id: 3, text: 'gelb bananen', value: 100, is_priority_today: 'Y' },
{ color: 'yellow' }
);
p.addRow(
{ index: 3, text: 'rosa hemd wie immer', value: 100 },
{ color: 'cyan' }
);
p.addRow({ id: 3, text: 'rosa hemd wie immer', value: 100 }, { color: 'cyan' });

p.printTable();
```

![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/screenshot-column-props-2.png)
![Screenshot](https://cdn.jsdelivr.net/gh/ayonious/console-table-printer@master/static-resources/readme-columns-1.png)

## CLI

Expand Down
Binary file removed static-resources/quick-print.png
Binary file not shown.
Binary file added static-resources/readme-color-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static-resources/readme-columns-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static-resources/readme-instance-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static-resources/readme-quick-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed static-resources/screenshot-colored.png
Binary file not shown.
Binary file removed static-resources/screenshot-column-props-2.png
Binary file not shown.
Binary file removed static-resources/screenshot-fat-border.png
Binary file not shown.
Binary file removed static-resources/screenshot-simple.png
Binary file not shown.
Binary file removed static-resources/screenshot-thin-border.png
Binary file not shown.
136 changes: 0 additions & 136 deletions test/readme/readmeExamples1.test.ts

This file was deleted.

15 changes: 15 additions & 0 deletions test/readme/readmeExamples1Basic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { printTable } from '../../index';

describe('Example: 1', () => {
it('Basic', () => {
// Create a table
const testCases = [
{ Rank: 3, text: 'I would like some Yellow', value: 100 },
{ Rank: 4, text: 'I hope batch update is working', value: 300 },
];

// print
const returned = printTable(testCases);
expect(returned).toBeUndefined();
});
});
77 changes: 0 additions & 77 deletions test/readme/readmeExamples2.test.ts

This file was deleted.

22 changes: 22 additions & 0 deletions test/readme/readmeExamples2Instance.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Table } from '../../index';

describe('Example: 2', () => {
it('Instance', () => {
// Create a table
const p = new Table();

// add rows with color
p.addRow({ Record: 'a', text: 'red wine please', value: 10.212 });
p.addRow({ Record: 'b', text: 'green gemuse please', value: 20.0 });
p.addRows([
// adding multiple rows are possible
{ Record: 'c', text: 'gelb bananen bitte', value: 100 },
{ Record: 'd', text: 'update is working', value: 300 },
]);

// print
const returned = p.printTable();

expect(returned).toBeUndefined();
});
});
33 changes: 0 additions & 33 deletions test/readme/readmeExamples3.test.ts

This file was deleted.