mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
tpl: Fix golint godoc issues
This commit is contained in:
parent
400fe96aee
commit
f6f22ad944
6 changed files with 17 additions and 2 deletions
|
@ -15,6 +15,7 @@ package fmt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_fmt "fmt"
|
_fmt "fmt"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/helpers"
|
"github.com/gohugoio/hugo/helpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -44,6 +45,8 @@ func (ns *Namespace) Println(a ...interface{}) string {
|
||||||
return _fmt.Sprintln(a...)
|
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 {
|
func (ns *Namespace) Errorf(format string, a ...interface{}) string {
|
||||||
ns.errorLogger.Printf(format, a...)
|
ns.errorLogger.Printf(format, a...)
|
||||||
return _fmt.Sprintf(format, a...)
|
return _fmt.Sprintf(format, a...)
|
||||||
|
|
|
@ -34,12 +34,16 @@ import (
|
||||||
"github.com/gohugoio/hugo/deps"
|
"github.com/gohugoio/hugo/deps"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TemplateFuncsNamespaceRegistry describes a registry of functions that provide
|
||||||
|
// namespaces.
|
||||||
var TemplateFuncsNamespaceRegistry []func(d *deps.Deps) *TemplateFuncsNamespace
|
var TemplateFuncsNamespaceRegistry []func(d *deps.Deps) *TemplateFuncsNamespace
|
||||||
|
|
||||||
|
// AddTemplateFuncsNamespace adds a given function to a registry.
|
||||||
func AddTemplateFuncsNamespace(ns func(d *deps.Deps) *TemplateFuncsNamespace) {
|
func AddTemplateFuncsNamespace(ns func(d *deps.Deps) *TemplateFuncsNamespace) {
|
||||||
TemplateFuncsNamespaceRegistry = append(TemplateFuncsNamespaceRegistry, ns)
|
TemplateFuncsNamespaceRegistry = append(TemplateFuncsNamespaceRegistry, ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TemplateFuncsNamespace represents a template function namespace.
|
||||||
type TemplateFuncsNamespace struct {
|
type TemplateFuncsNamespace struct {
|
||||||
// The namespace name, "strings", "lang", etc.
|
// The namespace name, "strings", "lang", etc.
|
||||||
Name string
|
Name string
|
||||||
|
@ -51,8 +55,10 @@ type TemplateFuncsNamespace struct {
|
||||||
MethodMappings map[string]TemplateFuncMethodMapping
|
MethodMappings map[string]TemplateFuncMethodMapping
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TemplateFuncsNamespaces is a slice of TemplateFuncsNamespace.
|
||||||
type TemplateFuncsNamespaces []*TemplateFuncsNamespace
|
type TemplateFuncsNamespaces []*TemplateFuncsNamespace
|
||||||
|
|
||||||
|
// AddMethodMapping adds a method to a template function namespace.
|
||||||
func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []string, examples [][2]string) {
|
func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []string, examples [][2]string) {
|
||||||
if t.MethodMappings == nil {
|
if t.MethodMappings == nil {
|
||||||
t.MethodMappings = make(map[string]TemplateFuncMethodMapping)
|
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 {
|
type TemplateFuncMethodMapping struct {
|
||||||
Method interface{}
|
Method interface{}
|
||||||
|
|
||||||
|
@ -134,6 +142,7 @@ func (t goDocFunc) toJSON() ([]byte, error) {
|
||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalJSON returns the JSON encoding of namespaces.
|
||||||
func (namespaces TemplateFuncsNamespaces) MarshalJSON() ([]byte, error) {
|
func (namespaces TemplateFuncsNamespaces) MarshalJSON() ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ type Namespace struct {
|
||||||
deps *deps.Deps
|
deps *deps.Deps
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate ...
|
// Translate returns a translated string for id.
|
||||||
func (ns *Namespace) Translate(id interface{}, args ...interface{}) (string, error) {
|
func (ns *Namespace) Translate(id interface{}, args ...interface{}) (string, error) {
|
||||||
sid, err := cast.ToStringE(id)
|
sid, err := cast.ToStringE(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -140,6 +140,7 @@ type pagesLanguageMerger interface {
|
||||||
MergeByLanguageInterface(other interface{}) (interface{}, error)
|
MergeByLanguageInterface(other interface{}) (interface{}, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merge creates a union of pages from two languages.
|
||||||
func (ns *Namespace) Merge(p2, p1 interface{}) (interface{}, error) {
|
func (ns *Namespace) Merge(p2, p1 interface{}) (interface{}, error) {
|
||||||
merger, ok := p1.(pagesLanguageMerger)
|
merger, ok := p1.(pagesLanguageMerger)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
## Build Templates
|
## 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.
|
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.
|
||||||
|
|
|
@ -81,6 +81,7 @@ func main() {
|
||||||
// Package embedded defines the internal templates that Hugo provides.
|
// Package embedded defines the internal templates that Hugo provides.
|
||||||
package embedded
|
package embedded
|
||||||
|
|
||||||
|
// EmbeddedTemplates represents all embedded templates.
|
||||||
var EmbeddedTemplates = [][2]string{
|
var EmbeddedTemplates = [][2]string{
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
|
1
tpl/tplimpl/embedded/templates.autogen.go
generated
1
tpl/tplimpl/embedded/templates.autogen.go
generated
|
@ -16,6 +16,7 @@
|
||||||
// Package embedded defines the internal templates that Hugo provides.
|
// Package embedded defines the internal templates that Hugo provides.
|
||||||
package embedded
|
package embedded
|
||||||
|
|
||||||
|
// EmbeddedTemplates represents all embedded templates.
|
||||||
var EmbeddedTemplates = [][2]string{
|
var EmbeddedTemplates = [][2]string{
|
||||||
{`_default/robots.txt`, `User-agent: *`},
|
{`_default/robots.txt`, `User-agent: *`},
|
||||||
{`_default/rss.xml`, `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
{`_default/rss.xml`, `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
|
|
Loading…
Reference in a new issue