Documentation ¶
Overview ¶
Package parser implements types and methods to parse markdown files in a filesystem to HTML to a destination filesystem that can be used to serve needforheat manuals.
Index ¶
- Variables
- func GetDestinationDirPath(source fs.FS, dirPath string) (string, error)
- func GetDestinationFilePath(source fs.FS, filePath string) (string, error)
- func NewDeviceRepoSource(url string, auth transport.AuthMethod) (fs.FS, error)
- func NewLabDirSource(path string) (fs.FS, error)
- func NewLabRepoSource(url string, branch string, auth transport.AuthMethod) (fs.FS, error)
- type DeviceRepoSource
- type HTMLTemplate
- type LabDirSource
- type LabRepoSource
- type ManualCategory
- type Parser
- type SourceFS
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotSourceFS = errors.New("parser: type does not implement SourceFS interface")
)
var (
ErrTemplateNotFound = errors.New("template file could not be found")
)
Functions ¶
func GetDestinationDirPath ¶
Get the path to copy a directory to at the destination filesystem. Use dirPath at sourceFS to determine the path the directory should be copied to at the destination filesystem.
An error will be returned if source is not a SourceFS.
func GetDestinationFilePath ¶
Get the path to copy a file to at the destination filesystem. Use filePath at sourceFS to determine the path the file should be copied to at the destination filesystem.
An error will be returned if source is not a SourceFS.
func NewDeviceRepoSource ¶
Create a new source filesystem from a directory at path.
func NewLabDirSource ¶
Create a new source filesystem from a directory at path.
func NewLabRepoSource ¶
Create a new source filesystem from a directory at path.
Types ¶
type DeviceRepoSource ¶
DeviceRepoSource is a git repo that contains manuals made by developers of a device.
func (DeviceRepoSource) GetDestinationDirPath ¶
func (repo DeviceRepoSource) GetDestinationDirPath(dirPath string) string
Get the path to copy a directory to at the destination filesystem. Use dirPath at sourceFS to determine the path the directory should be copied to at the destination filesystem.
func (DeviceRepoSource) GetDestinationFilePath ¶
func (repo DeviceRepoSource) GetDestinationFilePath(filePath string) string
Get the path to copy a file to at the destination filesystem. Use filePath at sourceFS to determine the path the file should be copied to at the destination filesystem.
type HTMLTemplate ¶
HTMLTemplate contains data for filling a template.html.
type LabDirSource ¶
LabDirSource is a local directory that contains manuals made by a lab.
func (LabDirSource) GetDestinationDirPath ¶
func (dir LabDirSource) GetDestinationDirPath(dirPath string) string
Get the path to copy a directory to at the destination filesystem. Use dirPath at sourceFS to determine the path the directory should be copied to at the destination filesystem.
func (LabDirSource) GetDestinationFilePath ¶
func (dir LabDirSource) GetDestinationFilePath(filePath string) string
Get the path to copy a file to at the destination filesystem. Use filePath at sourceFS to determine the path the file should be copied to at the destination filesystem.
type LabRepoSource ¶
LabRepoSource is a git repo that contains manuals made by a lab.
func (LabRepoSource) GetDestinationDirPath ¶
func (repo LabRepoSource) GetDestinationDirPath(dirPath string) string
Get the path to copy a directory to at the destination filesystem. Use dirPath at sourceFS to determine the path the directory should be copied to at the destination filesystem.
func (LabRepoSource) GetDestinationFilePath ¶
func (repo LabRepoSource) GetDestinationFilePath(filePath string) string
Get the path to copy a file to at the destination filesystem. Use filePath at sourceFS to determine the path the file should be copied to at the destination filesystem.
type ManualCategory ¶
type ManualCategory string
ManualCategory is the type of manual.
const ( ManualCategoryUnknown ManualCategory = "unknown" ManualCategoryDevice ManualCategory = "devices" ManualCategoryCampaign ManualCategory = "campaigns" )
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
A Parser can parse manuals written in markdown to html files.
Following the folder structure specification, the parser will parse all markdown files to HTML while checking languages and creating a structure that can be served by a [Server].
type SourceFS ¶
type SourceFS interface { // Get the path to copy a file to at the destination filesystem. // Use filePath at sourceFS to determine the path the file should be copied to at the destination filesystem. GetDestinationFilePath(filePath string) string // Get the path to copy a directory to at the destination filesystem. // Use dirPath at sourceFS to determine the path the directory should be copied to at the destination filesystem. GetDestinationDirPath(dirPath string) string }
Source is an interface for a filesystem that can be used as a source for a Parser.