]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Remove deprecations <= v0.122.0 (note)
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 16 Nov 2024 16:58:06 +0000 (17:58 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 16 Nov 2024 19:32:43 +0000 (20:32 +0100)
These have, once we release this, been logging ERROR for 6 minor versions.

16 files changed:
commands/commandeer.go
common/hugo/hugo_test.go
config/allconfig/allconfig.go
hugolib/page__common.go
hugolib/page__meta.go
hugolib/page__new.go
hugolib/site.go
resources/page/page.go
resources/page/page_nop.go
resources/page/site.go
resources/page/testhelpers_test.go
source/fileInfo.go
tpl/collections/collections.go
tpl/collections/collections_test.go
tpl/collections/init.go
tpl/lang/lang.go

index 69077ad73cdbb7de03906ce21a141ebe396cb96b..bb82ec654323a95db5fdf18065083f6403c3dfda 100644 (file)
@@ -39,7 +39,6 @@ import (
 
        "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"
@@ -141,8 +140,6 @@ type rootCommand struct {
 
        logLevel string
 
-       verbose bool
-       debug   bool
        quiet   bool
        devMode bool // Hidden flag.
 
@@ -482,17 +479,6 @@ func (r *rootCommand) createLogger(running bool) (loggers.Logger, error) {
                        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
-                       }
                }
        }
 
@@ -560,8 +546,6 @@ Complete documentation is available at https://gohugo.io/.`
        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))
index 241d8c0ae80c0437984acc35839072ee28b4f15e..feb52075df17ec6f4cacd2635f68ef287316e4fa 100644 (file)
@@ -63,6 +63,10 @@ func TestDeprecationLogLevelFromVersion(t *testing.T) {
        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) {
index 35517ece2db898d50f4c508552efb7b6f690a644..b158d8a90bd86d71864952a6f7fc67ad215b5c37 100644 (file)
@@ -888,30 +888,17 @@ func fromLoadConfigResult(fs afero.Fs, logger loggers.Logger, res config.LoadCon
                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
index 55465e214ecb9882d092dd80a2cd2943fb8e0a11..a120849b3803df4b12bc11529189b72977c4eb41 100644 (file)
@@ -57,7 +57,6 @@ type pageCommon struct {
 
        // All of these represents the common parts of a page.Page
        navigation.PageMenusProvider
-       page.AuthorProvider
        page.AlternativeOutputFormatsProvider
        page.ChildCareProvider
        page.FileProvider
index 97a716b4370fa0d33ced32f4b8b416ef6190d6b2..07d9d1c0e4e07fffba17b4fba9f7768d3ce57743 100644 (file)
@@ -32,7 +32,6 @@ import (
 
        "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"
@@ -108,23 +107,6 @@ func (p *pageMeta) Aliases() []string {
        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:
index 9a11fa8892bdc7a4f89688161299c5734acbde00..91bfe5e32398fa223907d42c468340be0b9bf3f3 100644 (file)
@@ -183,7 +183,6 @@ func (h *HugoSites) doNewPage(m *pageMeta) (*pageState, *paths.Path, error) {
                        dependencyManager:                 m.s.Conf.NewIdentityManager(m.Path()),
                        pageCommon: &pageCommon{
                                FileProvider:              m,
-                               AuthorProvider:            m,
                                store:                     maps.NewScratch(),
                                Positioner:                page.NopPage,
                                InSectionPositioner:       page.NopPage,
index c434ff2b46d359d23be4f0b6395ecee43071dd6f..f6dc89a777b19ce50e3321f176989285b584f33f 100644 (file)
@@ -17,7 +17,6 @@ import (
        "context"
        "errors"
        "fmt"
-       "html/template"
        "io"
        "mime"
        "net/url"
@@ -412,12 +411,6 @@ func newHugoSites(cfg deps.DepsCfg, d *deps.Deps, pageTrees *pageTrees, sites []
        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()
@@ -432,13 +425,6 @@ func (s *Site) Copyright() string {
        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,
@@ -520,18 +506,6 @@ func (s *Site) Social() map[string]string {
        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)
 }
index acd4ce31354360c50099f8f2765163fdb2cccb3e..032ee320d06925a4e593c89218877ba65ac264b1 100644 (file)
@@ -51,14 +51,6 @@ type AlternativeOutputFormatsProvider interface {
        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.
@@ -309,9 +301,6 @@ type PageWithoutContent interface {
        Positioner
        navigation.PageMenusProvider
 
-       // TODO(bep)
-       AuthorProvider
-
        // Page lookups/refs
        GetPageProvider
        RefProvider
index 2b40dbb7329e4e635388ab3c1661ec9ff8ef03e0..5a03b19941cb49580555558c842a908e8c55e3e0 100644 (file)
@@ -77,20 +77,6 @@ func (p *nopPage) Layout() string {
        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
 }
@@ -167,14 +153,6 @@ func (p *nopPage) ExpiryDate() (t time.Time) {
        return
 }
 
-func (p *nopPage) Ext() string {
-       return ""
-}
-
-func (p *nopPage) Extension() string {
-       return ""
-}
-
 func (p *nopPage) File() *source.File {
        return nil
 }
index 4a99982fdb88375c67a797d2a3740687008f4319..47e1454c82e157ec801073f6ee8bba11b726c29f 100644 (file)
@@ -14,7 +14,6 @@
 package page
 
 import (
-       "html/template"
        "time"
 
        "github.com/gohugoio/hugo/common/maps"
@@ -54,9 +53,6 @@ type Site interface {
        // A shortcut to the home
        Home() Page
 
-       // Deprecated: Use hugo.IsServer instead.
-       IsServer() bool
-
        // Returns the server port.
        ServerPort() int
 
@@ -117,12 +113,6 @@ type Site interface {
        // 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
 
@@ -132,9 +122,6 @@ type Site interface {
        // 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.
@@ -195,11 +182,6 @@ func (s *siteWrapper) Authors() AuthorList {
        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...)
 }
@@ -232,11 +214,6 @@ func (s *siteWrapper) Home() Page {
        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()
 }
@@ -315,20 +292,10 @@ func (s *siteWrapper) IsMultiLingual() bool {
        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()
 }
@@ -416,20 +383,10 @@ func (t testSite) Languages() langs.Languages {
        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
 }
@@ -474,11 +431,6 @@ func (s testSite) Config() SiteConfig {
        return SiteConfig{}
 }
 
-// Deprecated: Use .Site.Config.Services.Disqus.Shortname instead.
-func (testSite) DisqusShortname() string {
-       return ""
-}
-
 func (s testSite) BuildDrafts() bool {
        return false
 }
@@ -492,11 +444,6 @@ func (s testSite) Param(key any) (any, error) {
        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()
 }
index 9eefeeea4104b67e88303aa5b89ee40bb0877b5a..8a2d28e31fe53eb3eaea40601b760016e442f29f 100644 (file)
@@ -127,16 +127,6 @@ func (p *testPage) AlternativeOutputFormats() OutputFormats {
        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")
 }
@@ -201,14 +191,6 @@ func (p *testPage) ExpiryDate() time.Time {
        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
 }
@@ -459,10 +441,6 @@ func (p *testPage) PublishDate() time.Time {
        return p.pubDate
 }
 
-func (p *testPage) RSSLink() template.URL {
-       return ""
-}
-
 func (p *testPage) RawContent() string {
        panic("testpage: not implemented")
 }
index bece86fa9f86c38d40a013dc98dbebc2b9dedbd3..8994dec976cdb61844e15f9961d43c78594c0f2f 100644 (file)
@@ -56,13 +56,6 @@ func (fi *File) Dir() string {
        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() }
 
index edec536ef407ebbc408a703dc36c3028cb1786c2..a7e36f6892836b09cf70cf49f1aaea81e7dea4d1 100644 (file)
@@ -26,7 +26,6 @@ import (
        "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"
@@ -189,54 +188,6 @@ func (ns *Namespace) Dictionary(values ...any) (map[string]any, error) {
        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 {
index c89051a3de6a3ebcf524257dca5dc6e09d1087f0..0f4bf82f5dc916323e9abd27d53c3bd0c023ea26 100644 (file)
@@ -232,39 +232,6 @@ func TestReverse(t *testing.T) {
        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)
index 20711f9e46c16876a42e0fdd02404e494c667188..f89651326bcc4445ea5a7dacf445c599b2d2acc0 100644 (file)
@@ -67,11 +67,6 @@ func init() {
                        [][2]string{},
                )
 
-               ns.AddMethodMapping(ctx.EchoParam,
-                       []string{"echoParam"},
-                       [][2]string{},
-               )
-
                ns.AddMethodMapping(ctx.First,
                        []string{"first"},
                        [][2]string{},
index b4ff98684202c31ee82eb40daef4560ddb568af0..4cbd661afe446ea68631a615e401cbd62f866c6f 100644 (file)
@@ -26,7 +26,6 @@ import (
        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"
 )
@@ -240,12 +239,6 @@ func (ns *Namespace) FormatNumberCustom(precision, number any, options ...any) (
        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)
 }