docshelper.go - hugo - [fork] hugo port for 9front
HTML git clone https://git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
docshelper.go (1634B)
---
1 // Copyright 2017 The Hugo Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 package cast
15
16 import (
17 "github.com/gohugoio/hugo/config"
18 "github.com/gohugoio/hugo/config/testconfig"
19 "github.com/gohugoio/hugo/deps"
20 "github.com/gohugoio/hugo/docshelper"
21 "github.com/gohugoio/hugo/resources/page"
22 "github.com/gohugoio/hugo/tpl/internal"
23 )
24
25 // This file provides documentation support and is randomly put into this package.
26 func init() {
27 docsProvider := func() docshelper.DocProvider {
28 d := &deps.Deps{Conf: testconfig.GetTestConfig(nil, nil)}
29 if err := d.Init(); err != nil {
30 panic(err)
31 }
32 conf := testconfig.GetTestConfig(nil, newTestConfig())
33 d.Site = page.NewDummyHugoSite(conf)
34
35 var namespaces internal.TemplateFuncsNamespaces
36
37 for _, nsf := range internal.TemplateFuncsNamespaceRegistry {
38 nf := nsf(d)
39 namespaces = append(namespaces, nf)
40
41 }
42
43 return docshelper.DocProvider{"tpl": map[string]any{"funcs": namespaces}}
44 }
45
46 docshelper.AddDocProviderFunc(docsProvider)
47 }
48
49 func newTestConfig() config.Provider {
50 v := config.New()
51 v.Set("contentDir", "content")
52 return v
53 }