Skip to content

Commit

Permalink
Merge pull request #93 from kolyshkin/gofumpt
Browse files Browse the repository at this point in the history
enable/use gofumpt
  • Loading branch information
cpuguy83 committed Apr 27, 2023
2 parents 88f3fbc + 2813831 commit 6cc2302
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ jobs:
- uses: actions/checkout@v3
- uses: golangci/golangci-lint-action@v3.4.0
with:
# must be specified without patch version
version: v1.41
version: v1.51
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# For documentation, see https://golangci-lint.run/usage/configuration/

linters:
enable:
- gofumpt

6 changes: 4 additions & 2 deletions md2man.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (
"github.com/cpuguy83/go-md2man/v2/md2man"
)

var inFilePath = flag.String("in", "", "Path to file to be processed (default: stdin)")
var outFilePath = flag.String("out", "", "Path to output processed file (default: stdout)")
var (
inFilePath = flag.String("in", "", "Path to file to be processed (default: stdin)")
outFilePath = flag.String("out", "", "Path to output processed file (default: stdout)")
)

func main() {
var err error
Expand Down
6 changes: 4 additions & 2 deletions md2man/md2man.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ func Render(doc []byte) []byte {
renderer := NewRoffRenderer()

return blackfriday.Run(doc,
[]blackfriday.Option{blackfriday.WithRenderer(renderer),
blackfriday.WithExtensions(renderer.GetExtensions())}...)
[]blackfriday.Option{
blackfriday.WithRenderer(renderer),
blackfriday.WithExtensions(renderer.GetExtensions()),
}...)
}
3 changes: 1 addition & 2 deletions md2man/roff.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ func (r *roffRenderer) RenderFooter(w io.Writer, ast *blackfriday.Node) {
// RenderNode is called for each node in a markdown document; based on the node
// type the equivalent roff output is sent to the writer
func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus {

var walkAction = blackfriday.GoToNext
walkAction := blackfriday.GoToNext

switch node.Type {
case blackfriday.Text:
Expand Down
29 changes: 15 additions & 14 deletions md2man/roff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type TestParams struct {
}

func TestEmphasis(t *testing.T) {
var tests = []string{
tests := []string{
"nothing inline\n",
".nh\n\n.PP\nnothing inline\n",

Expand Down Expand Up @@ -67,7 +67,7 @@ func TestEmphasis(t *testing.T) {
}

func TestStrong(t *testing.T) {
var tests = []string{
tests := []string{
"nothing inline\n",
".nh\n\n.PP\nnothing inline\n",

Expand Down Expand Up @@ -126,7 +126,7 @@ func TestStrong(t *testing.T) {
}

func TestEmphasisMix(t *testing.T) {
var tests = []string{
tests := []string{
"***triple emphasis***\n",
".nh\n\n.PP\n\\fB\\fItriple emphasis\\fP\\fP\n",

Expand Down Expand Up @@ -155,7 +155,7 @@ func TestEmphasisMix(t *testing.T) {
}

func TestCodeSpan(t *testing.T) {
var tests = []string{
tests := []string{
"`source code`\n",
".nh\n\n.PP\n\\fB\\fCsource code\\fR\n",

Expand Down Expand Up @@ -193,7 +193,7 @@ func TestCodeSpan(t *testing.T) {
}

func TestListLists(t *testing.T) {
var tests = []string{
tests := []string{
"\n\n**[grpc]**\n: Section for gRPC socket listener settings. Contains three properties:\n - **address** (Default: \"/run/containerd/containerd.sock\")\n - **uid** (Default: 0)\n - **gid** (Default: 0)",
".nh\n\n.TP\n\\fB[grpc]\\fP\nSection for gRPC socket listener settings. Contains three properties:\n.RS\n.IP \\(bu 2\n\\fBaddress\\fP (Default: \"/run/containerd/containerd.sock\")\n.IP \\(bu 2\n\\fBuid\\fP (Default: 0)\n.IP \\(bu 2\n\\fBgid\\fP (Default: 0)\n\n.RE\n\n",
"Definition title\n: Definition description one\n: And two\n: And three\n",
Expand All @@ -203,7 +203,7 @@ func TestListLists(t *testing.T) {
}

func TestLineBreak(t *testing.T) {
var tests = []string{
tests := []string{
"this line \nhas a break\n",
".nh\n\n.PP\nthis line\n.br\nhas a break\n",

Expand Down Expand Up @@ -238,11 +238,12 @@ func TestLineBreak(t *testing.T) {
".nh\n\n.PP\nthis has an\n.br\nextra space\n",
}
doTestsInlineParam(t, tests, TestParams{
extensions: blackfriday.BackslashLineBreak})
extensions: blackfriday.BackslashLineBreak,
})
}

func TestTable(t *testing.T) {
var tests = []string{
tests := []string{
`
| Animal | Color |
| --------------| --- |
Expand Down Expand Up @@ -273,7 +274,7 @@ robin red.
}

func TestTableWithEmptyCell(t *testing.T) {
var tests = []string{
tests := []string{
`
| Col1 | Col2 | Col3 |
|:---------|:-----:|:----:|
Expand All @@ -296,7 +297,7 @@ row two x
}

func TestTableWrapping(t *testing.T) {
var tests = []string{
tests := []string{
`
| Col1 | Col2 |
| ----------- | ------------------------------------------------ |
Expand Down Expand Up @@ -333,7 +334,7 @@ T}
}

func TestLinks(t *testing.T) {
var tests = []string{
tests := []string{
"See [docs](https://docs.docker.com/) for\nmore",
".nh\n\n.PP\nSee docs\n\\[la]https://docs.docker.com/\\[ra] for\nmore\n",
"See [docs](https://docs-foo.docker.com/) for\nmore",
Expand All @@ -345,15 +346,15 @@ func TestLinks(t *testing.T) {
}

func TestEscapeCharacters(t *testing.T) {
var tests = []string{
tests := []string{
"Test-one_two&three\\four~five",
".nh\n\n.PP\nTest-one_two&three\\\\four~five\n",
}
doTestsInline(t, tests)
}

func TestSpan(t *testing.T) {
var tests = []string{
tests := []string{
"Text containing a <span>html span</span> element\n",
".nh\n\n.PP\nText containing a html span element\n",

Expand All @@ -367,7 +368,7 @@ func TestSpan(t *testing.T) {
}

func TestEmails(t *testing.T) {
var tests = []string{
tests := []string{
`April 2014, Originally compiled by William Henry (whenry at redhat dot com)
based on docker.com source material and internal work.
June 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>
Expand Down

0 comments on commit 6cc2302

Please sign in to comment.