Documentation ¶
Overview ¶
Package htmldoc : Provides local document interface for htmltest. Models a store of documents, individual documents and their internal and external references.
Index ¶
- func AttrPresent(attrs []html.Attribute, key string) bool
- func ExtractAttrs(attrs []html.Attribute, keys []string) map[string]string
- func GetAttr(attrs []html.Attribute, key string) string
- func GetID(attrs []html.Attribute) string
- func URLStripQueryString(urlStr string) string
- type Document
- type DocumentState
- type DocumentStore
- type Reference
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttrPresent ¶ added in v0.1.1
AttrPresent : Is key present within attrs?
func ExtractAttrs ¶ added in v0.1.1
ExtractAttrs : From attrs extract the asked for keys
func URLStripQueryString ¶
URLStripQueryString : Utility function to remove query string from given urlStr.
Types ¶
type Document ¶
type Document struct { FilePath string // Relative to the shell session SitePath string // Relative to the site root BasePath string // Base for relative links NodesOfInterest []*html.Node // Slice of nodes to run checks on State DocumentState // Link to a DocumentState struct DoctypeNode *html.Node // Pointer to doctype node if exists // contains filtered or unexported fields }
Document struct, representation of a document within the tested site
func (*Document) Init ¶ added in v0.1.1
func (doc *Document) Init()
Init : Initialise the Document struct doesn't mesh nice with the NewXYZ() convention but many optional parameters for Document and no parameter overloading in Go
func (*Document) IsHashValid ¶ added in v0.1.1
IsHashValid : Is a hash/fragment present in this Document.
type DocumentState ¶
type DocumentState struct {
FaviconPresent bool // Have we found a favicon in the document?
}
DocumentState struct, used by checks that depend on the document being parsed.
type DocumentStore ¶ added in v0.1.1
type DocumentStore struct { BasePath string // Path, relative to cwd, the site is located in IgnorePatterns []interface{} // Regexes of directories to ignore Documents []*Document // All of the documents, used to iterate over DocumentPathMap map[string]*Document // Maps slash separated paths to documents DocumentExtension string // File extension to look for DirectoryIndex string // What file is the index of the directory }
DocumentStore struct, store of Documents including Document discovery
func NewDocumentStore ¶ added in v0.1.1
func NewDocumentStore() DocumentStore
NewDocumentStore : Create and return a new Document store.
func (*DocumentStore) AddDocument ¶ added in v0.1.1
func (dS *DocumentStore) AddDocument(doc *Document)
AddDocument : Add a document to the document store.
func (*DocumentStore) Discover ¶ added in v0.1.1
func (dS *DocumentStore) Discover()
Discover : Discover all documents within DocumentStore.BasePath.
func (*DocumentStore) ResolvePath ¶ added in v0.1.1
func (dS *DocumentStore) ResolvePath(refPath string) (*Document, bool)
ResolvePath : Resolves internal absolute paths to documents.
func (*DocumentStore) ResolveRef ¶ added in v0.1.1
func (dS *DocumentStore) ResolveRef(ref *Reference) (*Document, bool)
ResolveRef : Proxy to ResolvePath via ref.RefSitePath()
type Reference ¶
type Reference struct { Document *Document // Document node is in Node *html.Node // Node reference was created from Path string // href/src taken verbatim from source URL *url.URL // URL object created from Path }
Reference struct, representation of the link between a document and a resource.
func NewReference ¶
NewReference : Create a new reference given a document, node and path. Generates the URL object.
func (*Reference) IsInternalAbsolute ¶
IsInternalAbsolute : Is an internal absolute link.
func (*Reference) RefSitePath ¶ added in v0.1.1
RefSitePath : For internals, return a path to the referenced file relative to the 'site root'.