summaryrefslogtreecommitdiffstats
path: root/tpl
diff options
context:
space:
mode:
authorCameron Moore <moorereason@gmail.com>2018-09-06 17:25:30 -0500
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-09-07 08:25:51 +0200
commitf6f22ad944a1c308fd823792b2fbff1504f42cef (patch)
tree3d233fb691e25e6818a3467e3e2c65d7c46678a9 /tpl
parent400fe96aee8e38112e347e762661b8389701c938 (diff)
tpl: Fix golint godoc issues
Diffstat (limited to 'tpl')
-rw-r--r--tpl/fmt/fmt.go3
-rw-r--r--tpl/internal/templatefuncsRegistry.go9
-rw-r--r--tpl/lang/lang.go3
-rw-r--r--tpl/tplimpl/embedded/README.md2
-rw-r--r--tpl/tplimpl/embedded/generate/generate.go1
-rw-r--r--tpl/tplimpl/embedded/templates.autogen.go1
6 files changed, 17 insertions, 2 deletions
diff --git a/tpl/fmt/fmt.go b/tpl/fmt/fmt.go
index 96113a598..0f4f906c2 100644
--- a/tpl/fmt/fmt.go
+++ b/tpl/fmt/fmt.go
@@ -15,6 +15,7 @@ package fmt
import (
_fmt "fmt"
+
"github.com/gohugoio/hugo/helpers"
)
@@ -44,6 +45,8 @@ func (ns *Namespace) Println(a ...interface{}) string {
return _fmt.Sprintln(a...)
}
+// Errorf formats according to a format specifier and returns the string as a
+// value that satisfies error.
func (ns *Namespace) Errorf(format string, a ...interface{}) string {
ns.errorLogger.Printf(format, a...)
return _fmt.Sprintf(format, a...)
diff --git a/tpl/internal/templatefuncsRegistry.go b/tpl/internal/templatefuncsRegistry.go
index 0f11be65c..99877dcca 100644
--- a/tpl/internal/templatefuncsRegistry.go
+++ b/tpl/internal/templatefuncsRegistry.go
@@ -34,12 +34,16 @@ import (
"github.com/gohugoio/hugo/deps"
)
+// TemplateFuncsNamespaceRegistry describes a registry of functions that provide
+// namespaces.
var TemplateFuncsNamespaceRegistry []func(d *deps.Deps) *TemplateFuncsNamespace
+// AddTemplateFuncsNamespace adds a given function to a registry.
func AddTemplateFuncsNamespace(ns func(d *deps.Deps) *TemplateFuncsNamespace) {
TemplateFuncsNamespaceRegistry = append(TemplateFuncsNamespaceRegistry, ns)
}
+// TemplateFuncsNamespace represents a template function namespace.
type TemplateFuncsNamespace struct {
// The namespace name, "strings", "lang", etc.
Name string
@@ -51,8 +55,10 @@ type TemplateFuncsNamespace struct {
MethodMappings map[string]TemplateFuncMethodMapping
}
+// TemplateFuncsNamespaces is a slice of TemplateFuncsNamespace.
type TemplateFuncsNamespaces []*TemplateFuncsNamespace
+// AddMethodMapping adds a method to a template function namespace.
func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []string, examples [][2]string) {
if t.MethodMappings == nil {
t.MethodMappings = make(map[string]TemplateFuncMethodMapping)
@@ -80,6 +86,8 @@ func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []strin
}
+// TemplateFuncMethodMapping represents a mapping of functions to methods for a
+// given namespace.
type TemplateFuncMethodMapping struct {
Method interface{}
@@ -134,6 +142,7 @@ func (t goDocFunc) toJSON() ([]byte, error) {
return buf.Bytes(), nil
}
+// MarshalJSON returns the JSON encoding of namespaces.
func (namespaces TemplateFuncsNamespaces) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
diff --git a/tpl/lang/lang.go b/tpl/lang/lang.go
index b29b182ab..430b5e442 100644
--- a/tpl/lang/lang.go
+++ b/tpl/lang/lang.go
@@ -36,7 +36,7 @@ type Namespace struct {
deps *deps.Deps
}
-// Translate ...
+// Translate returns a translated string for id.
func (ns *Namespace) Translate(id interface{}, args ...interface{}) (string, error) {
sid, err := cast.ToStringE(id)
if err != nil {
@@ -140,6 +140,7 @@ type pagesLanguageMerger interface {
MergeByLanguageInterface(other interface{}) (interface{}, error)
}
+// Merge creates a union of pages from two languages.
func (ns *Namespace) Merge(p2, p1 interface{}) (interface{}, error) {
merger, ok := p1.(pagesLanguageMerger)
if !ok {
diff --git a/tpl/tplimpl/embedded/README.md b/tpl/tplimpl/embedded/README.md
index e14ef1115..1c01961e1 100644
--- a/tpl/tplimpl/embedded/README.md
+++ b/tpl/tplimpl/embedded/README.md
@@ -2,4 +2,4 @@
## Build Templates
-If you add or modify any template in the tmplates folder, you also need to run `mage generate` to get the Go code in synch. \ No newline at end of file
+If you add or modify any template in the templates folder, you also need to run `mage generate` to get the Go code in synch.
diff --git a/tpl/tplimpl/embedded/generate/generate.go b/tpl/tplimpl/embedded/generate/generate.go
index 14b877c55..76a167a99 100644
--- a/tpl/tplimpl/embedded/generate/generate.go
+++ b/tpl/tplimpl/embedded/generate/generate.go
@@ -81,6 +81,7 @@ func main() {
// Package embedded defines the internal templates that Hugo provides.
package embedded
+// EmbeddedTemplates represents all embedded templates.
var EmbeddedTemplates = [][2]string{
`)
diff --git a/tpl/tplimpl/embedded/templates.autogen.go b/tpl/tplimpl/embedded/templates.autogen.go
index 046882ed3..b185ec1bb 100644
--- a/tpl/tplimpl/embedded/templates.autogen.go
+++ b/tpl/tplimpl/embedded/templates.autogen.go
@@ -16,6 +16,7 @@
// Package embedded defines the internal templates that Hugo provides.
package embedded
+// EmbeddedTemplates represents all embedded templates.
var EmbeddedTemplates = [][2]string{
{`_default/robots.txt`, `User-agent: *`},
{`_default/rss.xml`, `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">