Skip to content

Commit

Permalink
refactor!: remove buildin template 'std.struct.v1.go.tmpl' (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedhyw authored Jun 19, 2024
1 parent 50a25ce commit 03e6cb4
Show file tree
Hide file tree
Showing 73 changed files with 53 additions and 5,440 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ See [internal/app/app.feature](internal/app/app.feature) and [internal/app/app_t
1. Simplified template is set by default. In order to use the default template from the previous versions, provide the following flag `-template @/std.struct.v1.go.tmpl`.
2. All tests will have `t.Parallel` by default. This behaviour can be disabled by providing the flag `-disable-go-parallel`.

## Version 4 changes

1. Removed template "std.struct.v1.go.tmpl".

# Install

## Package
Expand Down Expand Up @@ -138,7 +142,7 @@ gherkingen -help
## Go

```bash
go install github.com/hedhyw/gherkingen/v3/cmd/gherkingen@latest
go install github.com/hedhyw/gherkingen/v4/cmd/gherkingen@latest
# Notice: gherkingen -version will return "unknown" version.
```

Expand Down Expand Up @@ -236,7 +240,7 @@ docker run --rm -it --read-only --network none \
# Output customization

## Custom templates
You can provide your own template, it can be based on [internal/assets/std.struct.v1.go.tmpl](internal/assets/std.struct.v1.go.tmpl). In the command-line tool specify the template
You can provide your own template, it can be based on [internal/assets/std.simple.v1.go.tmpl](internal/assets/std.simple.v1.go.tmpl). In the command-line tool specify the template
using `-template` flag: `gherkingen -template example.tmpl raw example.feature`

## Frameworks support
Expand All @@ -259,7 +263,7 @@ Useful resources:
|-------------------------------------------|------------------------------------------------------|
| Golang template documentation | [text/template](https://pkg.go.dev/text/template) |
| Root template object struct documentation | [TemplateData](https://pkg.go.dev/github.com/hedhyw/gherkingen/internal/model#TemplateData) |
| Example template | [std.struct.v1.go.tmpl](./internal/assets/std.struct.v1.go.tmpl) |
| Example template | [std.simple.v1.go.tmpl](./internal/assets/std.simple.v1.go.tmpl) |
| Example json representation of a root template object | [readme.feature.json](internal/generator/examples/readme.feature.json) |

There is a way to return a json representation of the root object `TemplateData` for your feature, for this run `gherkingen -format json <EXAMPLE.feature>`.
Expand Down
2 changes: 1 addition & 1 deletion cmd/gherkingen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"os"

"github.com/hedhyw/gherkingen/v3/internal/app"
"github.com/hedhyw/gherkingen/v4/internal/app"
)

// Version will be set on build.
Expand Down
2 changes: 1 addition & 1 deletion go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions internal/app/app.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ Feature: Application command line tool
Then the output should be generated
Examples:
| <feature> | <template> |
| app.feature | ../assets/std.struct.v1.go.tmpl |
| app.feature | @/std.struct.v1.go.tmpl |
| app.feature | ../assets/std.simple.v1.go.tmpl |
| app.feature | @/std.simple.v1.go.tmpl |

Scenario Outline: User wants to set custom package
Expand Down
2 changes: 1 addition & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/hedhyw/gherkingen/v3/internal/model"
"github.com/hedhyw/gherkingen/v4/internal/model"

"github.com/google/uuid"
)
Expand Down
5 changes: 2 additions & 3 deletions internal/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"testing"

"github.com/hedhyw/gherkingen/v3/internal/app"
"github.com/hedhyw/gherkingen/v4/internal/app"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -135,8 +135,7 @@ func TestApplicationCommandLineToolCustom(t *testing.T) {
}

testCases := map[string]testCase{
"app.feature_../assets/std.struct.v1.go.tmpl": {"app.feature", "../assets/std.struct.v1.go.tmpl"},
"app.feature_@/std.struct.v1.go.tmpl": {"app.feature", "@/std.struct.v1.go.tmpl"},
"app.feature_../assets/std.simple.v1.go.tmpl": {"app.feature", "../assets/std.simple.v1.go.tmpl"},
"app.feature_@/std.simple.v1.go.tmpl": {"app.feature", "@/std.simple.v1.go.tmpl"},
}

Expand Down
8 changes: 4 additions & 4 deletions internal/app/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"path"
"strings"

"github.com/hedhyw/gherkingen/v3/internal/docplugin/goplugin"
"github.com/hedhyw/gherkingen/v3/internal/docplugin/multiplugin"
"github.com/hedhyw/gherkingen/v3/internal/generator"
"github.com/hedhyw/gherkingen/v3/internal/model"
"github.com/hedhyw/gherkingen/v4/internal/docplugin/goplugin"
"github.com/hedhyw/gherkingen/v4/internal/docplugin/multiplugin"
"github.com/hedhyw/gherkingen/v4/internal/generator"
"github.com/hedhyw/gherkingen/v4/internal/model"
)

// appArgs contains required arguments for runGenerator.
Expand Down
2 changes: 1 addition & 1 deletion internal/app/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app
import (
"testing"

"github.com/hedhyw/gherkingen/v3/internal/model"
"github.com/hedhyw/gherkingen/v4/internal/model"

"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/app/readers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"strings"

"github.com/hedhyw/gherkingen/v3/internal/assets"
"github.com/hedhyw/gherkingen/v4/internal/assets"
)

func readInput(inputFile string) (data []byte, err error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/app/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"io"

"github.com/hedhyw/gherkingen/v3/internal/assets"
"github.com/hedhyw/gherkingen/v4/internal/assets"
)

func runListTemplates(out io.Writer) (err error) {
Expand Down
3 changes: 1 addition & 2 deletions internal/assets/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"io"
"testing"

"github.com/hedhyw/gherkingen/v3/internal/assets"
"github.com/hedhyw/gherkingen/v4/internal/assets"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -23,7 +23,6 @@ func TestOpenTemplate(t *testing.T) {
t.Parallel()

files := [...]string{
"std.struct.v1.go.tmpl",
"std.simple.v1.go.tmpl",
}

Expand Down
135 changes: 0 additions & 135 deletions internal/assets/std.struct.v1.go.tmpl

This file was deleted.

2 changes: 1 addition & 1 deletion internal/docplugin/goplugin/goaliaser/goaliaser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package goaliaser_test
import (
"testing"

"github.com/hedhyw/gherkingen/v3/internal/docplugin/goplugin/goaliaser"
"github.com/hedhyw/gherkingen/v4/internal/docplugin/goplugin/goaliaser"

"github.com/stretchr/testify/assert"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/docplugin/goplugin/goplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"unicode"

"github.com/hedhyw/gherkingen/v3/internal/docplugin/goplugin/goaliaser"
"github.com/hedhyw/gherkingen/v3/internal/model"
"github.com/hedhyw/gherkingen/v4/internal/docplugin/goplugin/goaliaser"
"github.com/hedhyw/gherkingen/v4/internal/model"
)

const maxRecursionDepth = 10
Expand Down
6 changes: 3 additions & 3 deletions internal/docplugin/goplugin/goplugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strconv"
"testing"

"github.com/hedhyw/gherkingen/v3/internal/docplugin/goplugin"
"github.com/hedhyw/gherkingen/v3/internal/model"
"github.com/hedhyw/gherkingen/v4/internal/docplugin/goplugin"
"github.com/hedhyw/gherkingen/v4/internal/model"

"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -128,7 +128,7 @@ func TestExample(t *testing.T) {

p := goplugin.New(goplugin.Args{})

// It tests https://github.com/hedhyw/gherkingen/v3/issues/26.
// It tests https://github.com/hedhyw/gherkingen/v4/issues/26.

doc := getExampleDocument()
if assert.NoError(t, p.Process(ctx, doc)) {
Expand Down
2 changes: 1 addition & 1 deletion internal/docplugin/goplugin/gotype.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strconv"
"strings"

"github.com/hedhyw/gherkingen/v3/internal/docplugin/goplugin/goaliaser"
"github.com/hedhyw/gherkingen/v4/internal/docplugin/goplugin/goaliaser"
)

// goType definition.
Expand Down
2 changes: 1 addition & 1 deletion internal/docplugin/goplugin/gotype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"testing"

"github.com/hedhyw/gherkingen/v3/internal/docplugin/goplugin/goaliaser"
"github.com/hedhyw/gherkingen/v4/internal/docplugin/goplugin/goaliaser"

"github.com/stretchr/testify/assert"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/docplugin/multiplugin/multiplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"fmt"

"github.com/hedhyw/gherkingen/v3/internal/docplugin"
"github.com/hedhyw/gherkingen/v3/internal/model"
"github.com/hedhyw/gherkingen/v4/internal/docplugin"
"github.com/hedhyw/gherkingen/v4/internal/model"
)

// MultiPlugin helps to process many plugins.
Expand Down
6 changes: 3 additions & 3 deletions internal/docplugin/multiplugin/multiplugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"testing"

"github.com/hedhyw/gherkingen/v3/internal/docplugin/goplugin"
"github.com/hedhyw/gherkingen/v3/internal/docplugin/multiplugin"
"github.com/hedhyw/gherkingen/v3/internal/model"
"github.com/hedhyw/gherkingen/v4/internal/docplugin/goplugin"
"github.com/hedhyw/gherkingen/v4/internal/docplugin/multiplugin"
"github.com/hedhyw/gherkingen/v4/internal/model"

"github.com/hedhyw/semerr/pkg/v1/semerr"
"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion internal/docplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package docplugin
import (
"context"

"github.com/hedhyw/gherkingen/v3/internal/model"
"github.com/hedhyw/gherkingen/v4/internal/model"
)

// Plugin injects extra data to document.
Expand Down
Loading

0 comments on commit 03e6cb4

Please sign in to comment.