graph-resources

Create a resource graph.

Create a graph of referenced resources.

new GraphResources(context)

Create a resource graph.

GraphResources.prototype.sources(file, context, options)

Inspects the abstract syntax tree for each file to find referenced resources and add them to the graph.

If a file does not have an associated abstract syntax tree a document is added to the resource graph but no parsing is performed on the document.

Represents a document entry in the graph.

new Document(file)

Create a document.

readonly Array resources

List of resources referenced in this document.

readonly File file

Reference to the file that created this document.

readonly String id

Document identifier derived from the file path.

Represents an HTML document entry in the graph.

new HtmlDocument(file)

Create an HTML document.

Object anchors

List of anchor links.

Plugins that execute during the verify phase can use this to check if named anchors exist on the page or test whether external links return a valid HTTP status code.

Object identifiers

Map of id attributes.

Plugins that execute during the verify phase can use this to determine if a document contains duplicate id attributes.

Object ast

Get a reference to the file abstract syntax tree.

HtmlDocument.prototype.parse()

Traverse the file abstract syntax tree and parse resources in to this document.

Note that in the case of a base element with an href attribute a resource is not created but all subsequent URLs are considered relative to the base URL.

Represents a CSS document entry in the graph.

new CssDocument(file)

Create a CSS document.

Object ast

Get a reference to the file abstract syntax tree.

CssDocument.prototype.parse()

Traverse the file abstract syntax tree and parse resources in to this document.

This implementation parses @import rules using either string URLs or the url() function notation. It also parses all url() function declarations in normal CSS rule declarations.

Represents the application resource graph.

new Graph()

Create a resource graph.

readonly Object map

Maps file keys to resources.

Graph.prototype.addDocument()

Adds a document to the graph.

readonly Array documents

List of documents without abstract syntax trees.

readonly Array htmlDocuments

List of HTML documents.

readonly Array cssDocuments

List of CSS documents.

Graph.prototype.createDocument(file)

Create a document.

Returns a new document.

Graph.prototype.createHtmlDocument(file)

Create an HTML document.

Returns a new HTML document.

Graph.prototype.createCssDocument(file)

Create a CSS document.

Returns a new CSS document.

Represents a referenced resource.

The resource may exist within the output file structure or may point to an external (absolute) resource.

new Resource(uri, node[, base])

Creates a resource.

readonly String uri

Uniform resource identifier.

readonly Object node

An abstract syntax tree node associated with this resource.

readonly String base

Base URL for this resource.

Resource.prototype.isAbsolute(uri)

Determine if a URI is absolute.

If no URI is given the URI for this resource is used.

Returns a boolean indicating if this resource is absolute.

readonly String canonical

Get the canonical URI for this resource relative to the base if a base URL has been associated with this resource.

When no base URL is assigned to this resource it will return the uri.