Add minify config

Fixes #6750
Updates #6892
This commit is contained in:
SatowTakeshi 2020-02-29 18:44:05 +09:00 committed by Bjørn Erik Pedersen
parent 99958f90fe
commit 574c2959b8
12 changed files with 346 additions and 47 deletions

View file

@ -24,7 +24,11 @@ var DocProviders = make(map[string]DocProvider)
// AddDocProvider adds or updates the DocProvider for a given name.
func AddDocProvider(name string, provider DocProvider) {
DocProviders[name] = provider
if prev, ok := DocProviders[name]; !ok {
DocProviders[name] = provider
} else {
DocProviders[name] = merge(prev, provider)
}
}
// DocProvider is used to save arbitrary JSON data
@ -35,3 +39,13 @@ type DocProvider func() map[string]interface{}
func (d DocProvider) MarshalJSON() ([]byte, error) {
return json.MarshalIndent(d(), "", " ")
}
func merge(a, b DocProvider) DocProvider {
next := a()
for k, v := range b() {
next[k] = v
}
return func() map[string]interface{} {
return next
}
}