diff options
author | Jorin Vogel <hi@jorin.me> | 2017-08-02 14:25:05 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-08-03 15:57:51 +0200 |
commit | 81c13171a985b89f2af6682dbd1d4b8766cb9af7 (patch) | |
tree | db39d78bbe6da0ea3f3dd3d2f94c7e1571ad8fd6 /tpl | |
parent | 9891c0fb0eb274b8a95b62c40070a87a6e04088c (diff) |
Add some missing doc comments
As pointed out by the linter, some exported functions and types are
missing doc comments.
The linter warnings have been reduced from 194 to 116.
Not all missing comments have been added in this commit though.
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/fmt/fmt.go | 3 | ||||
-rw-r--r-- | tpl/math/math.go | 5 | ||||
-rw-r--r-- | tpl/os/os.go | 6 | ||||
-rw-r--r-- | tpl/partials/partials.go | 2 | ||||
-rw-r--r-- | tpl/strings/truncate.go | 1 | ||||
-rw-r--r-- | tpl/template.go | 1 | ||||
-rw-r--r-- | tpl/tplimpl/templateProvider.go | 6 | ||||
-rw-r--r-- | tpl/urls/urls.go | 1 |
8 files changed, 20 insertions, 5 deletions
diff --git a/tpl/fmt/fmt.go b/tpl/fmt/fmt.go index ca31ec522..e9d47dbd4 100644 --- a/tpl/fmt/fmt.go +++ b/tpl/fmt/fmt.go @@ -26,15 +26,18 @@ func New() *Namespace { type Namespace struct { } +// Print returns string representation of the passed arguments. func (ns *Namespace) Print(a ...interface{}) string { return _fmt.Sprint(a...) } +// Printf returns a formatted string representation of the passed arguments. func (ns *Namespace) Printf(format string, a ...interface{}) string { return _fmt.Sprintf(format, a...) } +// Print returns string representation of the passed arguments ending with a newline. func (ns *Namespace) Println(a ...interface{}) string { return _fmt.Sprintln(a...) } diff --git a/tpl/math/math.go b/tpl/math/math.go index 303f029af..f45488166 100644 --- a/tpl/math/math.go +++ b/tpl/math/math.go @@ -29,14 +29,17 @@ func New() *Namespace { // Namespace provides template functions for the "math" namespace. type Namespace struct{} +// Add adds two numbers. func (ns *Namespace) Add(a, b interface{}) (interface{}, error) { return DoArithmetic(a, b, '+') } +// Div divides two numbers. func (ns *Namespace) Div(a, b interface{}) (interface{}, error) { return DoArithmetic(a, b, '/') } +// Log returns the natural logarithm of a number. func (ns *Namespace) Log(a interface{}) (float64, error) { af, err := cast.ToFloat64E(a) @@ -84,10 +87,12 @@ func (ns *Namespace) ModBool(a, b interface{}) (bool, error) { return res == int64(0), nil } +// Mul multiplies two numbers. func (ns *Namespace) Mul(a, b interface{}) (interface{}, error) { return DoArithmetic(a, b, '*') } +// Sub substracts two numbers. func (ns *Namespace) Sub(a, b interface{}) (interface{}, error) { return DoArithmetic(a, b, '-') } diff --git a/tpl/os/os.go b/tpl/os/os.go index fb60f87dd..c9ffb81cf 100644 --- a/tpl/os/os.go +++ b/tpl/os/os.go @@ -70,9 +70,9 @@ func readFile(fs *afero.BasePathFs, filename string) (string, error) { return string(b), nil } -// ReadFilereads the file named by filename relative to the configured -// WorkingDir. It returns the contents as a string. There is a upper size -// limit set at 1 megabytes. +// ReadFile reads the file named by filename relative to the configured WorkingDir. +// It returns the contents as a string. +// There is an upper size limit set at 1 megabytes. func (ns *Namespace) ReadFile(i interface{}) (string, error) { s, err := cast.ToStringE(i) if err != nil { diff --git a/tpl/partials/partials.go b/tpl/partials/partials.go index d6e9fc9c5..cf89bad37 100644 --- a/tpl/partials/partials.go +++ b/tpl/partials/partials.go @@ -24,6 +24,8 @@ import ( "github.com/gohugoio/hugo/deps" ) +// TestTemplateProvider is global deps.ResourceProvider. +// NOTE: It's currently unused. var TestTemplateProvider deps.ResourceProvider // partialCache represents a cache of partials protected by a mutex. diff --git a/tpl/strings/truncate.go b/tpl/strings/truncate.go index 923816e9f..6e3a50ed2 100644 --- a/tpl/strings/truncate.go +++ b/tpl/strings/truncate.go @@ -39,6 +39,7 @@ type htmlTag struct { openTag bool } +// Truncate truncates a given string to the specified length. func (ns *Namespace) Truncate(a interface{}, options ...interface{}) (template.HTML, error) { length, err := cast.ToIntE(a) if err != nil { diff --git a/tpl/template.go b/tpl/template.go index 2ee322498..02d4a541c 100644 --- a/tpl/template.go +++ b/tpl/template.go @@ -101,6 +101,7 @@ func (t *TemplateAdapter) Tree() string { return s } +// TemplateFuncsGetter allows to get a map of functions. type TemplateFuncsGetter interface { GetFuncs() map[string]interface{} } diff --git a/tpl/tplimpl/templateProvider.go b/tpl/tplimpl/templateProvider.go index 5d5ee44b6..af89fed11 100644 --- a/tpl/tplimpl/templateProvider.go +++ b/tpl/tplimpl/templateProvider.go @@ -17,12 +17,14 @@ import ( "github.com/gohugoio/hugo/deps" ) +// TemplateProvider manages templates. type TemplateProvider struct{} +// DefaultTemplateProvider is a globally available TemplateProvider. var DefaultTemplateProvider *TemplateProvider -// Update updates the Hugo Template System in the provided Deps. -// with all the additional features, templates & functions +// Update updates the Hugo Template System in the provided Deps +// with all the additional features, templates & functions. func (*TemplateProvider) Update(deps *deps.Deps) error { newTmpl := newTemplateAdapter(deps) diff --git a/tpl/urls/urls.go b/tpl/urls/urls.go index e29cabe89..817ed8b15 100644 --- a/tpl/urls/urls.go +++ b/tpl/urls/urls.go @@ -54,6 +54,7 @@ func (ns *Namespace) RelURL(a interface{}) (template.HTML, error) { return template.HTML(ns.deps.PathSpec.RelURL(s, false)), nil } +// URLize returns the given argument formatted as URL. func (ns *Namespace) URLize(a interface{}) (string, error) { s, err := cast.ToStringE(a) if err != nil { |