mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
entc: move bindata files to internal packages
Summary: godoc was showing "Code generated by go-bindata. (generated) DO NOT EDIT." in the package description and exposing its methods. Reviewed By: alexsn Differential Revision: D17253564 fbshipit-source-id: c82082b4fa6adfba2c2663efbfacefb6423f89d9
This commit is contained in:
committed by
Facebook Github Bot
parent
61b8ccea4a
commit
b2cedc6c95
@@ -2,6 +2,7 @@
|
||||
// This source code is licensed under the Apache 2.0 license found
|
||||
// in the LICENSE file in the root directory of this source tree.
|
||||
|
||||
// Package gen is the interface for generating loaded schemas into a Go package.
|
||||
package gen
|
||||
|
||||
import (
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
// template/predicate.tmpl
|
||||
// template/tx.tmpl
|
||||
// template/where.tmpl
|
||||
package gen
|
||||
package internal
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -12,9 +12,11 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"text/template"
|
||||
|
||||
"github.com/facebookincubator/ent/entc/gen/internal"
|
||||
)
|
||||
|
||||
//go:generate go-bindata -pkg=gen ./template/...
|
||||
//go:generate go-bindata -o=internal/bindata.go -pkg=internal ./template/...
|
||||
|
||||
var (
|
||||
// Templates holds the template information for a file that the graph is generating.
|
||||
@@ -108,8 +110,8 @@ var (
|
||||
|
||||
func init() {
|
||||
templates.Funcs(funcs)
|
||||
for _, asset := range AssetNames() {
|
||||
templates = template.Must(templates.Parse(string(MustAsset(asset))))
|
||||
for _, asset := range internal.AssetNames() {
|
||||
templates = template.Must(templates.Parse(string(internal.MustAsset(asset))))
|
||||
}
|
||||
b := bytes.NewBuffer([]byte("package main\n"))
|
||||
check(templates.ExecuteTemplate(b, "import", Type{}), "load imports")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// sources:
|
||||
// template/main.tmpl
|
||||
// schema.go
|
||||
package load
|
||||
package internal
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/facebookincubator/ent"
|
||||
"github.com/facebookincubator/ent/entc/load/internal"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/tools/go/packages"
|
||||
@@ -189,13 +190,13 @@ func indirectType(typ types.Type) types.Type {
|
||||
}
|
||||
}
|
||||
|
||||
//go:generate go-bindata -pkg=load ./template/... schema.go
|
||||
//go:generate go-bindata -pkg=internal -o=internal/bindata.go ./template/... schema.go
|
||||
|
||||
var buildTmpl = templates()
|
||||
|
||||
func templates() *template.Template {
|
||||
tmpl := template.New("templates").Funcs(template.FuncMap{"base": filepath.Base})
|
||||
tmpl = template.Must(tmpl.Parse(string(MustAsset("template/main.tmpl"))))
|
||||
tmpl = template.Must(tmpl.Parse(string(internal.MustAsset("template/main.tmpl"))))
|
||||
// turns the schema file and its imports into templates.
|
||||
tmpls, err := schemaTemplates()
|
||||
if err != nil {
|
||||
@@ -215,7 +216,7 @@ func schemaTemplates() ([]string, error) {
|
||||
code bytes.Buffer
|
||||
fset = token.NewFileSet()
|
||||
)
|
||||
f, err := parser.ParseFile(fset, name, string(MustAsset(name)), parser.AllErrors)
|
||||
f, err := parser.ParseFile(fset, name, string(internal.MustAsset(name)), parser.AllErrors)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "parse file: %s", name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user