mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
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.
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
9891c0fb0e
commit
81c13171a9
@@ -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...)
|
||||
}
|
||||
|
@@ -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, '-')
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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.
|
||||
|
@@ -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 {
|
||||
|
@@ -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{}
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user