mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-27 22:09:53 +02:00
Improve some godoc comments
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
f6f22ad944
commit
30bc4ed0a0
@@ -36,7 +36,7 @@ func (f *realFilenameInfo) RealFilename() string {
|
||||
return f.realFilename
|
||||
}
|
||||
|
||||
// NewBasePathRealFilenameFs returns a new NewBasePathRealFilenameFs instance
|
||||
// NewBasePathRealFilenameFs returns a new BasePathRealFilenameFs instance
|
||||
// using base.
|
||||
func NewBasePathRealFilenameFs(base *afero.BasePathFs) *BasePathRealFilenameFs {
|
||||
return &BasePathRealFilenameFs{BasePathFs: base}
|
||||
|
@@ -51,7 +51,8 @@ type FilePather interface {
|
||||
BaseDir() string
|
||||
}
|
||||
|
||||
// LanguageDirsMerger implements the afero.DirsMerger interface.
|
||||
// LanguageDirsMerger implements the afero.DirsMerger interface, which is used
|
||||
// to merge two directories.
|
||||
var LanguageDirsMerger = func(lofi, bofi []os.FileInfo) ([]os.FileInfo, error) {
|
||||
m := make(map[string]*LanguageFileInfo)
|
||||
|
||||
@@ -102,39 +103,41 @@ type LanguageFileInfo struct {
|
||||
weight int
|
||||
}
|
||||
|
||||
// Filename returns a file's real filename.
|
||||
// Filename returns a file's real filename including the base (ie.
|
||||
// "/my/base/sect/page.md").
|
||||
func (fi *LanguageFileInfo) Filename() string {
|
||||
return fi.realFilename
|
||||
}
|
||||
|
||||
// Path returns a file's relative filename.
|
||||
// Path returns a file's filename relative to the base (ie. "sect/page.md").
|
||||
func (fi *LanguageFileInfo) Path() string {
|
||||
return fi.relFilename
|
||||
}
|
||||
|
||||
// RealName returns a file's real name.
|
||||
// RealName returns a file's real base name (ie. "page.md").
|
||||
func (fi *LanguageFileInfo) RealName() string {
|
||||
return fi.realName
|
||||
}
|
||||
|
||||
// BaseDir returns a file's base directory.
|
||||
// BaseDir returns a file's base directory (ie. "/my/base").
|
||||
func (fi *LanguageFileInfo) BaseDir() string {
|
||||
return fi.baseDir
|
||||
}
|
||||
|
||||
// Lang returns a file's language.
|
||||
// Lang returns a file's language (ie. "sv").
|
||||
func (fi *LanguageFileInfo) Lang() string {
|
||||
return fi.lang
|
||||
}
|
||||
|
||||
// TranslationBaseName returns the base filename without any extension or language
|
||||
// identificator.
|
||||
// identifiers (ie. "page").
|
||||
func (fi *LanguageFileInfo) TranslationBaseName() string {
|
||||
return fi.translationBaseName
|
||||
}
|
||||
|
||||
// Name is the name of the file within this filesystem without any path info.
|
||||
// It will be marked with language information so we can identify it as ours.
|
||||
// It will be marked with language information so we can identify it as ours
|
||||
// (ie. "__hugofs_sv_page.md").
|
||||
func (fi *LanguageFileInfo) Name() string {
|
||||
return fi.name
|
||||
}
|
||||
@@ -175,7 +178,7 @@ type LanguageFs struct {
|
||||
afero.Fs
|
||||
}
|
||||
|
||||
// NewLanguageFs creates a new LanguageFs.
|
||||
// NewLanguageFs creates a new language filesystem.
|
||||
func NewLanguageFs(lang string, languages map[string]bool, fs afero.Fs) *LanguageFs {
|
||||
if lang == "" {
|
||||
panic("no lang set for the language fs")
|
||||
@@ -191,7 +194,7 @@ func NewLanguageFs(lang string, languages map[string]bool, fs afero.Fs) *Languag
|
||||
return &LanguageFs{lang: lang, languages: languages, basePath: basePath, Fs: fs, nameMarker: marker}
|
||||
}
|
||||
|
||||
// Lang returns a language filesystem's language.
|
||||
// Lang returns a language filesystem's language (ie. "sv").
|
||||
func (fs *LanguageFs) Lang() string {
|
||||
return fs.lang
|
||||
}
|
||||
|
@@ -50,6 +50,9 @@ func TestLanguagFs(t *testing.T) {
|
||||
assert.Equal("page.sv.md", lfi.virtualName)
|
||||
assert.Equal("__hugofs_sv_page.md", lfi.Name())
|
||||
assert.Equal("page.md", lfi.RealName())
|
||||
assert.Equal("/my/base", lfi.BaseDir())
|
||||
assert.Equal("sv", lfi.Lang())
|
||||
assert.Equal("page", lfi.TranslationBaseName())
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user