Skip to content

Commit

Permalink
Fix type regex to include multi-line curly brackets (#96)
Browse files Browse the repository at this point in the history
* Add option  to include the exported types

* Add test packages with types

* Typo in GitHub action's commit message

* fix types brackets regex

* fix types brackets regex to match multi-lines

* Add tests cases for 'types' documentation

* Update readme according to godoc

* Revert "Update readme according to godoc"

This reverts commit e4eb04a.

Co-authored-by: goreadme <posener@gmail.com>
  • Loading branch information
romainbou and posener authored Oct 29, 2020
1 parent 0f5f314 commit 7e9b8ca
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/goreadme/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func push() {
log.Fatal(err)
}

err = actionutil.GitCommitPush([]string{path}, "Update readme accoridng to godoc")
err = actionutil.GitCommitPush([]string{path}, "Update readme according to godoc")
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var base = template.New("base").Funcs(
return "`" + s + "`"
},
"inlineCodeEllipsis": func(s string) string {
r := regexp.MustCompile(`\{[^[]*\}`)
r := regexp.MustCompile(`{(?s).*}`)
s = r.ReplaceAllString(s, "{ ... }")
return "`" + s + "`"
},
Expand Down
12 changes: 12 additions & 0 deletions testdata/pkg8_types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@ example := new(ExampleType)
example.val = 1

```

### type [ExampleType2](/pkg.go#L11)

`type ExampleType2 struct { ... }`

ExampleType2 is a type with an array

### type [ExampleTypeInt](/pkg.go#L17)

`type ExampleTypeInt struct { ... }`

ExampleTypeInt is a one-liner type
9 changes: 9 additions & 0 deletions testdata/pkg8_types/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ type ExampleType struct {
val int
ExampleInterface interface{}
}

// ExampleType2 is a type with an array
type ExampleType2 struct {
val []int
ExampleInterface interface{}
}

// ExampleTypeInt is a one-liner type
type ExampleTypeInt struct{ val int }

0 comments on commit 7e9b8ca

Please sign in to comment.