Repository: gohugoio/hugo (language: go)

Issue:
Deprecate undocumented .File.Extension 
`.File.Ext` is documented.
`.File.Extension` is not documented.

See <https://github.com/gohugoio/hugo/blob/master/source/fileInfo.go#L73-L77>:

```
// Extension gets the file extension, i.e "myblogpost.md" will return "md".
Extension() string

// Ext is an alias for Extension.
Ext() string // Hmm... Deprecate Extension
```

Documentation: <https://gohugo.io/variables/files/>


Discussion / hints:
I'd like to take a crack at this one. I assume you want to use helpers.Deprecate to deprecate the function so that it will show a warning when used. Probably also refactor any usage of Extension() in the actual codebase as well? 
@sara-meie that is a sensible approach, yes.

Fix patch:
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go
index 182d6bad18b..9b27ae5e376 100644
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -978,7 +978,7 @@ func (h *HugoSites) readData(f source.File) (any, error) {
 	defer file.Close()
 	content := helpers.ReaderToBytes(file)
 
-	format := metadecoders.FormatFromString(f.Extension())
+	format := metadecoders.FormatFromString(f.Ext())
 	return metadecoders.Default.Unmarshal(content, format)
 }
 
diff --git a/source/fileInfo.go b/source/fileInfo.go
index 606b8b02572..13c4495bf26 100644
--- a/source/fileInfo.go
+++ b/source/fileInfo.go
@@ -70,11 +70,12 @@ type FileWithoutOverlap interface {
 	// The directory is relative to the content root.
 	Dir() string
 
-	// Extension gets the file extension, i.e "myblogpost.md" will return "md".
+	// Extension is an alias to Ext().
+	// Deprecated: Use Ext instead.
 	Extension() string
 
-	// Ext is an alias for Extension.
-	Ext() string // Hmm... Deprecate Extension
+	// Ext gets the file extension, i.e "myblogpost.md" will return "md".
+	Ext() string
 
 	// LogicalName is filename and extension of the file.
 	LogicalName() string
@@ -139,7 +140,10 @@ func (fi *FileInfo) Path() string { return fi.relPath }
 func (fi *FileInfo) Dir() string { return fi.relDir }
 
 // Extension is an alias to Ext().
-func (fi *FileInfo) Extension() string { return fi.Ext() }
+func (fi *FileInfo) Extension() string {
+	helpers.Deprecated(".File.Extension", "Use .File.Ext instead. ", false)
+	return fi.Ext()
+}
 
 // Ext returns a file's extension without the leading period (ie. "md").
 func (fi *FileInfo) Ext() string { return fi.ext }


Test patch: