docs.go - hugo - [fork] hugo port for 9front
(HTM) git clone https://git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
docs.go (1412B)
---
1 // Copyright 2017-present 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 docshelper provides some helpers for the Hugo documentation, and
15 // is of limited interest for the general Hugo user.
16 package docshelper
17
18 import "fmt"
19
20 type (
21 DocProviderFunc = func() DocProvider
22 DocProvider map[string]any
23 )
24
25 var docProviderFuncs []DocProviderFunc
26
27 func AddDocProviderFunc(fn DocProviderFunc) {
28 docProviderFuncs = append(docProviderFuncs, fn)
29 }
30
31 func GetDocProvider() DocProvider {
32 provider := make(DocProvider)
33
34 for _, fn := range docProviderFuncs {
35 p := fn()
36 for k, v := range p {
37 if _, found := provider[k]; found {
38 // We use to merge config, but not anymore.
39 // These constructs will eventually go away, so just make it simple.
40 panic(fmt.Sprintf("Duplicate doc provider key: %q", k))
41 }
42 provider[k] = v
43 }
44 }
45
46 return provider
47 }