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
|
mkdir -p .bin
|
||||||
|
|
||||||
check: $(SOURCES) .bin/docreflect
|
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
|
go test -count 1 . ./generate
|
||||||
rm -f testdocs_test.go
|
rm -f testdocs_test.go
|
||||||
|
|
||||||
.cover: $(SOURCES) .bin/docreflect
|
.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
|
go test -count 1 -coverprofile .cover . ./generate
|
||||||
rm -f testdocs_test.go
|
rm -f testdocs_test.go
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package docreflect_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"code.squareroundforest.org/arpio/docreflect"
|
"code.squareroundforest.org/arpio/docreflect"
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage"
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -17,14 +17,14 @@ func Test(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("package", func(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") {
|
if !strings.Contains(d, "Package testpackage") {
|
||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("function by path", func(t *testing.T) {
|
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") {
|
if !strings.Contains(d, "ExportedFunc has documentation") {
|
||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ func TestGenerate(t *testing.T) {
|
|||||||
testGenerate(check(localDocs, "Docs returns the documentation for"), "", o, localDocs),
|
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(
|
t.Run(
|
||||||
"package",
|
"package",
|
||||||
testGenerate(
|
testGenerate(
|
||||||
@ -132,115 +132,115 @@ func TestGenerate(t *testing.T) {
|
|||||||
t.Run("symbol", func(t *testing.T) {
|
t.Run("symbol", func(t *testing.T) {
|
||||||
t.Run("type", testGenerate(
|
t.Run("type", testGenerate(
|
||||||
check(
|
check(
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType",
|
||||||
"ExportedType has docs",
|
"ExportedType has docs",
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType2",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType2",
|
||||||
"",
|
"",
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
o,
|
o,
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType",
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType2",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedType2",
|
||||||
))
|
))
|
||||||
|
|
||||||
t.Run("const", testGenerate(
|
t.Run("const", testGenerate(
|
||||||
check(
|
check(
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.C1",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.C1",
|
||||||
"C1 is a const",
|
"C1 is a const",
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
o,
|
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(
|
t.Run("const grouped", testGenerate(
|
||||||
check(
|
check(
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.C3",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.C3",
|
||||||
"Cx is a const",
|
"Cx is a const",
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
o,
|
o,
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.C3",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.C3",
|
||||||
))
|
))
|
||||||
|
|
||||||
t.Run("var", testGenerate(
|
t.Run("var", testGenerate(
|
||||||
check(
|
check(
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.V1",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.V1",
|
||||||
"V1 is a var",
|
"V1 is a var",
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
o,
|
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(
|
t.Run("var grouped", testGenerate(
|
||||||
check(
|
check(
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.V3",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.V3",
|
||||||
"Vx is a var",
|
"Vx is a var",
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
o,
|
o,
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.V3",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.V3",
|
||||||
))
|
))
|
||||||
|
|
||||||
t.Run("func", testGenerate(
|
t.Run("func", testGenerate(
|
||||||
check(
|
check(
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedFunc",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedFunc",
|
||||||
"ExportedFunc has documentation",
|
"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",
|
"New create a new instance of ExportedType",
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
o,
|
o,
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.New",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.New",
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedFunc",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.ExportedFunc",
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("field", testGenerate(
|
t.Run("field", testGenerate(
|
||||||
check(
|
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",
|
"Foo is a field",
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
o,
|
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(
|
t.Run("method", testGenerate(
|
||||||
check(
|
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",
|
"Method is a method of ExportedType",
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
o,
|
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(
|
t.Run("inline struct type expression", testGenerate(
|
||||||
check(
|
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",
|
"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",
|
"Baz is another field",
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
o,
|
o,
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.ExportedType.Bar",
|
"code.squareroundforest.org/arpio/docreflect/internal/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.Baz",
|
||||||
))
|
))
|
||||||
|
|
||||||
t.Run("unexported symbol", testGenerate(
|
t.Run("unexported symbol", testGenerate(
|
||||||
check(
|
check(
|
||||||
"code.squareroundforest.org/arpio/docreflect/tests/src/testpackage.unexportedFunc",
|
"code.squareroundforest.org/arpio/docreflect/internal/tests/src/testpackage.unexportedFunc",
|
||||||
"unexportedFunc can have documentation",
|
"unexportedFunc can have documentation",
|
||||||
),
|
),
|
||||||
"",
|
"",
|
||||||
o,
|
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))
|
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("package not found", testGenerate(nil, "package", o, "foo.bar.baz/qux"))
|
||||||
t.Run(
|
t.Run(
|
||||||
"symbol not found",
|
"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(
|
t.Run(
|
||||||
@ -257,7 +257,7 @@ func TestGenerate(t *testing.T) {
|
|||||||
nil,
|
nil,
|
||||||
"symbol",
|
"symbol",
|
||||||
o,
|
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,
|
nil,
|
||||||
"symbol",
|
"symbol",
|
||||||
o,
|
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(
|
t.Run(
|
||||||
"method not found",
|
"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(
|
t.Run(
|
||||||
@ -288,12 +288,12 @@ func TestGenerate(t *testing.T) {
|
|||||||
|
|
||||||
t.Run(
|
t.Run(
|
||||||
"parse failed, syntax error",
|
"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(
|
t.Run(
|
||||||
"no type spec",
|
"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