Skip to content

Commit 598ad67

Browse files
committed
doc: document all internal/ exported variables/functions
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
1 parent ab54266 commit 598ad67

3 files changed

Lines changed: 49 additions & 15 deletions

File tree

internal/color/color.go

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,48 @@ import (
1616
)
1717

1818
const (
19-
EnvColor = "TESTDEEP_COLOR"
19+
// EnvColor is the name of the environment variable allowing to
20+
// enable/disable coloring feature.
21+
EnvColor = "TESTDEEP_COLOR"
22+
// EnvColorTestName is the name of the environment variable
23+
// containing the color of test names in error reports.
2024
EnvColorTestName = "TESTDEEP_COLOR_TEST_NAME"
21-
EnvColorTitle = "TESTDEEP_COLOR_TITLE"
22-
EnvColorOK = "TESTDEEP_COLOR_OK"
23-
EnvColorBad = "TESTDEEP_COLOR_BAD"
25+
// EnvColorTitle is the name of the environment variable
26+
// containing the color of failure reason in error reports.
27+
EnvColorTitle = "TESTDEEP_COLOR_TITLE"
28+
// EnvColorOK is the name of the environment variable
29+
// containing the color of "expected" in error reports.
30+
EnvColorOK = "TESTDEEP_COLOR_OK"
31+
// EnvColorBad is the name of the environment variable
32+
// containing the color of "got" in error reports.
33+
EnvColorBad = "TESTDEEP_COLOR_BAD"
2434
)
2535

2636
var (
27-
TestNameOn string
37+
// TestNameOn contains the ANSI color escape sequence to turn test
38+
// name color on.
39+
TestNameOn string
40+
// TestNameOff contains the ANSI color escape sequence to turn test
41+
// name color off.
2842
TestNameOff string
29-
TitleOn string
30-
TitleOff string
31-
OKOn string
32-
OKOnBold string
33-
OKOff string
34-
BadOn string
35-
BadOnBold string
36-
BadOff string
43+
// TitleOn contains the ANSI color escape sequence to turn title color on.
44+
TitleOn string
45+
// TitleOff contains the ANSI color escape sequence to turn title color off.
46+
TitleOff string
47+
// OKOn contains the ANSI color escape sequence to turn "expected" color on.
48+
OKOn string
49+
// OKOnBold contains the ANSI color escape sequence to turn
50+
// "expected" color and bold on.
51+
OKOnBold string
52+
// OKOff contains the ANSI color escape sequence to turn "expected" color off.
53+
OKOff string
54+
// BadOn contains the ANSI color escape sequence to turn "got" color on.
55+
BadOn string
56+
// BadOnBold contains the ANSI color escape sequence to turn "got"
57+
// color and bold on.
58+
BadOnBold string
59+
// BadOff contains the ANSI color escape sequence to turn "got" color off.
60+
BadOff string
3761
)
3862

3963
var initOnce sync.Once

internal/flat/slice.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import (
1010
"reflect"
1111
)
1212

13-
var SliceType = reflect.TypeOf(Slice{})
13+
var sliceType = reflect.TypeOf(Slice{})
1414

15+
// Slice allows to flatten any slice.
1516
type Slice struct {
1617
Slice interface{}
1718
}
@@ -20,7 +21,7 @@ type Slice struct {
2021
// f.Slice, so this Slice is already flattened.
2122
func (f Slice) isFlat() bool {
2223
t := reflect.TypeOf(f.Slice).Elem()
23-
return t != SliceType && t.Kind() != reflect.Interface
24+
return t != sliceType && t.Kind() != reflect.Interface
2425
}
2526

2627
func (f Slice) len() int {
@@ -87,6 +88,9 @@ func (f Slice) appendTo(si []interface{}) []interface{} {
8788
return si
8889
}
8990

91+
// Len returns the number of items contained in items. Nested Slice
92+
// items are counted as if they are flattened. It returns true if at
93+
// least one Slice item is found, false otherwise.
9094
func Len(items []interface{}) (int, bool) {
9195
l := len(items)
9296
flattened := true
@@ -100,6 +104,8 @@ func Len(items []interface{}) (int, bool) {
100104
return l, flattened
101105
}
102106

107+
// Values returns the items values as a slice of reflect.Value. Nested
108+
// Slice items are flattened.
103109
func Values(items []interface{}) []reflect.Value {
104110
l, flattened := Len(items)
105111
if flattened {
@@ -121,6 +127,8 @@ func Values(items []interface{}) []reflect.Value {
121127
return sv
122128
}
123129

130+
// Values returns the items values as a slice of interface{}. Nested
131+
// Slice items are flattened.
124132
func Interfaces(items ...interface{}) []interface{} {
125133
l, flattened := Len(items)
126134
if flattened {

td/t_struct.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ func (t *T) RunAssertRequire(name string, f func(assert *T, require *T)) bool {
610610
return ret[0].Bool()
611611
}
612612

613+
// RunT runs "f" as a subtest of t called "name".
614+
//
613615
// Deprecated: RunT has been superseded by Run() method. It is kept
614616
// for compatibility.
615617
func (t *T) RunT(name string, f func(t *T)) bool {

0 commit comments

Comments
 (0)