mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
tpl: Misco GoDoc improvements
This commit is contained in:
parent
dc44bca963
commit
7d5e3ab8a8
3 changed files with 20 additions and 3 deletions
|
@ -59,11 +59,12 @@ func (d goatDiagram) Height() int {
|
|||
return d.d.Height
|
||||
}
|
||||
|
||||
type Diagrams struct {
|
||||
// Namespace provides template functions for the diagrams namespace.
|
||||
type Namespace struct {
|
||||
d *deps.Deps
|
||||
}
|
||||
|
||||
func (d *Diagrams) Goat(v any) SVGDiagram {
|
||||
func (d *Namespace) Goat(v any) SVGDiagram {
|
||||
var r io.Reader
|
||||
|
||||
switch vv := v.(type) {
|
||||
|
|
|
@ -22,7 +22,7 @@ const name = "diagrams"
|
|||
|
||||
func init() {
|
||||
f := func(d *deps.Deps) *internal.TemplateFuncsNamespace {
|
||||
ctx := &Diagrams{
|
||||
ctx := &Namespace{
|
||||
d: d,
|
||||
}
|
||||
|
||||
|
|
|
@ -141,6 +141,22 @@ func (t goDocFunc) toJSON() ([]byte, error) {
|
|||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// ToMap returns a limited map representation of the namespaces.
|
||||
func (namespaces TemplateFuncsNamespaces) ToMap() map[string]any {
|
||||
m := make(map[string]any)
|
||||
for _, ns := range namespaces {
|
||||
mm := make(map[string]any)
|
||||
for name, mapping := range ns.MethodMappings {
|
||||
mm[name] = map[string]any{
|
||||
"Examples": mapping.Examples,
|
||||
"Aliases": mapping.Aliases,
|
||||
}
|
||||
}
|
||||
m[ns.Name] = mm
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
// MarshalJSON returns the JSON encoding of namespaces.
|
||||
func (namespaces TemplateFuncsNamespaces) MarshalJSON() ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
|
|
Loading…
Reference in a new issue