Misc doc, code refactoring to improve documentation

This commit is contained in:
Bjørn Erik Pedersen
2022-12-30 09:20:58 +01:00
parent 3c51625c71
commit e402d91ee1
47 changed files with 238 additions and 95 deletions

2
common/docs.go Normal file
View File

@@ -0,0 +1,2 @@
// Package common provides common helper functionality for Hugo.
package common

View File

@@ -30,6 +30,7 @@ type Scratch struct {
// Scratcher provides a scratching service.
type Scratcher interface {
// Scratch returns a "scratch pad" that can be used to store state.
Scratch() *Scratch
}

View File

@@ -263,3 +263,14 @@ func (n NamedSlice) String() string {
}
return fmt.Sprintf("%s%s{%s}", n.Name, FilePathSeparator, strings.Join(n.Slice, ","))
}
// DirFile holds the result from path.Split.
type DirFile struct {
Dir string
File string
}
// Used in test.
func (df DirFile) String() string {
return fmt.Sprintf("%s|%s", df.Dir, df.File)
}

View File

@@ -24,6 +24,8 @@ import (
// Positioner represents a thing that knows its position in a text file or stream,
// typically an error.
type Positioner interface {
// Position returns the current position.
// Useful in error logging, e.g. {{ errorf "error in code block: %s" .Position }}.
Position() Position
}