Skip to content

Commit dd50fba

Browse files
committed
docs: td uses new go1.19 doc features
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
1 parent 9559aee commit dd50fba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1887
-1550
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ See [FAQ](https://go-testdeep.zetta.rocks/faq/).
286286
[`tdutil`]: https://pkg.go.dev/github.com/maxatome/go-testdeep/helpers/tdutil
287287

288288
[`BeLax` config flag]: https://pkg.go.dev/github.com/maxatome/go-testdeep/td#ContextConfig.BeLax
289-
[`error`]: https://pkg.go.dev/builtin/#error
289+
[`error`]: https://pkg.go.dev/builtin#error
290290

291291

292292
[`fmt.Stringer`]: https://pkg.go.dev/fmt/#Stringer

helpers/tdhttp/doc.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
// This source code is licensed under the BSD-style license found in the
55
// LICENSE file in the root directory of this source tree.
66

7-
// Package tdhttp provides some functions to easily test HTTP handlers.
7+
// Package tdhttp, from [go-testdeep], provides some functions to easily
8+
// test HTTP handlers.
89
//
9-
// Combined to td package ([github.com/maxatome/go-testdeep/td]) it
10-
// provides powerful testing features.
10+
// Combined to [td] package it provides powerful testing features.
1111
//
1212
// # TestAPI
1313
//
@@ -62,4 +62,6 @@
6262
// It now uses [TestAPI] behind the scene. It is better to directly
6363
// use [TestAPI] and its methods instead, as it is more flexible and
6464
// readable.
65+
//
66+
// [go-testdeep]: https://go-testdeep.zetta.rocks/
6567
package tdhttp

helpers/tdhttp/http.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ func CmpXMLResponse(t testing.TB,
271271
}
272272

273273
// CmpMarshaledResponseFunc returns a function ready to be used with
274-
// [testing.Run], calling [CmpMarshaledResponse] behind the scene. As it
275-
// is intended to be used in conjunction with [testing.Run] which
274+
// [testing.T.Run], calling [CmpMarshaledResponse] behind the scene. As it
275+
// is intended to be used in conjunction with [testing.T.Run] which
276276
// names the sub-test, the test name part (args...) is voluntary
277277
// omitted.
278278
//
@@ -297,8 +297,8 @@ func CmpMarshaledResponseFunc(req *http.Request,
297297
}
298298

299299
// CmpResponseFunc returns a function ready to be used with
300-
// [testing.Run], calling [CmpResponse] behind the scene. As it is
301-
// intended to be used in conjunction with [testing.Run] which names
300+
// [testing.T.Run], calling [CmpResponse] behind the scene. As it is
301+
// intended to be used in conjunction with [testing.T.Run] which names
302302
// the sub-test, the test name part (args...) is voluntary omitted.
303303
//
304304
// t.Run("Subtest name", tdhttp.CmpResponseFunc(
@@ -321,8 +321,8 @@ func CmpResponseFunc(req *http.Request,
321321
}
322322

323323
// CmpJSONResponseFunc returns a function ready to be used with
324-
// [testing.Run], calling [CmpJSONResponse] behind the scene. As it is
325-
// intended to be used in conjunction with [testing.Run] which names
324+
// [testing.T.Run], calling [CmpJSONResponse] behind the scene. As it is
325+
// intended to be used in conjunction with [testing.T.Run] which names
326326
// the sub-test, the test name part (args...) is voluntary omitted.
327327
//
328328
// t.Run("Subtest name", tdhttp.CmpJSONResponseFunc(
@@ -346,8 +346,8 @@ func CmpJSONResponseFunc(req *http.Request,
346346
}
347347

348348
// CmpXMLResponseFunc returns a function ready to be used with
349-
// [testing.Run], calling [CmpXMLResponse] behind the scene. As it is
350-
// intended to be used in conjunction with [testing.Run] which names
349+
// [testing.T.Run], calling [CmpXMLResponse] behind the scene. As it is
350+
// intended to be used in conjunction with [testing.T.Run] which names
351351
// the sub-test, the test name part (args...) is voluntary omitted.
352352
//
353353
// t.Run("Subtest name", tdhttp.CmpXMLResponseFunc(

helpers/tdsuite/doc.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// This source code is licensed under the BSD-style license found in the
55
// LICENSE file in the root directory of this source tree.
66

7-
// Package tdsuite adds tests suite feature to go-testdeep in a
7+
// Package tdsuite adds tests suite feature to [go-testdeep] in a
88
// non-intrusive way, but easily and powerfully.
99
//
1010
// A tests suite is a set of tests run sequentially that share some data.
@@ -125,4 +125,6 @@
125125
//
126126
// See documentation below for other possible hooks: [PreTest], [PostTest]
127127
// and [BetweenTests].
128+
//
129+
// [go-testdeep]: https://go-testdeep.zetta.rocks/
128130
package tdsuite

helpers/tdutil/t.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
// T can be used in tests, to test [testing.T] behavior as it overrides
20-
// [testing.Run] method.
20+
// [testing.T.Run] method.
2121
type T struct {
2222
testing.T
2323
name string

internal/anchors/anchor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Info struct {
2727
anchors map[any]anchor
2828
}
2929

30-
// NewInfo returns a new instance of *Info.
30+
// NewInfo returns a new instance of [*Info].
3131
func NewInfo() *Info {
3232
return &Info{
3333
anchors: map[any]anchor{},

internal/anchors/types.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type anchorableType struct {
2222
}
2323

2424
// AnchorableTypes contains all non-native types that can be
25-
// anchorable. See AddAnchorableStructType to add a new type to it.
25+
// anchorable. See [AddAnchorableStructType] to add a new type to it.
2626
var AnchorableTypes []anchorableType
2727

2828
func init() {
@@ -31,29 +31,29 @@ func init() {
3131
})
3232
}
3333

34-
// AddAnchorableStructType declares a struct type as anchorable. "fn"
34+
// AddAnchorableStructType declares a struct type as anchorable. fn
3535
// is a function allowing to return a unique and identifiable instance
3636
// of the struct type.
3737
//
38-
// "fn" has to have the following signature:
38+
// fn has to have the following signature:
3939
//
4040
// func (nextAnchor int) TYPE
4141
//
42-
// TYPE is the struct type to make anchorable and "nextAnchor" is an
42+
// TYPE is the struct type to make anchorable and nextAnchor is an
4343
// index to allow to differentiate several instances of the same type.
4444
//
45-
// For example, the time.Time type which is anchorable by default,
45+
// For example, the [time.Time] type which is anchorable by default,
4646
// is declared as:
4747
//
4848
// AddAnchorableStructType(func (nextAnchor int) time.Time {
4949
// return time.Unix(math.MaxInt64-1000424443-int64(nextAnchor), 42)
5050
// })
5151
//
5252
// Just as a note, the 1000424443 constant allows to avoid to flirt
53-
// with the math.MaxInt64 extreme limit and so avoid possible
53+
// with the [math.MaxInt64] extreme limit and so avoid possible
5454
// collision with real world values.
5555
//
56-
// It returns an error if the provided "fn" is not a function or if it
56+
// It returns an error if the provided fn is not a function or if it
5757
// has not the expected signature (see above).
5858
func AddAnchorableStructType(fn any) error {
5959
vfn := reflect.ValueOf(fn)

internal/color/color.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func Init() {
7575
}
7676

7777
// SaveState saves the "TESTDEEP_COLOR" environment variable
78-
// value, sets it to "on" (if true passed as on) or "false" (if on not
78+
// value, sets it to "on" (if true passed as on) or "off" (if on not
7979
// passed or set to false), resets the colors initialization and
8080
// returns a function to be called in a defer statement. Only intended
8181
// to be used in tests like:
@@ -249,7 +249,7 @@ func TooManyParams(usage string) string {
249249
return BadOnBold + "usage: " + usage + ", too many parameters" + BadOff
250250
}
251251

252-
// UnBad returns "s" with bad color prefix & suffix removed.
252+
// UnBad returns s with bad color prefix & suffix removed.
253253
func UnBad(s string) string {
254254
return strings.TrimSuffix(strings.TrimPrefix(s, BadOnBold), BadOff)
255255
}

internal/ctxerr/context.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/maxatome/go-testdeep/internal/visited"
1616
)
1717

18-
// Context is used internally to keep track of the CmpDeeply in-Depth
18+
// Context is used internally to keep track of the Cmp in-depth
1919
// traversal.
2020
type Context struct {
2121
Path Path
@@ -46,7 +46,7 @@ type Context struct {
4646
IgnoreUnexported bool
4747
}
4848

49-
// InitErrors initializes Context *Errors slice, if MaxErrors < 0 or
49+
// InitErrors initializes [Context] *Errors slice, if MaxErrors < 0 or
5050
// MaxErrors > 1.
5151
func (c *Context) InitErrors() {
5252
if c.MaxErrors != 0 && c.MaxErrors != 1 {
@@ -55,7 +55,7 @@ func (c *Context) InitErrors() {
5555
}
5656
}
5757

58-
// ResetErrors returns a new Context without any Error set.
58+
// ResetErrors returns a new [Context] without any Error set.
5959
func (c Context) ResetErrors() (new Context) {
6060
new = c
6161
new.InitErrors()
@@ -65,7 +65,8 @@ func (c Context) ResetErrors() (new Context) {
6565
// CollectError collects an error in the context. It returns an error
6666
// if the collector is full, nil otherwise.
6767
//
68-
// In boolean context, ignore the passed error and return the BooleanError.
68+
// In boolean context, it ignores the passed error and returns the
69+
// [BooleanError].
6970
func (c Context) CollectError(err *Error) *Error {
7071
if err == nil {
7172
return nil
@@ -126,23 +127,23 @@ func (c Context) CannotCompareError() *Error {
126127
}
127128
}
128129

129-
// AddCustomLevel creates a new Context from current one plus pathAdd.
130+
// AddCustomLevel creates a new [Context] from current one plus pathAdd.
130131
func (c Context) AddCustomLevel(pathAdd string) (new Context) {
131132
new = c
132133
new.Path = new.Path.AddCustomLevel(pathAdd)
133134
new.Depth++
134135
return
135136
}
136137

137-
// AddField creates a new Context from current one plus "." + field.
138+
// AddField creates a new [Context] from current one plus "." + field.
138139
func (c Context) AddField(field string) (new Context) {
139140
new = c
140141
new.Path = new.Path.AddField(field)
141142
new.Depth++
142143
return
143144
}
144145

145-
// AddArrayIndex creates a new Context from current one plus an array
146+
// AddArrayIndex creates a new [Context] from current one plus an array
146147
// dereference for index-th item.
147148
func (c Context) AddArrayIndex(index int) (new Context) {
148149
new = c
@@ -151,7 +152,7 @@ func (c Context) AddArrayIndex(index int) (new Context) {
151152
return
152153
}
153154

154-
// AddMapKey creates a new Context from current one plus a map
155+
// AddMapKey creates a new [Context] from current one plus a map
155156
// dereference for key key.
156157
func (c Context) AddMapKey(key any) (new Context) {
157158
new = c
@@ -160,15 +161,15 @@ func (c Context) AddMapKey(key any) (new Context) {
160161
return
161162
}
162163

163-
// AddPtr creates a new Context from current one plus a pointer dereference.
164+
// AddPtr creates a new [Context] from current one plus a pointer dereference.
164165
func (c Context) AddPtr(num int) (new Context) {
165166
new = c
166167
new.Path = new.Path.AddPtr(num)
167168
new.Depth++
168169
return
169170
}
170171

171-
// AddFunctionCall creates a new Context from current one inside a
172+
// AddFunctionCall creates a new [Context] from current one inside a
172173
// function call.
173174
func (c Context) AddFunctionCall(fn string) (new Context) {
174175
new = c
@@ -177,7 +178,7 @@ func (c Context) AddFunctionCall(fn string) (new Context) {
177178
return
178179
}
179180

180-
// ResetPath creates a new Context from current one but reinitializing Path.
181+
// ResetPath creates a new [Context] from current one but reinitializing Path.
181182
func (c Context) ResetPath(newRoot string) (new Context) {
182183
new = c
183184
new.Path = NewPath(newRoot)

internal/ctxerr/error.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,15 @@ type Error struct {
3838
Next *Error
3939
}
4040

41-
var (
42-
// BooleanError is the *Error returned when an error occurs in a
43-
// boolean context.
44-
BooleanError = &Error{}
45-
46-
// ErrTooManyErrors is chained to the last error encountered when
47-
// the maximum number of errors has been reached.
48-
ErrTooManyErrors = &Error{
49-
Message: "Too many errors (use TESTDEEP_MAX_ERRORS=-1 to see all)",
50-
}
51-
)
41+
// BooleanError is the [*Error] returned when an error occurs in a
42+
// boolean context.
43+
var BooleanError = &Error{}
44+
45+
// ErrTooManyErrors is chained to the last error encountered when
46+
// the maximum number of errors has been reached.
47+
var ErrTooManyErrors = &Error{
48+
Message: "Too many errors (use TESTDEEP_MAX_ERRORS=-1 to see all)",
49+
}
5250

5351
// TypeMismatch returns a "type mismatch" error. It is the caller
5452
// responsibility to check that both types differ.
@@ -101,8 +99,8 @@ func (e *Error) Error() string {
10199
return buf.String()
102100
}
103101

104-
// Append appends the Error contents to "buf" using prefix "prefix"
105-
// for each line.
102+
// Append appends the a contents to buf using prefix prefix for each
103+
// line.
106104
func (e *Error) Append(buf *bytes.Buffer, prefix string) {
107105
if e == BooleanError {
108106
return
@@ -187,8 +185,7 @@ func (e *Error) Append(buf *bytes.Buffer, prefix string) {
187185
}
188186

189187
// GotString returns the string corresponding to the Got
190-
// field. Returns the empty string if the Error Summary field is not
191-
// nil.
188+
// field. Returns the empty string if the e Summary field is not nil.
192189
func (e *Error) GotString() string {
193190
if e.Summary != nil {
194191
return ""
@@ -197,8 +194,7 @@ func (e *Error) GotString() string {
197194
}
198195

199196
// ExpectedString returns the string corresponding to the Expected
200-
// field. Returns the empty string if the Error Summary field is not
201-
// nil.
197+
// field. Returns the empty string if the e Summary field is not nil.
202198
func (e *Error) ExpectedString() string {
203199
if e.Summary != nil {
204200
return ""
@@ -207,7 +203,7 @@ func (e *Error) ExpectedString() string {
207203
}
208204

209205
// SummaryString returns the string corresponding to the Summary
210-
// field. Returns the empty string if the Error Summary field is nil.
206+
// field. Returns the empty string if the e Summary field is nil.
211207
func (e *Error) SummaryString() string {
212208
if e.Summary == nil {
213209
return ""

0 commit comments

Comments
 (0)