Skip to content

Commit 0da58f4

Browse files
dolmenjlou2u
authored andcommitted
mock: improve doc (stretchr#1570)
## Summary Improve API doc of package [`mock`](https://pkg.go.dev/github.com/stretchr/testify/mock): - add godoc links - indent example code ## Motivation Readability.
1 parent ac74379 commit 0da58f4

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

mock/mock.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ const (
831831
)
832832

833833
// AnythingOfTypeArgument contains the type of an argument
834-
// for use when type checking. Used in Diff and Assert.
834+
// for use when type checking. Used in [Arguments.Diff] and [Arguments.Assert].
835835
//
836836
// Deprecated: this is an implementation detail that must not be used. Use [AnythingOfType] instead.
837837
type AnythingOfTypeArgument = anythingOfTypeArgument
@@ -847,24 +847,25 @@ type anythingOfTypeArgument string
847847
//
848848
// For example:
849849
//
850-
// Assert(t, AnythingOfType("string"), AnythingOfType("int"))
850+
// args.Assert(t, AnythingOfType("string"), AnythingOfType("int"))
851851
func AnythingOfType(t string) AnythingOfTypeArgument {
852852
return anythingOfTypeArgument(t)
853853
}
854854

855855
// IsTypeArgument is a struct that contains the type of an argument
856-
// for use when type checking. This is an alternative to AnythingOfType.
857-
// Used in Diff and Assert.
856+
// for use when type checking. This is an alternative to [AnythingOfType].
857+
// Used in [Arguments.Diff] and [Arguments.Assert].
858858
type IsTypeArgument struct {
859859
t reflect.Type
860860
}
861861

862862
// IsType returns an IsTypeArgument object containing the type to check for.
863863
// You can provide a zero-value of the type to check. This is an
864-
// alternative to AnythingOfType. Used in Diff and Assert.
864+
// alternative to [AnythingOfType]. Used in [Arguments.Diff] and [Arguments.Assert].
865865
//
866866
// For example:
867-
// Assert(t, IsType(""), IsType(0))
867+
//
868+
// args.Assert(t, IsType(""), IsType(0))
868869
func IsType(t interface{}) *IsTypeArgument {
869870
return &IsTypeArgument{t: reflect.TypeOf(t)}
870871
}
@@ -886,8 +887,8 @@ func (f *FunctionalOptionsArgument) String() string {
886887
return strings.Replace(fmt.Sprintf("%#v", f.value), "[]interface {}", name, 1)
887888
}
888889

889-
// FunctionalOptions returns an FunctionalOptionsArgument object containing the functional option type
890-
// and the values to check of
890+
// FunctionalOptions returns an [FunctionalOptionsArgument] object containing the functional option type
891+
// and the values to check of.
891892
//
892893
// For example:
893894
// Assert(t, FunctionalOptions("[]foo.FunctionalOption", foo.Opt1(), foo.Opt2()))
@@ -940,10 +941,11 @@ func (f argumentMatcher) String() string {
940941
// and false otherwise.
941942
//
942943
// Example:
943-
// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" }))
944944
//
945-
// |fn|, must be a function accepting a single argument (of the expected type)
946-
// which returns a bool. If |fn| doesn't match the required signature,
945+
// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" }))
946+
//
947+
// fn must be a function accepting a single argument (of the expected type)
948+
// which returns a bool. If fn doesn't match the required signature,
947949
// MatchedBy() panics.
948950
func MatchedBy(fn interface{}) argumentMatcher {
949951
fnType := reflect.TypeOf(fn)

0 commit comments

Comments
 (0)