diff --git a/pkg/codegen/docs/gen.go b/pkg/codegen/docs/gen.go
index 2fb0f3b78..668dbf202 100644
--- a/pkg/codegen/docs/gen.go
+++ b/pkg/codegen/docs/gen.go
@@ -128,6 +128,12 @@ type formalParam struct {
DefaultValue string
}
+type packageDetails struct {
+ Repository string
+ License string
+ Notes string
+}
+
type resourceDocArgs struct {
Header header
@@ -162,6 +168,8 @@ type resourceDocArgs struct {
// NestedTypes is a slice of the nested types used in the input and
// output properties.
NestedTypes []docNestedType
+
+ PackageDetails packageDetails
}
type appearsIn struct {
@@ -850,6 +858,12 @@ func (mod *modContext) genResource(r *schema.Resource) resourceDocArgs {
}
}
+ packageDetails := packageDetails{
+ Repository: mod.pkg.Repository,
+ License: mod.pkg.License,
+ Notes: mod.pkg.Attribution,
+ }
+
stateParam := name + "State"
data := resourceDocArgs{
Header: header{
@@ -868,6 +882,8 @@ func (mod *modContext) genResource(r *schema.Resource) resourceDocArgs {
StateInputs: stateInputs,
StateParam: stateParam,
NestedTypes: mod.genNestedTypes(r, true /*resourceType*/),
+
+ PackageDetails: packageDetails,
}
return data
@@ -1087,6 +1103,16 @@ func (mod *modContext) genIndex(exports []string) string {
fmt.Fprintf(w, "\n\n")
}
+ fmt.Fprintf(w, "
Package Details
\n")
+ fmt.Fprintf(w, "\n")
+ fmt.Fprintf(w, " - Repository
\n")
+ fmt.Fprintf(w, " - %s
\n", mod.pkg.Repository)
+ fmt.Fprintf(w, " - License
\n")
+ fmt.Fprintf(w, " - %s
\n", mod.pkg.License)
+ fmt.Fprintf(w, " - Notes
\n")
+ fmt.Fprintf(w, " - %s
\n", mod.pkg.Attribution)
+ fmt.Fprintf(w, "
\n\n")
+
return w.String()
}
diff --git a/pkg/codegen/docs/templates/resource.tmpl b/pkg/codegen/docs/templates/resource.tmpl
index 1c9640cc2..bfcd7d905 100644
--- a/pkg/codegen/docs/templates/resource.tmpl
+++ b/pkg/codegen/docs/templates/resource.tmpl
@@ -137,3 +137,15 @@ The following state arguments are supported:
{{ end }}
{{ end }}
+
+Package Details
+
+ - Repository
+ - {{ htmlSafe .PackageDetails.Repository }}
+ - License
+ - {{ htmlSafe .PackageDetails.License }}
+ {{- if ne .PackageDetails.Notes "" -}}
+ - Notes
+ - {{ htmlSafe .PackageDetails.Notes }}
+ {{- end -}}
+
diff --git a/pkg/codegen/go/gen.go b/pkg/codegen/go/gen.go
index a73339566..353d3967a 100644
--- a/pkg/codegen/go/gen.go
+++ b/pkg/codegen/go/gen.go
@@ -854,7 +854,6 @@ func (pkg *pkgContext) genHeader(w io.Writer, goImports []string, importedPackag
pkgName = path.Base(pkg.mod)
}
- fmt.Fprintf(w, "// nolint: lll\n")
fmt.Fprintf(w, "package %s\n\n", pkgName)
var imports []string
@@ -1126,13 +1125,13 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
switch mod {
case "":
buffer := &bytes.Buffer{}
- fmt.Fprintf(buffer, "// Package %[1]s exports types, functions, subpackages for provisioning %[1]s resources.", pkg.pkg.Name)
- fmt.Fprintf(buffer, "//\n")
if pkg.pkg.Description != "" {
printComment(buffer, pkg.pkg.Description, false)
fmt.Fprintf(buffer, "//\n")
+ } else {
+ fmt.Fprintf(buffer, "// Package %[1]s exports types, functions, subpackages for provisioning %[1]s resources.\n", pkg.pkg.Name)
+ fmt.Fprintf(buffer, "//\n")
}
- fmt.Fprintf(buffer, "// nolint: lll\n")
fmt.Fprintf(buffer, "package %s\n", name)
setFile(path.Join(mod, "doc.go"), buffer.String())
diff --git a/pkg/codegen/schema/schema.go b/pkg/codegen/schema/schema.go
index 720d4a2e9..e8d39f751 100644
--- a/pkg/codegen/schema/schema.go
+++ b/pkg/codegen/schema/schema.go
@@ -264,6 +264,8 @@ type Package struct {
Homepage string
// License indicates which license is used for the package's contents.
License string
+ // Attribution allows freeform text attribution of derived work, if needed.
+ Attribution string
// Repository is the URL at which the source for the package can be found.
Repository string
// LogoURL is the URL for the package's logo, if any.
@@ -431,6 +433,8 @@ type PackageSpec struct {
Homepage string `json:"homepage,omitempty"`
// License indicates which license is used for the package's contents.
License string `json:"license,omitempty"`
+ // Attribution allows freeform text attribution of derived work, if needed.
+ Attribution string `json:"attribution,omitempty"`
// Repository is the URL at which the source for the package can be found.
Repository string `json:"repository,omitempty"`
// LogoURL is the URL for the package's logo, if any.
@@ -530,6 +534,7 @@ func ImportSpec(spec PackageSpec) (*Package, error) {
Keywords: spec.Keywords,
Homepage: spec.Homepage,
License: spec.License,
+ Attribution: spec.Attribution,
Repository: spec.Repository,
Config: config,
Types: typeList,
diff --git a/sdk/go.sum b/sdk/go.sum
index 1e836ea78..da802feb1 100644
--- a/sdk/go.sum
+++ b/sdk/go.sum
@@ -167,6 +167,7 @@ github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=