Skip to content

Commit

Permalink
Document usage
Browse files Browse the repository at this point in the history
  • Loading branch information
fbiville committed Aug 19, 2019
1 parent 4924fe6 commit 518bea7
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,74 @@
# Markdown table formatter in Golang

## Import

```sh
$ go get github.com/fbiville/markdown-table-formatter/pkg/markdown
```

## Usage

### Basic

```go
package some_package

import (
"fmt"
"github.com/fbiville/markdown-table-formatter/pkg/markdown"
)

func someFunction() {
basicTable, err := markdown.NewTableFormatterBuilder().
Build("column 1", "column 2", "column 3").
Format([][]string{
{"so", "much", "fun"},
{"don't", "you", "agree"},
})
if err != nil {
// ... do your thing
}
fmt.Print(basicTable)
}
```

The output will be:
```
| column 1 | column 2 | column 3 |
| -------- | -------- | -------- |
| so | much | fun |
| don't | you | agree |
```

### Pretty-print

```go
package some_package

import (
"fmt"
"github.com/fbiville/markdown-table-formatter/pkg/markdown"
)

func someFunction() {
prettyPrintedTable, err := markdown.NewTableFormatterBuilder().
WithPrettyPrint().
Build("column 1", "column 2", "column 3").
Format([][]string{
{"so", "much", "fun"},
{"don't", "you", "agree"},
})
if err != nil {
// ... do your thing
}
fmt.Println(prettyPrintedTable)
}
```

The output will be:
```
| column 1 | column 2 | column 3 |
| -------- | -------- | -------- |
| so | much | fun |
| don't | you | agree |
```

0 comments on commit 518bea7

Please sign in to comment.