diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-06-30 08:47:11 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-06-30 10:24:28 +0200 |
commit | ffd37d4f757c8448afd49823d2252532be7f7e00 (patch) | |
tree | 2b09f9d83a9be6966e74731fed741114a49a197c /config | |
parent | b4b65245b28e623e927941d4a07635535e6377fc (diff) | |
download | hugo-ffd37d4f757c8448afd49823d2252532be7f7e00.tar.gz hugo-ffd37d4f757c8448afd49823d2252532be7f7e00.zip |
Only print the path warnings once
We could reset and rerun it on server rebuilds, but that report needs a full build to make sense.
Also clean up the config vs flags in this area: Make all config settings match the flags e.g. `printPathWarnings`, but set up aliases for the
old.
Fixes #11187
Diffstat (limited to 'config')
-rw-r--r-- | config/allconfig/allconfig.go | 12 | ||||
-rw-r--r-- | config/allconfig/configlanguage.go | 4 | ||||
-rw-r--r-- | config/allconfig/integration_test.go | 18 | ||||
-rw-r--r-- | config/allconfig/load.go | 6 | ||||
-rw-r--r-- | config/configProvider.go | 2 |
5 files changed, 32 insertions, 10 deletions
diff --git a/config/allconfig/allconfig.go b/config/allconfig/allconfig.go index 2dc409be7..bab15501b 100644 --- a/config/allconfig/allconfig.go +++ b/config/allconfig/allconfig.go @@ -484,12 +484,6 @@ type RootConfig struct { // Enable to print greppable placeholders (on the form "[i18n] TRANSLATIONID") for missing translation strings. EnableMissingTranslationPlaceholders bool - // Enable to print warnings for missing translation strings. - LogI18nWarnings bool - - // ENable to print warnings for multiple files published to the same destination. - LogPathWarnings bool - // Enable to panic on warning log entries. This may make it easier to detect the source. PanicOnWarning bool @@ -525,6 +519,12 @@ type RootConfig struct { // Whether to track and print unused templates during the build. PrintUnusedTemplates bool + // Enable to print warnings for missing translation strings. + PrintI18nWarnings bool + + // ENable to print warnings for multiple files published to the same destination. + PrintPathWarnings bool + // URL to be used as a placeholder when a page reference cannot be found in ref or relref. Is used as-is. RefLinksNotFoundURL string diff --git a/config/allconfig/configlanguage.go b/config/allconfig/configlanguage.go index 95c5c7edf..be549126b 100644 --- a/config/allconfig/configlanguage.go +++ b/config/allconfig/configlanguage.go @@ -199,8 +199,8 @@ func (c ConfigLanguage) EnableMissingTranslationPlaceholders() bool { return c.config.EnableMissingTranslationPlaceholders } -func (c ConfigLanguage) LogI18nWarnings() bool { - return c.config.LogI18nWarnings +func (c ConfigLanguage) PrintI18nWarnings() bool { + return c.config.PrintI18nWarnings } func (c ConfigLanguage) CreateTitle(s string) string { diff --git a/config/allconfig/integration_test.go b/config/allconfig/integration_test.go index 2de83eaa4..fcb92e71d 100644 --- a/config/allconfig/integration_test.go +++ b/config/allconfig/integration_test.go @@ -69,3 +69,21 @@ Title: {{ .Title }} b.Assert(modConf.Mounts[1].Lang, qt.Equals, "sv") } + +func TestConfigAliases(t *testing.T) { + + files := ` +-- hugo.toml -- +baseURL = "https://example.com" +logI18nWarnings = true +logPathWarnings = true +` + b := hugolib.NewIntegrationTestBuilder( + hugolib.IntegrationTestConfig{T: t, TxtarString: files}, + ).Build() + + conf := b.H.Configs.Base + + b.Assert(conf.PrintI18nWarnings, qt.Equals, true) + b.Assert(conf.PrintPathWarnings, qt.Equals, true) +} diff --git a/config/allconfig/load.go b/config/allconfig/load.go index 4e5478c40..b9bb38aaf 100644 --- a/config/allconfig/load.go +++ b/config/allconfig/load.go @@ -139,7 +139,11 @@ type configLoader struct { // Handle some legacy values. func (l configLoader) applyConfigAliases() error { - aliases := []types.KeyValueStr{{Key: "taxonomies", Value: "indexes"}} + aliases := []types.KeyValueStr{ + {Key: "indexes", Value: "taxonomies"}, + {Key: "logI18nWarnings", Value: "printI18nWarnings"}, + {Key: "logPathWarnings", Value: "printPathWarnings"}, + } for _, alias := range aliases { if l.cfg.IsSet(alias.Key) { diff --git a/config/configProvider.go b/config/configProvider.go index 8ed0728bd..5d6acce9f 100644 --- a/config/configProvider.go +++ b/config/configProvider.go @@ -57,7 +57,7 @@ type AllProvider interface { EnableMissingTranslationPlaceholders() bool TemplateMetrics() bool TemplateMetricsHints() bool - LogI18nWarnings() bool + PrintI18nWarnings() bool CreateTitle(s string) string IgnoreFile(s string) bool NewContentEditor() string |