Skip to content

Commit

Permalink
Remove deprecations <= v0.122.0 (note)
Browse files Browse the repository at this point in the history
These have, once we release this, been logging ERROR for 6 minor versions.
  • Loading branch information
bep committed Nov 16, 2024
1 parent f7fc6cc commit ad43d13
Show file tree
Hide file tree
Showing 16 changed files with 7 additions and 287 deletions.
16 changes: 0 additions & 16 deletions commands/commandeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -141,8 +140,6 @@ type rootCommand struct {

logLevel string

verbose bool
debug bool
quiet bool
devMode bool // Hidden flag.

Expand Down Expand Up @@ -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
}
}
}

Expand Down Expand Up @@ -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))
Expand Down
4 changes: 4 additions & 0 deletions common/hugo/hugo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 3 additions & 16 deletions config/allconfig/allconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion hugolib/page__common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 0 additions & 18 deletions hugolib/page__meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion hugolib/page__new.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 0 additions & 26 deletions hugolib/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"context"
"errors"
"fmt"
"html/template"
"io"
"mime"
"net/url"
Expand Down Expand Up @@ -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()
Expand All @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down
11 changes: 0 additions & 11 deletions resources/page/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -309,9 +301,6 @@ type PageWithoutContent interface {
Positioner
navigation.PageMenusProvider

// TODO(bep)
AuthorProvider

// Page lookups/refs
GetPageProvider
RefProvider
Expand Down
22 changes: 0 additions & 22 deletions resources/page/page_nop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
53 changes: 0 additions & 53 deletions resources/page/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package page

import (
"html/template"
"time"

"github.com/gohugoio/hugo/common/maps"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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.
Expand Down Expand Up @@ -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...)
}
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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()
}
Expand Down
Loading

0 comments on commit ad43d13

Please sign in to comment.