Remove deprecations <= v0.122.0 (note)

These have, once we release this, been logging ERROR for 6 minor versions.
This commit is contained in:
Bjørn Erik Pedersen 2024-11-16 17:58:06 +01:00
parent f7fc6ccd59
commit ad43d137d5
16 changed files with 7 additions and 287 deletions

View file

@ -39,7 +39,6 @@ import (
"github.com/gohugoio/hugo/common/hstrings" "github.com/gohugoio/hugo/common/hstrings"
"github.com/gohugoio/hugo/common/htime" "github.com/gohugoio/hugo/common/htime"
"github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/common/paths" "github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/common/types" "github.com/gohugoio/hugo/common/types"
@ -141,8 +140,6 @@ type rootCommand struct {
logLevel string logLevel string
verbose bool
debug bool
quiet bool quiet bool
devMode bool // Hidden flag. devMode bool // Hidden flag.
@ -482,17 +479,6 @@ func (r *rootCommand) createLogger(running bool) (loggers.Logger, error) {
default: default:
return nil, fmt.Errorf("invalid log level: %q, must be one of debug, warn, info or error", r.logLevel) 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().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.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().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.PersistentFlags().StringVar(&r.logLevel, "logLevel", "", "log level (debug|info|warn|error)")
_ = cmd.RegisterFlagCompletionFunc("logLevel", cobra.FixedCompletions([]string{"debug", "info", "warn", "error"}, cobra.ShellCompDirectiveNoFileComp)) _ = cmd.RegisterFlagCompletionFunc("logLevel", cobra.FixedCompletions([]string{"debug", "info", "warn", "error"}, cobra.ShellCompDirectiveNoFileComp))

View file

@ -63,6 +63,10 @@ func TestDeprecationLogLevelFromVersion(t *testing.T) {
c.Assert(deprecationLogLevelFromVersion(ver.String()), qt.Equals, logg.LevelWarn) c.Assert(deprecationLogLevelFromVersion(ver.String()), qt.Equals, logg.LevelWarn)
ver.Minor -= 6 ver.Minor -= 6
c.Assert(deprecationLogLevelFromVersion(ver.String()), qt.Equals, logg.LevelError) 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) { func TestMarkupScope(t *testing.T) {

View file

@ -888,30 +888,17 @@ func fromLoadConfigResult(fs afero.Fs, logger loggers.Logger, res config.LoadCon
var differentRootKeys []string var differentRootKeys []string
switch x := v.(type) { switch x := v.(type) {
case maps.Params: case maps.Params:
var params maps.Params _, found := x["params"]
pv, found := x["params"] if !found {
if found { x["params"] = maps.Params{
params = pv.(maps.Params)
} else {
params = maps.Params{
maps.MergeStrategyKey: maps.ParamsMergeStrategyDeep, maps.MergeStrategyKey: maps.ParamsMergeStrategyDeep,
} }
x["params"] = params
} }
for kk, vv := range x { for kk, vv := range x {
if kk == "_merge" { if kk == "_merge" {
continue 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" { if kk == "baseurl" {
// baseURL configure don the language level is a multihost setup. // baseURL configure don the language level is a multihost setup.
isMultihost = true isMultihost = true

View file

@ -57,7 +57,6 @@ type pageCommon struct {
// All of these represents the common parts of a page.Page // All of these represents the common parts of a page.Page
navigation.PageMenusProvider navigation.PageMenusProvider
page.AuthorProvider
page.AlternativeOutputFormatsProvider page.AlternativeOutputFormatsProvider
page.ChildCareProvider page.ChildCareProvider
page.FileProvider page.FileProvider

View file

@ -32,7 +32,6 @@ import (
"github.com/gohugoio/hugo/common/constants" "github.com/gohugoio/hugo/common/constants"
"github.com/gohugoio/hugo/common/hashing" "github.com/gohugoio/hugo/common/hashing"
"github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/common/maps" "github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/paths" "github.com/gohugoio/hugo/common/paths"
@ -108,23 +107,6 @@ func (p *pageMeta) Aliases() []string {
return p.pageConfig.Aliases 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 { func (p *pageMeta) BundleType() string {
switch p.pathInfo.BundleType() { switch p.pathInfo.BundleType() {
case paths.PathTypeLeaf: case paths.PathTypeLeaf:

View file

@ -183,7 +183,6 @@ func (h *HugoSites) doNewPage(m *pageMeta) (*pageState, *paths.Path, error) {
dependencyManager: m.s.Conf.NewIdentityManager(m.Path()), dependencyManager: m.s.Conf.NewIdentityManager(m.Path()),
pageCommon: &pageCommon{ pageCommon: &pageCommon{
FileProvider: m, FileProvider: m,
AuthorProvider: m,
store: maps.NewScratch(), store: maps.NewScratch(),
Positioner: page.NopPage, Positioner: page.NopPage,
InSectionPositioner: page.NopPage, InSectionPositioner: page.NopPage,

View file

@ -17,7 +17,6 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"html/template"
"io" "io"
"mime" "mime"
"net/url" "net/url"
@ -412,12 +411,6 @@ func newHugoSites(cfg deps.DepsCfg, d *deps.Deps, pageTrees *pageTrees, sites []
return h, nil 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. // Returns the server port.
func (s *Site) ServerPort() int { func (s *Site) ServerPort() int {
return s.conf.C.BaseURL.Port() return s.conf.C.BaseURL.Port()
@ -432,13 +425,6 @@ func (s *Site) Copyright() string {
return s.conf.Copyright 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 { func (s *Site) Config() page.SiteConfig {
return page.SiteConfig{ return page.SiteConfig{
Privacy: s.conf.Privacy, Privacy: s.conf.Privacy,
@ -520,18 +506,6 @@ func (s *Site) Social() map[string]string {
return s.conf.Social 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) { func (s *Site) Param(key any) (any, error) {
return resource.Param(s, nil, key) return resource.Param(s, nil, key)
} }

View file

@ -51,14 +51,6 @@ type AlternativeOutputFormatsProvider interface {
AlternativeOutputFormats() OutputFormats 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. // ChildCareProvider provides accessors to child resources.
type ChildCareProvider interface { type ChildCareProvider interface {
// Pages returns a list of pages of all kinds. // Pages returns a list of pages of all kinds.
@ -309,9 +301,6 @@ type PageWithoutContent interface {
Positioner Positioner
navigation.PageMenusProvider navigation.PageMenusProvider
// TODO(bep)
AuthorProvider
// Page lookups/refs // Page lookups/refs
GetPageProvider GetPageProvider
RefProvider RefProvider

View file

@ -77,20 +77,6 @@ func (p *nopPage) Layout() string {
return "" 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 { func (p *nopPage) AllTranslations() Pages {
return nil return nil
} }
@ -167,14 +153,6 @@ func (p *nopPage) ExpiryDate() (t time.Time) {
return return
} }
func (p *nopPage) Ext() string {
return ""
}
func (p *nopPage) Extension() string {
return ""
}
func (p *nopPage) File() *source.File { func (p *nopPage) File() *source.File {
return nil return nil
} }

View file

@ -14,7 +14,6 @@
package page package page
import ( import (
"html/template"
"time" "time"
"github.com/gohugoio/hugo/common/maps" "github.com/gohugoio/hugo/common/maps"
@ -54,9 +53,6 @@ type Site interface {
// A shortcut to the home // A shortcut to the home
Home() Page Home() Page
// Deprecated: Use hugo.IsServer instead.
IsServer() bool
// Returns the server port. // Returns the server port.
ServerPort() int ServerPort() int
@ -117,12 +113,6 @@ type Site interface {
// Deprecated: Use .Site.Params instead. // Deprecated: Use .Site.Params instead.
Social() map[string]string 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 is deprecated and will be removed in a future release.
BuildDrafts() bool BuildDrafts() bool
@ -132,9 +122,6 @@ type Site interface {
// LanguagePrefix returns the language prefix for this site. // LanguagePrefix returns the language prefix for this site.
LanguagePrefix() string LanguagePrefix() string
// Deprecated: Use .Site.Home.OutputFormats.Get "rss" instead.
RSSLink() template.URL
maps.StoreProvider maps.StoreProvider
// For internal use only. // For internal use only.
@ -195,11 +182,6 @@ func (s *siteWrapper) Authors() AuthorList {
return s.s.Authors() 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) { func (s *siteWrapper) GetPage(ref ...string) (Page, error) {
return s.s.GetPage(ref...) return s.s.GetPage(ref...)
} }
@ -232,11 +214,6 @@ func (s *siteWrapper) Home() Page {
return s.s.Home() return s.s.Home()
} }
// Deprecated: Use hugo.IsServer instead.
func (s *siteWrapper) IsServer() bool {
return s.s.IsServer()
}
func (s *siteWrapper) ServerPort() int { func (s *siteWrapper) ServerPort() int {
return s.s.ServerPort() return s.s.ServerPort()
} }
@ -315,20 +292,10 @@ func (s *siteWrapper) IsMultiLingual() bool {
return s.s.IsMultiLingual() 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 { func (s *siteWrapper) LanguagePrefix() string {
return s.s.LanguagePrefix() 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 { func (s *siteWrapper) Store() *maps.Scratch {
return s.s.Store() return s.s.Store()
} }
@ -416,20 +383,10 @@ func (t testSite) Languages() langs.Languages {
return nil return nil
} }
// Deprecated: Use .Site.Config.Services.GoogleAnalytics.ID instead.
func (t testSite) GoogleAnalytics() string {
return ""
}
func (t testSite) MainSections() []string { func (t testSite) MainSections() []string {
return nil return nil
} }
// Deprecated: Use hugo.IsServer instead.
func (t testSite) IsServer() bool {
return false
}
func (t testSite) Language() *langs.Language { func (t testSite) Language() *langs.Language {
return t.l return t.l
} }
@ -474,11 +431,6 @@ func (s testSite) Config() SiteConfig {
return SiteConfig{} return SiteConfig{}
} }
// Deprecated: Use .Site.Config.Services.Disqus.Shortname instead.
func (testSite) DisqusShortname() string {
return ""
}
func (s testSite) BuildDrafts() bool { func (s testSite) BuildDrafts() bool {
return false return false
} }
@ -492,11 +444,6 @@ func (s testSite) Param(key any) (any, error) {
return nil, nil return nil, nil
} }
// Deprecated: Use .Site.Home.OutputFormats.Get "rss" instead.
func (s testSite) RSSLink() template.URL {
return ""
}
func (s testSite) Store() *maps.Scratch { func (s testSite) Store() *maps.Scratch {
return maps.NewScratch() return maps.NewScratch()
} }

View file

@ -127,16 +127,6 @@ func (p *testPage) AlternativeOutputFormats() OutputFormats {
panic("testpage: not implemented") 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 { func (p *testPage) BaseFileName() string {
panic("testpage: not implemented") panic("testpage: not implemented")
} }
@ -201,14 +191,6 @@ func (p *testPage) ExpiryDate() time.Time {
return p.expiryDate 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 { func (p *testPage) File() *source.File {
return p.file return p.file
} }
@ -459,10 +441,6 @@ func (p *testPage) PublishDate() time.Time {
return p.pubDate return p.pubDate
} }
func (p *testPage) RSSLink() template.URL {
return ""
}
func (p *testPage) RawContent() string { func (p *testPage) RawContent() string {
panic("testpage: not implemented") panic("testpage: not implemented")
} }

View file

@ -56,13 +56,6 @@ func (fi *File) Dir() string {
return fi.pathToDir(fi.p().Dir()) 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"). // Ext returns a file's extension without the leading period (e.g. "md").
func (fi *File) Ext() string { return fi.p().Ext() } func (fi *File) Ext() string { return fi.p().Ext() }

View file

@ -26,7 +26,6 @@ import (
"time" "time"
"github.com/gohugoio/hugo/common/collections" "github.com/gohugoio/hugo/common/collections"
"github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/common/maps" "github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/types" "github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/deps"
@ -189,54 +188,6 @@ func (ns *Namespace) Dictionary(values ...any) (map[string]any, error) {
return root, nil 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. // First returns the first limit items in list l.
func (ns *Namespace) First(limit any, l any) (any, error) { func (ns *Namespace) First(limit any, l any) (any, error) {
if limit == nil || l == nil { if limit == nil || l == nil {

View file

@ -232,39 +232,6 @@ func TestReverse(t *testing.T) {
c.Assert(err, qt.Not(qt.IsNil)) 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) { func TestFirst(t *testing.T) {
t.Parallel() t.Parallel()
c := qt.New(t) c := qt.New(t)

View file

@ -67,11 +67,6 @@ func init() {
[][2]string{}, [][2]string{},
) )
ns.AddMethodMapping(ctx.EchoParam,
[]string{"echoParam"},
[][2]string{},
)
ns.AddMethodMapping(ctx.First, ns.AddMethodMapping(ctx.First,
[]string{"first"}, []string{"first"},
[][2]string{}, [][2]string{},

View file

@ -26,7 +26,6 @@ import (
translators "github.com/gohugoio/localescompressed" translators "github.com/gohugoio/localescompressed"
"github.com/gohugoio/hugo/common/hreflect" "github.com/gohugoio/hugo/common/hreflect"
"github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/deps"
"github.com/spf13/cast" "github.com/spf13/cast"
) )
@ -240,12 +239,6 @@ func (ns *Namespace) FormatNumberCustom(precision, number any, options ...any) (
return string(b), nil 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 { type pagesLanguageMerger interface {
MergeByLanguageInterface(other any) (any, error) MergeByLanguageInterface(other any) (any, error)
} }