Documentation ¶
Overview ¶
Package source contains the types and functions related to source files.
Index ¶
- type File
- type FileInfo
- func (fi *FileInfo) BaseFileName() string
- func (fi *FileInfo) ContentBaseName() string
- func (fi *FileInfo) Dir() string
- func (fi *FileInfo) Ext() string
- func (fi *FileInfo) Extension() string
- func (fi *FileInfo) FileInfo() hugofs.FileMetaInfo
- func (fi *FileInfo) Filename() string
- func (fi *FileInfo) IsZero() bool
- func (fi *FileInfo) Lang() string
- func (fi *FileInfo) LogicalName() string
- func (fi *FileInfo) Open() (hugio.ReadSeekCloser, error)
- func (fi *FileInfo) Path() string
- func (fi *FileInfo) Section() string
- func (fi *FileInfo) String() string
- func (fi *FileInfo) TranslationBaseName() string
- func (fi *FileInfo) UniqueID() string
- type FileWithoutOverlap
- type Filesystem
- type GitInfo
- type SourceSpec
- func (s *SourceSpec) IgnoreFile(filename string) bool
- func (s *SourceSpec) IsRegularSourceFile(filename string) (bool, error)
- func (sp *SourceSpec) NewFileInfo(fi hugofs.FileMetaInfo) (*FileInfo, error)
- func (sp *SourceSpec) NewFileInfoFrom(path, filename string) (*FileInfo, error)
- func (sp SourceSpec) NewFilesystem(base string) *Filesystem
- func (sp SourceSpec) NewFilesystemFromFileMetaInfo(fi hugofs.FileMetaInfo) *Filesystem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File interface { FileWithoutOverlap // contains filtered or unexported methods }
File represents a source file. This is a temporary construct until we resolve page.Page conflicts. TODO(bep) remove this construct once we have resolved page deprecations
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo describes a source file.
func NewTestFile ¶
NewTestFile creates a partially filled File used in unit tests. TODO(bep) improve this package
func (*FileInfo) BaseFileName ¶
BaseFileName returns a file's name without extension (ie. "page.sv").
func (*FileInfo) ContentBaseName ¶
ContentBaseName is a either TranslationBaseName or name of containing folder if file is a leaf bundle.
func (*FileInfo) Dir ¶
Dir gets the name of the directory that contains this file. The directory is relative to the content root.
func (*FileInfo) FileInfo ¶
func (fi *FileInfo) FileInfo() hugofs.FileMetaInfo
FileInfo returns a file's underlying os.FileInfo. For internal use only.
func (*FileInfo) LogicalName ¶
LogicalName returns a file's name and extension (ie. "page.sv.md").
func (*FileInfo) Open ¶
func (fi *FileInfo) Open() (hugio.ReadSeekCloser, error)
Open implements ReadableFile.
func (*FileInfo) Path ¶
Path gets the relative path including file name and extension. The directory is relative to the content root.
func (*FileInfo) TranslationBaseName ¶
TranslationBaseName returns a file's translation base name without the language segment (ie. "page").
type FileWithoutOverlap ¶
type FileWithoutOverlap interface { // Filename gets the full path and filename to the file. Filename() string // Dir gets the name of the directory that contains this file. // The directory is relative to the content root. Dir() string // Extension is an alias to Ext(). // Deprecated: Use Ext instead. Extension() string // Ext gets the file extension, i.e "myblogpost.md" will return "md". Ext() string // LogicalName is filename and extension of the file. LogicalName() string // BaseFileName is a filename without extension. BaseFileName() string // TranslationBaseName is a filename with no extension, // not even the optional language extension part. TranslationBaseName() string // ContentBaseName is a either TranslationBaseName or name of containing folder // if file is a leaf bundle. ContentBaseName() string // UniqueID is the MD5 hash of the file's path and is for most practical applications, // Hugo content files being one of them, considered to be unique. UniqueID() string // For internal use only. FileInfo() hugofs.FileMetaInfo }
type Filesystem ¶
type Filesystem struct { Base string SourceSpec // contains filtered or unexported fields }
Filesystem represents a source filesystem.
func (*Filesystem) Files ¶
func (f *Filesystem) Files() ([]File, error)
Files returns a slice of readable files.
type GitInfo ¶
type GitInfo struct { // Commit hash. Hash string `json:"hash"` // Abbreviated commit hash. AbbreviatedHash string `json:"abbreviatedHash"` // The commit message's subject/title line. Subject string `json:"subject"` // The author name, respecting .mailmap. AuthorName string `json:"authorName"` // The author email address, respecting .mailmap. AuthorEmail string `json:"authorEmail"` // The author date. AuthorDate time.Time `json:"authorDate"` // The commit date. CommitDate time.Time `json:"commitDate"` }
GitInfo provides information about a version controlled source file.
func NewGitInfo ¶
type SourceSpec ¶
type SourceSpec struct { *helpers.PathSpec SourceFs afero.Fs // contains filtered or unexported fields }
SourceSpec abstracts language-specific file creation. TODO(bep) rename to Spec
func NewSourceSpec ¶
func NewSourceSpec(ps *helpers.PathSpec, inclusionFilter *glob.FilenameFilter, fs afero.Fs) *SourceSpec
NewSourceSpec initializes SourceSpec using languages the given filesystem and PathSpec.
func (*SourceSpec) IgnoreFile ¶
func (s *SourceSpec) IgnoreFile(filename string) bool
IgnoreFile returns whether a given file should be ignored.
func (*SourceSpec) IsRegularSourceFile ¶
func (s *SourceSpec) IsRegularSourceFile(filename string) (bool, error)
IsRegularSourceFile returns whether filename represents a regular file in the source filesystem.
func (*SourceSpec) NewFileInfo ¶
func (sp *SourceSpec) NewFileInfo(fi hugofs.FileMetaInfo) (*FileInfo, error)
func (*SourceSpec) NewFileInfoFrom ¶
func (sp *SourceSpec) NewFileInfoFrom(path, filename string) (*FileInfo, error)
func (SourceSpec) NewFilesystem ¶
func (sp SourceSpec) NewFilesystem(base string) *Filesystem
NewFilesystem returns a new filesystem for a given source spec.
func (SourceSpec) NewFilesystemFromFileMetaInfo ¶
func (sp SourceSpec) NewFilesystemFromFileMetaInfo(fi hugofs.FileMetaInfo) *Filesystem