diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/general.go | 2 | ||||
-rw-r--r-- | helpers/hugo.go | 10 | ||||
-rw-r--r-- | helpers/path.go | 2 | ||||
-rw-r--r-- | helpers/processing_stats.go | 7 |
4 files changed, 15 insertions, 6 deletions
diff --git a/helpers/general.go b/helpers/general.go index ab66376c3..43a921318 100644 --- a/helpers/general.go +++ b/helpers/general.go @@ -445,7 +445,7 @@ func DiffStringSlices(slice1 []string, slice2 []string) []string { return diffStr } -// DiffString splits the strings into fields and runs it into DiffStringSlices. +// DiffStrings splits the strings into fields and runs it into DiffStringSlices. // Useful for tests. func DiffStrings(s1, s2 string) []string { return DiffStringSlices(strings.Fields(s1), strings.Fields(s2)) diff --git a/helpers/hugo.go b/helpers/hugo.go index 4ec340e18..45c261fd0 100644 --- a/helpers/hugo.go +++ b/helpers/hugo.go @@ -39,27 +39,29 @@ var ( _ compare.Comparer = (*HugoVersionString)(nil) ) -type HugoVersionString string - func (v HugoVersion) String() string { return hugoVersion(v.Number, v.PatchLevel, v.Suffix) } +// Version returns the Hugo version. func (v HugoVersion) Version() HugoVersionString { return HugoVersionString(v.String()) } +// HugoVersionString represents a Hugo version string. +type HugoVersionString string + func (h HugoVersionString) String() string { return string(h) } -// Implements compare.Comparer +// Compare implements the compare.Comparer interface. func (h HugoVersionString) Compare(other interface{}) int { v := MustParseHugoVersion(h.String()) return compareVersionsWithSuffix(v.Number, v.PatchLevel, v.Suffix, other) } -// Implements compare.Eqer +// Eq implements the compare.Eqer interface. func (h HugoVersionString) Eq(other interface{}) bool { s, err := cast.ToStringE(other) if err != nil { diff --git a/helpers/path.go b/helpers/path.go index 9fef06d2a..1549df404 100644 --- a/helpers/path.go +++ b/helpers/path.go @@ -545,7 +545,7 @@ func WriteToDisk(inpath string, r io.Reader, fs afero.Fs) (err error) { return afero.WriteReader(fs, inpath, r) } -// OpenFileForWriting opens all the given filenames for writing. +// OpenFilesForWriting opens all the given filenames for writing. func OpenFilesForWriting(fs afero.Fs, filenames ...string) (io.WriteCloser, error) { var writeClosers []io.WriteCloser for _, filename := range filenames { diff --git a/helpers/processing_stats.go b/helpers/processing_stats.go index 2d7fcb4de..4382d5fa5 100644 --- a/helpers/processing_stats.go +++ b/helpers/processing_stats.go @@ -21,6 +21,7 @@ import ( "github.com/olekukonko/tablewriter" ) +// ProcessingStats represents statistics about a site build. type ProcessingStats struct { Name string @@ -52,18 +53,23 @@ func (s *ProcessingStats) toVals() []processingStatsTitleVal { } } +// NewProcessingStats returns a new ProcessingStats instance. func NewProcessingStats(name string) *ProcessingStats { return &ProcessingStats{Name: name} } +// Incr increments a given counter. func (s *ProcessingStats) Incr(counter *uint64) { atomic.AddUint64(counter, 1) } +// Add adds an amount to a given counter. func (s *ProcessingStats) Add(counter *uint64, amount int) { atomic.AddUint64(counter, uint64(amount)) } +// Table writes a table-formatted representation of the stats in a +// ProcessingStats instance to w. func (s *ProcessingStats) Table(w io.Writer) { titleVals := s.toVals() data := make([][]string, len(titleVals)) @@ -80,6 +86,7 @@ func (s *ProcessingStats) Table(w io.Writer) { } +// ProcessingStatsTable writes a table-formatted representation of stats to w. func ProcessingStatsTable(w io.Writer, stats ...*ProcessingStats) { names := make([]string, len(stats)+1) |