Skip to content

Commit 3c302f7

Browse files
authored
mock: improve doc (#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 632a260 commit 3c302f7

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
@@ -764,7 +764,7 @@ const (
764764
)
765765

766766
// AnythingOfTypeArgument contains the type of an argument
767-
// for use when type checking. Used in Diff and Assert.
767+
// for use when type checking. Used in [Arguments.Diff] and [Arguments.Assert].
768768
//
769769
// Deprecated: this is an implementation detail that must not be used. Use [AnythingOfType] instead.
770770
type AnythingOfTypeArgument = anythingOfTypeArgument
@@ -780,24 +780,25 @@ type anythingOfTypeArgument string
780780
//
781781
// For example:
782782
//
783-
// Assert(t, AnythingOfType("string"), AnythingOfType("int"))
783+
// args.Assert(t, AnythingOfType("string"), AnythingOfType("int"))
784784
func AnythingOfType(t string) AnythingOfTypeArgument {
785785
return anythingOfTypeArgument(t)
786786
}
787787

788788
// IsTypeArgument is a struct that contains the type of an argument
789-
// for use when type checking. This is an alternative to AnythingOfType.
790-
// Used in Diff and Assert.
789+
// for use when type checking. This is an alternative to [AnythingOfType].
790+
// Used in [Arguments.Diff] and [Arguments.Assert].
791791
type IsTypeArgument struct {
792792
t reflect.Type
793793
}
794794

795795
// IsType returns an IsTypeArgument object containing the type to check for.
796796
// You can provide a zero-value of the type to check. This is an
797-
// alternative to AnythingOfType. Used in Diff and Assert.
797+
// alternative to [AnythingOfType]. Used in [Arguments.Diff] and [Arguments.Assert].
798798
//
799799
// For example:
800-
// Assert(t, IsType(""), IsType(0))
800+
//
801+
// args.Assert(t, IsType(""), IsType(0))
801802
func IsType(t interface{}) *IsTypeArgument {
802803
return &IsTypeArgument{t: reflect.TypeOf(t)}
803804
}
@@ -819,8 +820,8 @@ func (f *FunctionalOptionsArgument) String() string {
819820
return strings.Replace(fmt.Sprintf("%#v", f.value), "[]interface {}", name, 1)
820821
}
821822

822-
// FunctionalOptions returns an FunctionalOptionsArgument object containing the functional option type
823-
// and the values to check of
823+
// FunctionalOptions returns an [FunctionalOptionsArgument] object containing the functional option type
824+
// and the values to check of.
824825
//
825826
// For example:
826827
// Assert(t, FunctionalOptions("[]foo.FunctionalOption", foo.Opt1(), foo.Opt2()))
@@ -873,10 +874,11 @@ func (f argumentMatcher) String() string {
873874
// and false otherwise.
874875
//
875876
// Example:
876-
// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" }))
877877
//
878-
// |fn|, must be a function accepting a single argument (of the expected type)
879-
// which returns a bool. If |fn| doesn't match the required signature,
878+
// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" }))
879+
//
880+
// fn must be a function accepting a single argument (of the expected type)
881+
// which returns a bool. If fn doesn't match the required signature,
880882
// MatchedBy() panics.
881883
func MatchedBy(fn interface{}) argumentMatcher {
882884
fnType := reflect.TypeOf(fn)

0 commit comments

Comments
 (0)