These have, once we release this, been logging ERROR for 6 minor versions.
"github.com/gohugoio/hugo/common/hstrings"
"github.com/gohugoio/hugo/common/htime"
- "github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/common/types"
logLevel string
- verbose bool
- debug bool
quiet bool
devMode bool // Hidden flag.
default:
return nil, fmt.Errorf("invalid log level: %q, must be one of debug, warn, info or error", r.logLevel)
}
- } else {
- if r.verbose {
- hugo.Deprecate("--verbose", "use --logLevel info", "v0.114.0")
- hugo.Deprecate("--verbose", "use --logLevel info", "v0.114.0")
- level = logg.LevelInfo
- }
-
- if r.debug {
- hugo.Deprecate("--debug", "use --logLevel debug", "v0.114.0")
- level = logg.LevelDebug
- }
}
}
cmd.PersistentFlags().BoolVar(&r.quiet, "quiet", false, "build in quiet mode")
cmd.PersistentFlags().BoolVarP(&r.renderToMemory, "renderToMemory", "M", false, "render to memory (mostly useful when running the server)")
- cmd.PersistentFlags().BoolVarP(&r.verbose, "verbose", "v", false, "verbose output")
- cmd.PersistentFlags().BoolVarP(&r.debug, "debug", "", false, "debug output")
cmd.PersistentFlags().BoolVarP(&r.devMode, "devMode", "", false, "only used for internal testing, flag hidden.")
cmd.PersistentFlags().StringVar(&r.logLevel, "logLevel", "", "log level (debug|info|warn|error)")
_ = cmd.RegisterFlagCompletionFunc("logLevel", cobra.FixedCompletions([]string{"debug", "info", "warn", "error"}, cobra.ShellCompDirectiveNoFileComp))
c.Assert(deprecationLogLevelFromVersion(ver.String()), qt.Equals, logg.LevelWarn)
ver.Minor -= 6
c.Assert(deprecationLogLevelFromVersion(ver.String()), qt.Equals, logg.LevelError)
+
+ // Added just to find the threshold for where we can remove deprecated items.
+ // Subtract 5 from the minor version of the first ERRORed version => 0.122.0.
+ c.Assert(deprecationLogLevelFromVersion("0.127.0"), qt.Equals, logg.LevelError)
}
func TestMarkupScope(t *testing.T) {
var differentRootKeys []string
switch x := v.(type) {
case maps.Params:
- var params maps.Params
- pv, found := x["params"]
- if found {
- params = pv.(maps.Params)
- } else {
- params = maps.Params{
+ _, found := x["params"]
+ if !found {
+ x["params"] = maps.Params{
maps.MergeStrategyKey: maps.ParamsMergeStrategyDeep,
}
- x["params"] = params
}
for kk, vv := range x {
if kk == "_merge" {
continue
}
- if kk != maps.MergeStrategyKey && !configLanguageKeys[kk] {
- // This should have been placed below params.
- // We accidentally allowed it in the past, so we need to support it a little longer,
- // But log a warning.
- if _, found := params[kk]; !found {
- hugo.Deprecate(fmt.Sprintf("config: languages.%s.%s: custom params on the language top level", k, kk), fmt.Sprintf("Put the value below [languages.%s.params]. See https://gohugo.io/content-management/multilingual/#changes-in-hugo-01120", k), "v0.112.0")
- params[kk] = vv
- }
- }
if kk == "baseurl" {
// baseURL configure don the language level is a multihost setup.
isMultihost = true
// All of these represents the common parts of a page.Page
navigation.PageMenusProvider
- page.AuthorProvider
page.AlternativeOutputFormatsProvider
page.ChildCareProvider
page.FileProvider
"github.com/gohugoio/hugo/common/constants"
"github.com/gohugoio/hugo/common/hashing"
- "github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/paths"
return p.pageConfig.Aliases
}
-// Deprecated: Use taxonomies instead.
-func (p *pageMeta) Author() page.Author {
- hugo.Deprecate(".Page.Author", "Use taxonomies instead.", "v0.98.0")
- authors := p.Authors()
-
- for _, author := range authors {
- return author
- }
- return page.Author{}
-}
-
-// Deprecated: Use taxonomies instead.
-func (p *pageMeta) Authors() page.AuthorList {
- hugo.Deprecate(".Page.Authors", "Use taxonomies instead.", "v0.112.0")
- return nil
-}
-
func (p *pageMeta) BundleType() string {
switch p.pathInfo.BundleType() {
case paths.PathTypeLeaf:
dependencyManager: m.s.Conf.NewIdentityManager(m.Path()),
pageCommon: &pageCommon{
FileProvider: m,
- AuthorProvider: m,
store: maps.NewScratch(),
Positioner: page.NopPage,
InSectionPositioner: page.NopPage,
"context"
"errors"
"fmt"
- "html/template"
"io"
"mime"
"net/url"
return h, nil
}
-// Deprecated: Use hugo.IsServer instead.
-func (s *Site) IsServer() bool {
- hugo.Deprecate(".Site.IsServer", "Use hugo.IsServer instead.", "v0.120.0")
- return s.conf.Internal.Running
-}
-
// Returns the server port.
func (s *Site) ServerPort() int {
return s.conf.C.BaseURL.Port()
return s.conf.Copyright
}
-// Deprecated: Use .Site.Home.OutputFormats.Get "rss" instead.
-func (s *Site) RSSLink() template.URL {
- hugo.Deprecate(".Site.RSSLink", "Use the Output Format's Permalink method instead, e.g. .OutputFormats.Get \"RSS\".Permalink", "v0.114.0")
- rssOutputFormat := s.home.OutputFormats().Get("rss")
- return template.URL(rssOutputFormat.Permalink())
-}
-
func (s *Site) Config() page.SiteConfig {
return page.SiteConfig{
Privacy: s.conf.Privacy,
return s.conf.Social
}
-// Deprecated: Use .Site.Config.Services.Disqus.Shortname instead.
-func (s *Site) DisqusShortname() string {
- hugo.Deprecate(".Site.DisqusShortname", "Use .Site.Config.Services.Disqus.Shortname instead.", "v0.120.0")
- return s.Config().Services.Disqus.Shortname
-}
-
-// Deprecated: Use .Site.Config.Services.GoogleAnalytics.ID instead.
-func (s *Site) GoogleAnalytics() string {
- hugo.Deprecate(".Site.GoogleAnalytics", "Use .Site.Config.Services.GoogleAnalytics.ID instead.", "v0.120.0")
- return s.Config().Services.GoogleAnalytics.ID
-}
-
func (s *Site) Param(key any) (any, error) {
return resource.Param(s, nil, key)
}
AlternativeOutputFormats() OutputFormats
}
-// AuthorProvider provides author information.
-type AuthorProvider interface {
- // Deprecated: Use taxonomies instead.
- Author() Author
- // Deprecated: Use taxonomies instead.
- Authors() AuthorList
-}
-
// ChildCareProvider provides accessors to child resources.
type ChildCareProvider interface {
// Pages returns a list of pages of all kinds.
Positioner
navigation.PageMenusProvider
- // TODO(bep)
- AuthorProvider
-
// Page lookups/refs
GetPageProvider
RefProvider
return ""
}
-func (p *nopPage) RSSLink() template.URL {
- return ""
-}
-
-// Deprecated: Use taxonomies instead.
-func (p *nopPage) Author() Author {
- return Author{}
-}
-
-// Deprecated: Use taxonomies instead.
-func (p *nopPage) Authors() AuthorList {
- return nil
-}
-
func (p *nopPage) AllTranslations() Pages {
return nil
}
return
}
-func (p *nopPage) Ext() string {
- return ""
-}
-
-func (p *nopPage) Extension() string {
- return ""
-}
-
func (p *nopPage) File() *source.File {
return nil
}
package page
import (
- "html/template"
"time"
"github.com/gohugoio/hugo/common/maps"
// A shortcut to the home
Home() Page
- // Deprecated: Use hugo.IsServer instead.
- IsServer() bool
-
// Returns the server port.
ServerPort() int
// Deprecated: Use .Site.Params instead.
Social() map[string]string
- // Deprecated: Use Config().Services.GoogleAnalytics instead.
- GoogleAnalytics() string
-
- // Deprecated: Use Config().Privacy.Disqus instead.
- DisqusShortname() string
-
// BuildDrafts is deprecated and will be removed in a future release.
BuildDrafts() bool
// LanguagePrefix returns the language prefix for this site.
LanguagePrefix() string
- // Deprecated: Use .Site.Home.OutputFormats.Get "rss" instead.
- RSSLink() template.URL
-
maps.StoreProvider
// For internal use only.
return s.s.Authors()
}
-// Deprecated: Use .Site.Config.Services.GoogleAnalytics.ID instead.
-func (s *siteWrapper) GoogleAnalytics() string {
- return s.s.GoogleAnalytics()
-}
-
func (s *siteWrapper) GetPage(ref ...string) (Page, error) {
return s.s.GetPage(ref...)
}
return s.s.Home()
}
-// Deprecated: Use hugo.IsServer instead.
-func (s *siteWrapper) IsServer() bool {
- return s.s.IsServer()
-}
-
func (s *siteWrapper) ServerPort() int {
return s.s.ServerPort()
}
return s.s.IsMultiLingual()
}
-// Deprecated: Use .Site.Config.Services.Disqus.Shortname instead.
-func (s *siteWrapper) DisqusShortname() string {
- return s.s.DisqusShortname()
-}
-
func (s *siteWrapper) LanguagePrefix() string {
return s.s.LanguagePrefix()
}
-// Deprecated: Use .Site.Home.OutputFormats.Get "rss" instead.
-func (s *siteWrapper) RSSLink() template.URL {
- return s.s.RSSLink()
-}
-
func (s *siteWrapper) Store() *maps.Scratch {
return s.s.Store()
}
return nil
}
-// Deprecated: Use .Site.Config.Services.GoogleAnalytics.ID instead.
-func (t testSite) GoogleAnalytics() string {
- return ""
-}
-
func (t testSite) MainSections() []string {
return nil
}
-// Deprecated: Use hugo.IsServer instead.
-func (t testSite) IsServer() bool {
- return false
-}
-
func (t testSite) Language() *langs.Language {
return t.l
}
return SiteConfig{}
}
-// Deprecated: Use .Site.Config.Services.Disqus.Shortname instead.
-func (testSite) DisqusShortname() string {
- return ""
-}
-
func (s testSite) BuildDrafts() bool {
return false
}
return nil, nil
}
-// Deprecated: Use .Site.Home.OutputFormats.Get "rss" instead.
-func (s testSite) RSSLink() template.URL {
- return ""
-}
-
func (s testSite) Store() *maps.Scratch {
return maps.NewScratch()
}
panic("testpage: not implemented")
}
-// Deprecated: Use taxonomies instead.
-func (p *testPage) Author() Author {
- return Author{}
-}
-
-// Deprecated: Use taxonomies instead.
-func (p *testPage) Authors() AuthorList {
- return nil
-}
-
func (p *testPage) BaseFileName() string {
panic("testpage: not implemented")
}
return p.expiryDate
}
-func (p *testPage) Ext() string {
- panic("testpage: not implemented")
-}
-
-func (p *testPage) Extension() string {
- panic("testpage: not implemented")
-}
-
func (p *testPage) File() *source.File {
return p.file
}
return p.pubDate
}
-func (p *testPage) RSSLink() template.URL {
- return ""
-}
-
func (p *testPage) RawContent() string {
panic("testpage: not implemented")
}
return fi.pathToDir(fi.p().Dir())
}
-// Extension is an alias to Ext().
-// Deprecated: Use Ext() instead.
-func (fi *File) Extension() string {
- hugo.Deprecate(".File.Extension", "Use .File.Ext instead.", "v0.96.0")
- return fi.Ext()
-}
-
// Ext returns a file's extension without the leading period (e.g. "md").
func (fi *File) Ext() string { return fi.p().Ext() }
"time"
"github.com/gohugoio/hugo/common/collections"
- "github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/deps"
return root, nil
}
-// EchoParam returns the value in the collection c with key k if is set; otherwise, it returns an
-// empty string.
-// Deprecated: Use the index function instead.
-func (ns *Namespace) EchoParam(c, k any) any {
- hugo.Deprecate("collections.EchoParam", "Use the index function instead.", "v0.120.0")
- av, isNil := indirect(reflect.ValueOf(c))
- if isNil {
- return ""
- }
-
- var avv reflect.Value
- switch av.Kind() {
- case reflect.Array, reflect.Slice:
- index, ok := k.(int)
- if ok && av.Len() > index {
- avv = av.Index(index)
- }
- case reflect.Map:
- kv := reflect.ValueOf(k)
- if kv.Type().AssignableTo(av.Type().Key()) {
- avv = av.MapIndex(kv)
- }
- }
-
- avv, isNil = indirect(avv)
-
- if isNil {
- return ""
- }
-
- if avv.IsValid() {
- switch avv.Kind() {
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return avv.Int()
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
- return avv.Uint()
- case reflect.Float32, reflect.Float64:
- return avv.Float()
- case reflect.String:
- return avv.String()
- case reflect.Bool:
- return avv.Bool()
- }
- }
-
- return ""
-}
-
// First returns the first limit items in list l.
func (ns *Namespace) First(limit any, l any) (any, error) {
if limit == nil || l == nil {
c.Assert(err, qt.Not(qt.IsNil))
}
-func TestEchoParam(t *testing.T) {
- t.Skip("deprecated, will be removed in Hugo 0.133.0")
- t.Parallel()
- c := qt.New(t)
-
- ns := newNs()
-
- for i, test := range []struct {
- a any
- key any
- expect any
- }{
- {[]int{1, 2, 3}, 1, int64(2)},
- {[]uint{1, 2, 3}, 1, uint64(2)},
- {[]float64{1.1, 2.2, 3.3}, 1, float64(2.2)},
- {[]string{"foo", "bar", "baz"}, 1, "bar"},
- {[]TstX{{A: "a", B: "b"}, {A: "c", B: "d"}, {A: "e", B: "f"}}, 1, ""},
- {map[string]int{"foo": 1, "bar": 2, "baz": 3}, "bar", int64(2)},
- {map[string]uint{"foo": 1, "bar": 2, "baz": 3}, "bar", uint64(2)},
- {map[string]float64{"foo": 1.1, "bar": 2.2, "baz": 3.3}, "bar", float64(2.2)},
- {map[string]string{"foo": "FOO", "bar": "BAR", "baz": "BAZ"}, "bar", "BAR"},
- {map[string]TstX{"foo": {A: "a", B: "b"}, "bar": {A: "c", B: "d"}, "baz": {A: "e", B: "f"}}, "bar", ""},
- {map[string]any{"foo": nil}, "foo", ""},
- {(*[]string)(nil), "bar", ""},
- } {
- errMsg := qt.Commentf("[%d] %v", i, test)
-
- result := ns.EchoParam(test.a, test.key)
-
- c.Assert(result, qt.Equals, test.expect, errMsg)
- }
-}
-
func TestFirst(t *testing.T) {
t.Parallel()
c := qt.New(t)
[][2]string{},
)
- ns.AddMethodMapping(ctx.EchoParam,
- []string{"echoParam"},
- [][2]string{},
- )
-
ns.AddMethodMapping(ctx.First,
[]string{"first"},
[][2]string{},
translators "github.com/gohugoio/localescompressed"
"github.com/gohugoio/hugo/common/hreflect"
- "github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/deps"
"github.com/spf13/cast"
)
return string(b), nil
}
-// Deprecated: Use lang.FormatNumberCustom instead.
-func (ns *Namespace) NumFmt(precision, number any, options ...any) (string, error) {
- hugo.Deprecate("lang.NumFmt", "Use lang.FormatNumberCustom instead.", "v0.120.0")
- return ns.FormatNumberCustom(precision, number, options...)
-}
-
type pagesLanguageMerger interface {
MergeByLanguageInterface(other any) (any, error)
}