reorg internal code
This commit is contained in:
parent
73104856d2
commit
0fcdf50ce5
4
Makefile
4
Makefile
@ -14,12 +14,12 @@ build: $(SOURCES) .bin
|
||||
mkdir -p .bin
|
||||
|
||||
check: $(SOURCES) .bin/docreflect
|
||||
.bin/docreflect generate docreflect_test code.squareroundforest.org/arpio/docreflect/tests/src/testpackage > testdocs_test.go
|
||||
.bin/docreflect generate docreflect_test code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage > testdocs_test.go
|
||||
go test -count 1 . ./generate
|
||||
rm -f testdocs_test.go
|
||||
|
||||
.cover: $(SOURCES) .bin/docreflect
|
||||
.bin/docreflect generate docreflect_test code.squareroundforest.org/arpio/docreflect/tests/src/testpackage > testdocs_test.go
|
||||
.bin/docreflect generate docreflect_test code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage > testdocs_test.go
|
||||
go test -count 1 -coverprofile .cover . ./generate
|
||||
rm -f testdocs_test.go
|
||||
|
||||
|
@ -2,7 +2,7 @@ package docreflect_test
|
||||
|
||||
import (
|
||||
"code.squareroundforest.org/arpio/docreflect"
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage"
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -17,14 +17,14 @@ func Test(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("package", func(t *testing.T) {
|
||||
d := docreflect.Docs("code.squareroundforest.org/arpio/docreflect/tests/src/testpackage")
|
||||
d := docreflect.Docs("code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage")
|
||||
if !strings.Contains(d, "Package testpackage") {
|
||||
t.Fatal()
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("function by path", func(t *testing.T) {
|
||||
d := docreflect.Docs("code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedFunc")
|
||||
d := docreflect.Docs("code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedFunc")
|
||||
if !strings.Contains(d, "ExportedFunc has documentation") {
|
||||
t.Fatal()
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func TestGenerate(t *testing.T) {
|
||||
testGenerate(check(localDocs, "Docs returns the documentation for"), "", o, localDocs),
|
||||
)
|
||||
|
||||
packagePath := "code.squareroundforest.org/arpio/docreflect/tests/src/testpackage"
|
||||
packagePath := "code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage"
|
||||
t.Run(
|
||||
"package",
|
||||
testGenerate(
|
||||
@ -132,115 +132,115 @@ func TestGenerate(t *testing.T) {
|
||||
t.Run("symbol", func(t *testing.T) {
|
||||
t.Run("type", testGenerate(
|
||||
check(
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType",
|
||||
"ExportedType has docs",
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType2",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType2",
|
||||
"",
|
||||
),
|
||||
"",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType",
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType2",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType2",
|
||||
))
|
||||
|
||||
t.Run("const", testGenerate(
|
||||
check(
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.C1",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.C1",
|
||||
"C1 is a const",
|
||||
),
|
||||
"",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.C1",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.C1",
|
||||
))
|
||||
|
||||
t.Run("const grouped", testGenerate(
|
||||
check(
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.C3",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.C3",
|
||||
"Cx is a const",
|
||||
),
|
||||
"",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.C3",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.C3",
|
||||
))
|
||||
|
||||
t.Run("var", testGenerate(
|
||||
check(
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.V1",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.V1",
|
||||
"V1 is a var",
|
||||
),
|
||||
"",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.V1",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.V1",
|
||||
))
|
||||
|
||||
t.Run("var grouped", testGenerate(
|
||||
check(
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.V3",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.V3",
|
||||
"Vx is a var",
|
||||
),
|
||||
"",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.V3",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.V3",
|
||||
))
|
||||
|
||||
t.Run("func", testGenerate(
|
||||
check(
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedFunc",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedFunc",
|
||||
"ExportedFunc has documentation",
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.New",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.New",
|
||||
"New create a new instance of ExportedType",
|
||||
),
|
||||
"",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.New",
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedFunc",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.New",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedFunc",
|
||||
))
|
||||
})
|
||||
|
||||
t.Run("field", testGenerate(
|
||||
check(
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Foo",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType.Foo",
|
||||
"Foo is a field",
|
||||
),
|
||||
"",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Foo",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType.Foo",
|
||||
))
|
||||
|
||||
t.Run("method", testGenerate(
|
||||
check(
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Method",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType.Method",
|
||||
"Method is a method of ExportedType",
|
||||
),
|
||||
"",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Method",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType.Method",
|
||||
))
|
||||
|
||||
t.Run("inline struct type expression", testGenerate(
|
||||
check(
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Bar",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType.Bar",
|
||||
"Bar is an inline struct type expression",
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Bar.Baz",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType.Bar.Baz",
|
||||
"Baz is another field",
|
||||
),
|
||||
"",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Bar",
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Bar.Baz",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType.Bar",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType.Bar.Baz",
|
||||
))
|
||||
|
||||
t.Run("unexported symbol", testGenerate(
|
||||
check(
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.unexportedFunc",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.unexportedFunc",
|
||||
"unexportedFunc can have documentation",
|
||||
),
|
||||
"",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.unexportedFunc",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.unexportedFunc",
|
||||
))
|
||||
|
||||
mainFunc := "code.squareroundforest.org/arpio/docreflect/tests/src/command.main"
|
||||
mainFunc := "code.squareroundforest.org/arpio/docreflect/internal/tests/src/command.main"
|
||||
t.Run("main package", testGenerate(check(mainFunc, "main func"), "", o, mainFunc))
|
||||
})
|
||||
|
||||
@ -248,7 +248,7 @@ func TestGenerate(t *testing.T) {
|
||||
t.Run("package not found", testGenerate(nil, "package", o, "foo.bar.baz/qux"))
|
||||
t.Run(
|
||||
"symbol not found",
|
||||
testGenerate(nil, "symbol", o, "code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.Qux"),
|
||||
testGenerate(nil, "symbol", o, "code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.Qux"),
|
||||
)
|
||||
|
||||
t.Run(
|
||||
@ -257,7 +257,7 @@ func TestGenerate(t *testing.T) {
|
||||
nil,
|
||||
"symbol",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Qux",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType.Qux",
|
||||
),
|
||||
)
|
||||
|
||||
@ -267,13 +267,13 @@ func TestGenerate(t *testing.T) {
|
||||
nil,
|
||||
"symbol",
|
||||
o,
|
||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Foo.Qux",
|
||||
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType.Foo.Qux",
|
||||
),
|
||||
)
|
||||
|
||||
t.Run(
|
||||
"method not found",
|
||||
testGenerate(nil, "symbol", o, "code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType2.Qux"),
|
||||
testGenerate(nil, "symbol", o, "code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType2.Qux"),
|
||||
)
|
||||
|
||||
t.Run(
|
||||
@ -288,12 +288,12 @@ func TestGenerate(t *testing.T) {
|
||||
|
||||
t.Run(
|
||||
"parse failed, syntax error",
|
||||
testGenerate(nil, "package", o, "code.squareroundforest.org/arpio/docreflect/tests/src/syntaxerror"),
|
||||
testGenerate(nil, "package", o, "code.squareroundforest.org/arpio/docreflect/internal/tests/src/syntaxerror"),
|
||||
)
|
||||
|
||||
t.Run(
|
||||
"no type spec",
|
||||
testGenerate(nil, "symbol", o, "code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.Foo.Qux"),
|
||||
testGenerate(nil, "symbol", o, "code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.Foo.Qux"),
|
||||
)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user