pkg

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetBasePath

func SetBasePath(path string, absolute bool)

Types

type Config

type Config struct {
	Files           []File   `yaml:"files"`
	WhiteListExt    []string `yaml:"white-list-external"`
	WhiteListInt    []string `yaml:"white-list-internal"`
	BlackList       []string `yaml:"black-list"`
	Timeout         int      `yaml:"timeout"`
	ReguestRepeats  int8     `yaml:"request-repeats"`
	AllowRedirect   bool     `yaml:"allow-redirect"`
	AllowCodeBlocks bool     `yaml:"allow-code-blocks"`
	IgnoreExternal  bool     `yaml:"ignore-external"`
	IgnoreInternal  bool     `yaml:"ignore-internal"`
}

func NewConfig

func NewConfig(commands cli.Commands) (*Config, error)
type FailedLinks struct {
	Count int
	Links []Link
}

type File

type File struct {
	RelPath string `yaml:"path"`
	AbsPath string
	DirPath string
	Content string
	Links   Links `yaml:"links"`
	Headers Headers
	Status  bool
	Config  *FileConfig `yaml:"config"`
	Stats   *FileStats
	// contains filtered or unexported fields
}

func NewFile

func NewFile(filePath string, fileLinks Links, config *FileConfig) (*File, error)

func (*File) ExtractHeaders

func (f *File) ExtractHeaders() *File
func (f *File) ExtractLinks() *File

func (*File) ExtractStats

func (f *File) ExtractStats() *File

func (*File) Run

func (f *File) Run()

func (*File) Summary

func (f *File) Summary() *File
func (f *File) ValidateLinks() *File

func (*File) WriteStats

func (f *File) WriteStats() *File

type FileConfig

type FileConfig struct {
	WhiteListExt    []string `yaml:"white-list-external"`
	WhiteListInt    []string `yaml:"white-list-internal"`
	Timeout         *int     `yaml:"timeout"`
	ReguestRepeats  *int8    `yaml:"request-repeats"`
	AllowRedirect   *bool    `yaml:"allow-redirect"`
	AllowCodeBlocks *bool    `yaml:"allow-code-blocks"`
	IgnoreExternal  *bool    `yaml:"ignore-external"`
	IgnoreInternal  *bool    `yaml:"ignore-internal"`
}

func NewFileConfig

func NewFileConfig(filePath string, config *Config) *FileConfig

type FileStats

type FileStats struct {
	SuccessLinks SuccessLinks
	FailedLinks  FailedLinks
}

func NewFileStats

func NewFileStats(file *File) *FileStats

type Files

type Files []*File

func NewFiles

func NewFiles(filePaths []string, config *Config) (Files, error)

func (Files) Run

func (f Files) Run(verbose bool)

func (Files) Summary

func (f Files) Summary() bool

type FilesStats

type FilesStats []*FileStats

func NewFilesStats

func NewFilesStats(files Files) FilesStats

type Headers

type Headers []string
type Link struct {
	RelPath string `yaml:"path"`
	AbsPath string
	Config  *LinkConfig `yaml:"config"`
	TypeOf  LinkType
	Result  LinkResult
}

type LinkConfig added in v0.0.3

type LinkConfig struct {
	Timeout        *int  `yaml:"timeout"`
	ReguestRepeats *int8 `yaml:"request-repeats"`
	AllowRedirect  *bool `yaml:"allow-redirect"`
}

func NewLinkConfig added in v0.0.4

func NewLinkConfig(link Link, file *File) *LinkConfig

type LinkResult

type LinkResult struct {
	Status  bool
	Message string
}

type LinkType

type LinkType string
const (
	ExternalLink     LinkType = "ExternalLink"
	InternalLink     LinkType = "InternalLink"
	HashInternalLink LinkType = "HashInternalLink"
)
type Links []Link
func NewLinks(filePath string, config *Config) Links

func (Links) AppendConfig added in v0.0.4

func (l Links) AppendConfig(file *File) Links

func (Links) CheckStatus

func (l Links) CheckStatus() bool

func (Links) Filter added in v0.0.3

func (l Links) Filter(condition func(link Link) bool) Links
func (l Links) RemoveWhiteLinks(externals, internals []string) Links

type Parser

type Parser struct{}

func (*Parser) Anchors added in v0.0.3

func (p *Parser) Anchors(body io.ReadCloser) (ids []string)

func (*Parser) Headers

func (p *Parser) Headers(markdown string) []string
func (p *Parser) Links(markdown, dirPath string) Links
type SuccessLinks struct {
	Count int
	Links []Link
}

type Validation

type Validation struct {
}
func (v *Validation) ExternalLinks(links Links) (Links, error)
func (v *Validation) HashInternalLinks(links Links, headers Headers) (Links, error)
func (v *Validation) InternalLink(links Links) (Links, error)
func (v *Validation) Links(links []Link, optionalHeaders ...Headers) []Link

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL