API Docs for:
Show:

Docpad Class

Extends EventEmitterGrouped

Contains methods for managing the DocPad application. This includes managing a DocPad projects files and documents, watching directories, emitting events and managing the node.js/express.js web server. Extends https://github.com/bevry/event-emitter-grouped

The class is instantiated in the docpad-server.js file which is the entry point for a DocPad application.

new DocPad(docpadConfig, function(err, docpad) {
    if (err) {
        return docpadUtil.writeError(err);
    }
    return docpad.action(action, function(err) {
        if (err) {
            return docpadUtil.writeError(err);
        }
        return console.log('OK');
    });
});

Constructor

Docpad

()

Item Index

Methods

Methods

action

(
  • args
)
Object

Apply the passed DocPad action arguments

Parameters:

  • args Object

Returns:

Object:

addCollection

(
  • collection
)

Add a collection

Parameters:

  • collection Object

addModel

(
  • model
  • opts
)
Object

Add supplied model to the DocPad database. If the passed model definition is a plain object of properties, a new model will be created prior to adding to the database. Calls DocPad/createModel:method before adding the model to the database.

# Override the stat's mtime to now
# This is because renames will not update the mtime
fileCurrentStat?.mtime = new Date()

# Create the file object
file = docpad.addModel({fullPath:filePath, stat:fileCurrentStat})

Parameters:

  • model Object

    either a plain object defining the required properties, in particular the file path or an actual model object

  • opts Object

Returns:

Object:

the model

addModels

(
  • models
  • opts
)
Object

Add the supplied collection of models to the DocPad database. Calls DocPad/createModels:method before adding the models to the database.

databaseData = JSON.parse data.toString()
models = docpad.addModels(databaseData.models)

Parameters:

  • models Object

    DocPad collection of models

  • opts Object

Returns:

Object:

the models

attachModelEvents

(
  • model
)
private

Attach events to a document model.

Parameters:

  • model Object

checkRequest

(
  • next
)
private

Check Request

Parameters:

  • next Function
    • err Error
    • res Object

clean

(
  • opts
  • next
)
Object private

DocPad cleanup tasks.

Parameters:

  • opts Object
  • next Object
    • err Error

Returns:

Object:

description

compareVersion

() private

Compare current DocPad version to the latest and print out the result to the console. Used at startup.

constructor

(
  • instanceConfig
  • next
)

Constructor method. Sets up the DocPad instance. next(err)

Parameters:

  • instanceConfig Object
  • next Function

    callback

    • err Error

contextualizeFiles

(
  • [opts={}]
  • next
)
private

Contextualize files. Contextualizing is the process of adding layouts and awareness of other documents to our document. The contextualizeBefore and contextualizeAfter events are emitted here.

Parameters:

  • [opts={}] Object optional
  • next Function
    • err Error

createDocument

(
  • [attrs={}]
  • [opts={}]
)
Object

Create document model. Calls DocPad/createModel:method with the 'document' modelType.

Parameters:

  • [attrs={}] Object optional
  • [opts={}] Object optional

Returns:

Object:

DocumentModel

createError

(
  • err
  • opts
)
Object

Create an error object

Parameters:

  • err Object
  • opts Object

Returns:

Object:

the error

createFile

(
  • [attrs={}]
  • [opts={}]
)
Object

Create file model. Calls DocPad/createModel:method with the 'file' modelType.

Parameters:

  • [attrs={}] Object optional
  • [opts={}] Object optional

Returns:

Object:

FileModel

createModel

(
  • [attrs={}]
  • [opts={}]
)
Object

Creates either a file or document model. The model type to be created can be passed as an opts property, if not, the method will attempt to determing the model type by checking if the file is in one of the documents or layout paths.

Ensures a duplicate model is not created and all required attributes are present and events attached.

Generally it is not necessary for an application to manually create a model via creatModel as DocPad will handle this process when watching a project's file and document directories. However, it is possible that a plugin might have a requirement to do so.

model = @docpad.createModel({fullPath:fullPath})

model.load()

Parameters:

  • [attrs={}] Object optional
    • fullPath String

      the full path to the file

  • [opts={}] Object optional
    • modelType String

      either 'file' or 'document'

Returns:

Object:

the file or document model

createModels

(
  • models
  • opts
)
Object private

Create a collection of models from the supplied collection ensuring that the collection is suitable for adding to the DocPad database. The method calls DocPad/createModel for each model in the models array.

Parameters:

  • models Object

    DocPad collection of models

  • opts Object

Returns:

Object:

the models

createProgress

() Object private

Create the console progress bar. Progress only shown if the DocPad config 'progress' option is true, the DocPad config 'prompts' option is true and the log level is 6 (default)

Returns:

Object:

the progress object

createRegenerateTimer

() private

Create the regeneration timer

destroy

(
  • opts
  • next
)

Destructor. Destroy the DocPad instance This is an action, and should be called as such E.g. docpad.action('destroy', next)

Parameters:

  • opts Object
  • next Function
    • err Error

destroyBlocks

() private

Destructor. Destroy all blocks

destroyCollection

(
  • value
)
Object

Destroy a collection by collection name or key

Parameters:

  • value String

Returns:

Object:

description

destroyCollections

() private

Destructor. Destroy the DocPad project's collections.

destroyDatabase

() private

Destructor. Destroy the DocPad database

destroyLoggers

() private

Destructor. Destroy the caterpillar logger instances bound to DocPad

destroyPlugins

() private

Destructor. Destroy plugins

destroyProgress

(
  • progress
)
Object private

Destructor. Destroy the progress object

Parameters:

  • progress Object

Returns:

Object:

the progress object

destroyRegenerateTimer

() private

Destructor. Destroy the regeneration timer.

destroyServer

() private

Destructor. Close and destroy the node.js http server

destroyWatchers

() private

Destructor. Destroy the watchers used by DocPad

eachBlock

(
  • fn
)

Apply the passed function to each block

Parameters:

  • fn Function

eachCollection

(
  • fn
)

Apply the passed function to each collection

Parameters:

  • fn Function

emitParallel

(
  • eventName
  • opts
  • next
)
private

Emit event, parallel

Parameters:

  • eventName String
  • opts Object
  • next Function
    • err Error

emitSerial

(
  • eventName
  • opts
  • next
)
private

Emit event, serial

Parameters:

  • eventName String
  • opts Object
  • next Function
    • err Error

error

(
  • err
  • [level='err']
)

Create an error (tracks it) and log it

Parameters:

  • err Object
  • [level='err'] Object optional

extendCollections

(
  • next
)
private

Extend collecitons. Create DocPad's standard (documents, files layouts) and special (generate, referencesOthers, hasLayout, html, stylesheet) collections. Set blocks

Parameters:

  • next Function
    • err Error

fatal

(
  • err
)
private

Handle a fatal error

Parameters:

  • err Object

fixNodePackageVersions

(
  • opts
  • next
)
private

Parameters:

  • opts Object
  • next Function
    • err Error

generate

(
  • opts
  • next
)

Set off DocPad's generation process. The generated, populateCollectionsBefore, populateCollections, populateCollections generateBefore and generateAfter events are emitted here

Parameters:

  • opts Object
  • next Function
    • err Error

getActionRunner

() Object

Get the action runner instance bound to docpad

Returns:

Object:

the action runner instance

getBlock

(
  • name
  • [clone]
)
Object

Get a block by block name. Optionally clone block.

Parameters:

  • name String
  • [clone] Object optional

Returns:

Object:

block

getBlocks

() Object

Get all blocks

Returns:

Object:

collection of blocks

getCollection

(
  • value
)
Object

Get a collection by collection name or key. This is often accessed within the docpad.coffee file or a layout/page via @getCollection. Because getCollection returns a docpad collection, a call to this method is often chained with a QueryEngine style query.

Parameters:

  • value String

Returns:

Object:

collection

getCollections

() Object

Get the DocPad project's collections

Returns:

Object:

the collections

getConfig

() Object

Get the DocPad configuration. Commonly called within the docpad.coffee file or within plugins to access application specific configurations. serverExtend: (opts) -> Extract the server from the options {server} = opts docpad = @docpad

As we are now running in an event, ensure we are using the latest copy of the docpad configuraiton and fetch our urls from it latestConfig = docpad.getConfig() oldUrls = latestConfig.templateData.site.oldUrls or [] newUrl = latestConfig.templateData.site.url

Redirect any requests accessing one of our sites oldUrls to the new site url server.use (req,res,next) -> ...

Returns:

Object:

the DocPad configuration object

getConfigPath

(
  • opts
  • next
)
private

Get config paths and check that those paths exist

Parameters:

  • opts Object
  • next Object
    • err Error
    • path String

getDatabase

()

Description for getDatabase

getDatabaseSafe

() Object

Safe method for retrieving the database by either returning the database itself or the temporary database cache

Returns:

Object:

getDebugging

() Boolean

Are we debugging?

Returns:

Boolean:

getEnvironment

() String

Get the DocPad environment, eg: development, production or static

Returns:

String:

the environment

getEnvironments

() Array

Get the environments

Returns:

Array:

array of environment strings

getErrorRunner

() Object

Get the error runner instance

Returns:

Object:

the error runner instance

getEvents

() Object

Get the list of available events

Returns:

Object:

string array of event names

getExchange

(
  • next
)
private

Get DocPad's exchange data Requires internet access next(err,exchange)

Parameters:

  • next Function
    • err Error
    • exchange Object

      docpad.exchange

getFile

(
  • query
  • sorting
  • paging
)
Object

Get a single file based on a query

Parameters:

  • query Object
  • sorting Object
  • paging Object

Returns:

Object:

a file

getFileAtPath

(
  • path
  • sorting
  • paging
)
Object

Get a file at a relative or absolute path or url

Parameters:

  • path String
  • sorting Object
  • paging Object

Returns:

Object:

a file

getFileById

(
  • id
  • [opts={}]
)
Object

Get a file by its id

Parameters:

  • id String
  • [opts={}] Object optional

Returns:

Object:

a file

getFileByRoute

(
  • url
  • next
)

Get a file by its route and return it to the supplied callback.

Parameters:

  • url String
  • next Object
    • err Error
    • file String

getFileBySelector

(
  • selector
  • [opts={}]
)
Object

Get a file by its selector

Parameters:

  • selector Object
  • [opts={}] Object optional

Returns:

Object:

a file

getFileByUrl

(
  • url
  • [opts={}]
)
Object

Get a file by its url

Parameters:

  • url String
  • [opts={}] Object optional

Returns:

Object:

a file

getFiles

(
  • query
  • sorting
  • paging
)
Object

Get all the files in the DocPad database (will use live collections)

Parameters:

  • query Object
  • sorting Object
  • paging Object

Returns:

Object:

collection

getFilesAtPath

(
  • path
  • sorting
  • paging
)
Object

Get files at a path

Parameters:

  • path String
  • sorting Object
  • paging Object

Returns:

Object:

files

getHostname

() String

Get the Hostname

Returns:

String:

getIgnoreOpts

() Array

Get the ignore options for the DocPad project

Returns:

Array:

string array of ignore options

getLocale

() Object

Get the locale (language code and locale code)

Returns:

Object:

locale

getLogger

() Object

Get the caterpillar logger instance bound to DocPad

Returns:

Object:

caterpillar logger

getLoggers

() Object

Get all the caterpillar logger instances bound to DocPad

Returns:

Object:

collection of caterpillar loggers

getLogLevel

() Number

Get the log level

Returns:

Number:

the log level

getPlugin

(
  • pluginName
)
Object

Get a plugin by it's name

Parameters:

  • pluginName Object

Returns:

Object:

a DocPad plugin

getPort

() Number

Get the port that DocPad is listening on (eg 9778)

Returns:

Number:

the port number

getProcessPlatform

() Object

Get the process platform

Returns:

Object:

getProcessVersion

() String

Get the process version string

Returns:

String:

getServer

(
  • [both=false]
)
Object

Get the DocPad express.js server instance and, optionally, the node.js https server instance

Parameters:

  • [both=false] Boolean optional

Returns:

Object:

getServerUrl

(
  • [opts={}]
)
String

Get address

Parameters:

  • [opts={}] Object optional

Returns:

String:

getSimpleServerUrl

(
  • [opts={}]
)
String

Get simple server URL (changes 0.0.0.0, ::, and ::1 to 127.0.0.1)

Parameters:

  • [opts={}] Object optional
    • [simple=true] Boolean optional

Returns:

String:

getSkeletons

(
  • next
)
Object

Get Skeletons Get all the available skeletons with their details and return this collection to the supplied callback.

Parameters:

  • next Function
    • err Error
    • skeletonsCollection Object

      DocPad collection of skeletons

Returns:

Object:

DocPad skeleton collection

getTemplateData

(
  • userTemplateData
)
Object

Get Complete Template Data

Parameters:

  • userTemplateData Object

Returns:

Object:

templateData

getTrackRunner

() Object

Get the track runner instance

Returns:

Object:

the track runner instance

getUrlPathname

(
  • url
)
String

Remove the query string from a url Pathname convention taken from document.location.pathname

Parameters:

  • url String

Returns:

String:

getVersion

() Number

Get the DocPad version number

Returns:

Number:

getVersionString

() String

Get the DocPad version string

Returns:

String:

hasPlugins

() Boolean

Check if we have any plugins

Returns:

Boolean:

identify

(
  • next
)
private

Identify DocPad user

Parameters:

  • next Function
    • err Error

init

(
  • opts
  • next
)
Object private

Initialize the project directory with the basic skeleton.

Parameters:

  • opts Object
  • next Object
    • err Error

Returns:

Object:

description

initGitRepo

(
  • opts
  • next
)
private

Initialise git repo

Parameters:

  • opts Object
  • next Function
    • err Error
    • results Object

initInstall

(
  • opts
  • next
)
private

Initialize the skeleton install process.

Parameters:

  • opts Object
  • next Function
    • err Error

initNodeModules

(
  • opts
  • next
)
private

Init node modules

Parameters:

  • opts Object
  • next Function
    • err Error
    • results Object

initSkeleton

(
  • skeletonModel
  • opts
  • next
)
private

Initialize a Skeleton into to a Directory

Parameters:

  • skeletonModel Object
  • opts Object
  • next Function
    • err Error

inspector

(
  • obj
  • opts
)
String

Inspect. Converts object to JSON string. Wrapper around nodes util.inspect method. Can't use the inspect namespace as for some silly reason it destroys everything

Parameters:

  • obj Object
  • opts Object

Returns:

String:

JSON string of passed object

install

(
  • opts
  • next
)
private

Install a plugin

Parameters:

  • opts Object
  • next Function
    • err Error

installNodeModule

(
  • names
  • opts
  • next
)
private

Install node module. Same as running 'npm install' through the command line

Parameters:

  • names Array
  • opts Object
  • next Function
    • err Error
    • result Object

installSkeleton

(
  • skeletonModel
  • opts
  • next
)
private

Install a Skeleton into a Directory

Parameters:

  • skeletonModel Object
  • opts Object
  • next Function
    • err Error

isIgnoredPath

(
  • path
  • [opts={}]
)
Boolean

Is the supplied path ignored?

Parameters:

  • path String
  • [opts={}] Object optional

Returns:

Boolean:

load

(
  • instanceConfig
  • next
)
private

Load the various configuration files from the file system. Set the instanceConfig. next(err,config)

Parameters:

  • instanceConfig Object
  • next Function
    • err Error
    • config Object

loadAndRenderDocument

(
  • document
  • opts
  • next
)

Load and render a document

Parameters:

  • document Object
  • opts Object
  • next Function
    • err Error
    • document Object

loadConfigPath

(
  • opts
  • next
)
private

Load the configuration from a file path passed as one of the options (opts.configPath) or from DocPad's configPaths

Parameters:

  • opts Object
  • next Function
    • err Error
    • parsedData Object

loadConfigUrl

(
  • configUrl
  • next
)

Load a configuration url.

Parameters:

  • configUrl String
  • next Function
    • err Error
    • parsedData Object

loadDocument

(
  • document
  • opts
  • next
)
private

Load a document

Parameters:

  • document Object
  • opts Object
  • next Function
    • err Error
    • document Object

loadedPlugin

(
  • pluginName
  • next
)

Checks if a plugin was loaded succesfully.

Parameters:

  • pluginName String
  • next Function
    • err Error
    • loaded Boolean

loadLocale

(
  • code
)
Object

Load the locale

Parameters:

  • code String

Returns:

Object:

locale

loadPlugin

(
  • fileFullPath
  • _next
)
Object private

Load a plugin from its full file path _next(err)

Parameters:

  • fileFullPath String
  • _next Function
    • err Error

Returns:

Object:

description

loadPlugins

(
  • next
)
private

Load plugins from the file system next(err)

Parameters:

  • next Function
    • err Error

loadPluginsIn

(
  • pluginsPath
  • next
)
private

Load plugins from a directory path

Parameters:

  • pluginsPath String
  • next Function
    • err Error

logError

(
  • err
)

Log an error

Parameters:

  • err Object

mergeConfigurations

(
  • configPackages
  • configsToMerge
)
private

Performs the merging of the passed configuration objects

Parameters:

  • configPackages Object
  • configsToMerge Object

notify

(
  • message
  • [opts={}]
)

Send a notify event to plugins (like growl)

Parameters:

  • message String
  • [opts={}] Object optional

notifyError

(
  • err
)
private

Notify error

Parameters:

  • err Object

parseDirectory

(
  • [opts={}]
  • next
)

Parse a directory and return a files collection

Parameters:

  • [opts={}] Object optional
  • next Object
    • err Error
    • files Object

      files collection

parseDocumentDirectory

(
  • [opts={}]
  • next
)

Parse the documents directory and return a documents collection to the passed callback.

The partials plugin (https://github.com/docpad/docpad-plugin-partials) uses this method to load a collection of files from the partials directory.

docpad.parseDocumentDirectory({path: config.partialsPath}, next)

Parameters:

  • [opts={}] Object optional
    • [modelType='document'] String optional
    • [collection=docpad.database] Object optional
    • [path] Object optional
  • next Function
    • err Error
    • files Object

      files collection of documents

parseFileDirectory

(
  • [opts={}]
  • next
)

Parse the files directory and return a files collection to the passed callback

Parameters:

  • [opts={}] Object optional
  • next Function

    callback

    • err Error
    • files Object

      files collection

ready

(
  • [opts]
  • next
)
private

DocPad is ready. Peforms the tasks needed after DocPad construction and DocPad has loaded. Triggers the docpadReady event. next(err,docpadInstance)

Parameters:

  • [opts] Object optional
  • next Function
    • err Error
    • docpadInstance Object

render

(
  • opts
  • next
)

Render action next(err,document,result)

Parameters:

  • opts Object
  • next Function
    • err Error

renderData

(
  • content
  • opts
  • next
)

Render the passed content data as a document. Required option, filename (opts.filename) next(err,result)

Parameters:

  • content String
  • opts Object
  • next Function
    • err Error
    • result Object

      the rendered document

renderDocument

(
  • document
  • opts
  • next
)

Render a document

Parameters:

  • document Object
  • opts Object
  • next Object
    • err Error
    • result Object
    • document Object

renderFiles

(
  • [opts={}]
  • next
)
private

Render the DocPad project's files. The renderCollectionBefore, renderCollectionAfter, renderBefore, renderAfter events are all emitted here.

Parameters:

  • [opts={}] Object optional
  • next Function
    • err Error

renderPath

(
  • path
  • opts
  • next
)

Render a document at a file path next(err,result)

Parameters:

  • path String
  • opts Object
  • next Function
    • err Error
    • result Object

      the rendered document

renderText

(
  • text
  • opts
  • next
)
private

Render the passed text data as a document. Required option, filename (opts.filename) next(err,result)

Parameters:

  • text String
  • opts Object
  • next Function
    • err Error
    • result Object

      the rendered content

    • document Object

      the rendered document model

resetCollections

(
  • opts
  • next
)
private

Reset collections. Perform a complete clean of our collections

Parameters:

  • opts Object
  • next Function
    • err Error

run

(
  • opts
  • next
)

Run an action

Parameters:

  • opts Object
  • next Function
    • err Error

scandir

(
  • [opts={}]
)

Scan directory

Parameters:

  • [opts={}] Object optional

selectSkeleton

(
  • opts
  • next
)
private

Select a Skeleton

Parameters:

  • opts Object
  • next Function
    • err Error
    • skeletonModel Error

serveDocument

(
  • opts
  • next
)
private

Serve a document

Parameters:

  • opts Object
  • next Function
    • err Error

server

(
  • opts
  • next
)
private

Configure and start up the DocPad web server. Http and express server is created, extended with middleware, started up and begins listening. The events serverBefore, serverExtend and serverAfter emitted here.

Parameters:

  • opts Object
  • next Function

serverMiddleware404

(
  • req
  • res
  • next
)
private

Server Middleware: 404

Parameters:

  • req Object
  • res Object
  • next Object

serverMiddleware500

(
  • err
  • req
  • res
  • next
)
private

Server Middleware: 500

Parameters:

  • err Object
  • req Object
  • res Object
  • next Function

serverMiddlewareHeader

(
  • req
  • res
  • next
)
private

Server Middleware: Header

Parameters:

  • req Object
  • res Object
  • next Object

serverMiddlewareRouter

(
  • req
  • res
  • next
)
private

Server Middleware: Router

Parameters:

  • req Object
  • res Object
  • next Function
    • err Error

setBlock

(
  • name
  • value
)

Set a block by name and value

Parameters:

  • name String
  • value Object

setBlocks

(
  • blocks
)

Set all blocks

Parameters:

  • blocks Object

setCollection

(
  • name
  • collection
)

Set a name for a collection. A collection can have multiple names

The partials plugin (https://github.com/docpad/docpad-plugin-partials) creates a live collection and passes this to setCollection with the name 'partials'.

# Add our partials collection
docpad.setCollection('partials', database.createLiveChildCollection()
    .setQuery('isPartial', {
            $or:
                isPartial: true
                fullPath: $startsWith: config.partialsPath
    })
    .on('add', (model) ->
        docpad.log('debug', util.format(locale.addingPartial, model.getFilePath()))
        model.setDefaults(
            isPartial: true
            render: false
            write: false
        )
    )
)

Parameters:

  • name String

    the name to give to the collection

  • collection Object

    a DocPad collection

setCollections

()

Set the DocPad project's collections

setConfig

(
  • instanceConfig
  • next
)
private

Set the DocPad configuration object. Performs a number of tasks, including merging the pass instanceConfig with DocPad's other config objects. next(err,config)

Parameters:

  • instanceConfig Object
  • next Object
    • err Error
    • config Object

setInstanceConfig

(
  • instanceConfig
)
private

Set the instance configuration by merging the properties of the passed object with the existing DocPad instanceConfig object

Parameters:

  • instanceConfig Object

setLoggers

(
  • loggers
)
Object

Sets the caterpillar logger instances bound to DocPad

Parameters:

  • loggers Object

Returns:

Object:

logger instances bound to DocPad

setLogLevel

(
  • level
)
private

Set the log level

Parameters:

  • level Number

setServer

(
  • servers
)

Set the express.js server and node.js http server to bind to DocPad

Parameters:

  • servers Object

skeleton

(
  • opts
  • next
)
private

Initialize the project directory with the basic skeleton.

Parameters:

  • opts Object
  • next Function
    • err Error

skeletonEmpty

(
  • path
  • next
)
private

Skeleton Empty?

Parameters:

  • path Object
  • next Function
    • err Error

subscribe

(
  • next
)
private

Subscribe to the DocPad email list.

Parameters:

  • next Function
    • err Error

track

(
  • name
  • [things={}]
  • next
)
private

Track

Parameters:

  • name String
  • [things={}] Object optional
  • next Function
    • err Error

trackError

(
  • err
)
private

Track an error in the background

Parameters:

  • err Object

uninstall

(
  • opts
  • next
)
private

Uninstall a plugin.

Parameters:

  • opts Object
  • next Function
    • err Error

uninstallNodeModule

(
  • names
  • opts
  • next
)
private

Uninstall node module. Same as running 'npm uninstall' through the command line

Parameters:

  • names Array
  • opts Object
  • next Function
    • err Error
    • result Object

update

(
  • opts
  • next
)
private

Update the local DocPad and plugin dependencies

Parameters:

  • opts Object
  • next Object
    • err Error

updateUserConfig

(
  • [data={}]
  • next
)

Update user configuration with the passed data

Parameters:

  • [data={}] Object optional
  • next Function
    • err Error

upgrade

(
  • opts
  • next
)
Object private

Update global NPM and DocPad

Parameters:

  • opts Object
  • next Object
    • err Error

Returns:

Object:

description

useSkeleton

(
  • skeletonModel
  • opts
  • next
)
Object private

Use a Skeleton

Parameters:

  • skeletonModel Object
  • opts Object
  • next Object
    • err Error

Returns:

Object:

description

warn

(
  • message
  • err
)
Object

Log an error of level 'warn'

Parameters:

  • message String
  • err Object

Returns:

Object:

description

watch

(
  • opts
  • next
)
private

Start up file watchers used by DocPad

Parameters:

  • opts Object
  • next Function
    • err Error

watchdir

(
  • [opts={}]
)
Object

Watch Directory. Wrapper around the Bevry watchr module (https://github.com/bevry/watchr). Used internally by DocPad to watch project documents and files and then activate the regeneration process when any of those items are updated.

Although it is possible to pass a range of options to watchdir in practice these options are provided as part of the DocPad config object with a number of default options specified in the DocPad config.

Parameters:

  • [opts={}] Object optional
    • [path] String optional

      a single path to watch.

    • [paths] Array optional

      an array of paths to watch.

    • [listener] Function optional

      a single change listener to fire when a change occurs.

    • [listeners] Array optional

      an array of listeners.

    • [next] Function optional

      callback.

    • [stat] Object optional

      a file stat object to use for the path, instead of fetching a new one.

    • [interval=5007] Number optional

      for systems that poll to detect file changes, how often should it poll in millseconds.

    • [catupDelay=200] Number optional

      handles system swap file deletions and renaming

    • [preferredMethods=['watch','watchFile'] Array optional

      which order should we prefer our watching methods to be tried?.

    • [followLinks=true] Boolean optional

      follow symlinks, i.e. use stat rather than lstat.

    • [ignorePaths=false] Boolean | Array optional

      an array of full paths to ignore.

    • [ignoreHiddenFiles=false] Boolean | Array optional

      whether or not to ignored files which filename starts with a ".".

    • [ignoreCommonPatterns=true] Boolean optional

      whether or not to ignore common undesirable file patterns (e.g. .svn, .git, .DS_Store, thumbs.db, etc).

    • [ignoreCustomPatterns=null] Boolean | Array optional

      any custom ignore patterns that you would also like to ignore along with the common patterns.

Returns:

Object:

the watcher

writeFiles

(
  • [opts={}]
  • next
)
private

Write rendered files to the DocPad out directory. The writeBefore and writeAfter events are emitted here.

Parameters:

  • [opts={}] Object optional
  • next Function
    • err Error

Properties

actionRunnerInstance

Object private

The action runner instance bound to docpad

BasePlugin

Object

blocks

Object private

Blocks

Collection

Object

collections

Object private

The DocPad collections

config

Object private

Merged Configuration Merged in the order of:

  • initialConfig
  • userConfig
  • websiteConfig
  • instanceConfig
  • environmentConfig Use getConfig to retrieve this value

corePath

String

The DocPad directory

database

Object private

QueryEngine collection

databaseTempCache FileCollection of models

Object private

A FilesCollection of models updated from the DocPad database after each regeneration.

debugLogPath

String

The DocPad debug log path (docpad-debug.log)

DocumentModel

Object

Document Model class Extension of the File Model class https://github.com/docpad/docpad/blob/master/src/lib/models/document.coffee

ElementsCollection

Object

Collection of elements in a DocPad project Extension of the Collection class https://github.com/docpad/docpad/blob/master/src/lib/collections/elements.coffee

errorRunnerInstance

Object

The error runner instance bound to DocPad

exchange

Object

A listing of all the available extensions for DocPad

FileModel

Object

File Model class Extension of the Model class https://github.com/docpad/docpad/blob/master/src/lib/models/file.coffee

filesByOutPath

Object private

Files by Out Path. Used to speed up conflict detection. Do not use for anything else

filesBySelector

Object private

Files by Selector. Used to speed up fetching

filesByUrl

Object private

Files by url. Used to speed up fetching

FilesCollection

Object

Collection of files in a DocPad project Extension of the QueryCollection class https://github.com/docpad/docpad/blob/master/src/lib/collections/files.coffee

generated

Object private

Has DocPad done at least one generation? True once the first generation has occured.

generateEnded

Boolean private

Has DocPad's generation process ended?

generateStarted

Boolean private

Has DocPad's generation process started?

generating

Boolean private

Is DocPad currently generating?

initialConfig

Object private

Initial Configuration. The default docpadConfig settings that can be overridden in a project's docpad.coffee file. Merged into the config property

initialTemplateData

Object private

Description for initialTemplateData

instanceConfig

Object private

Instance Configuration

libPath

String private

The DocPad library directory

loadedPlugins

Object

Loaded plugins indexed by name

locale

Object private

Determined locale

localePath

String

The DocPad locale path

log

Object

Log arguments

Sub-properties:

  • args... Mixed

loggerInstances

Object private

Internal property. The caterpillar logger instances bound to DocPad

mainPath

String

The main DocPad file

MetaCollection

Object

Collection of metadata in a DocPad project Extension of the ElementsCollection class https://github.com/docpad/docpad/blob/master/src/lib/collections/meta.coffee

Model

Object

packagePath

String

The DocPad package.json path

PluginLoader

Object

Plugin Loader class https://github.com/docpad/docpad/blob/master/src/lib/plugin-loader.coffee Loads the DocPad plugins from the file system into a DocPad project

pluginsTemplateData

Object private

Plugin's Extended Template Data

pluginVersion

String

The plugin version requirements

regenerateTimer

Object private

Regenerate Timer When config.regenerateEvery is set to a value, we create a timer here

ScriptsCollection

Object

Collection of JS script files in a DocPad project Extension of the ElementsCollection class https://github.com/docpad/docpad/blob/master/src/lib/collections/scripts.coffee

serverExpress

Object private

The express.js server instance bound to DocPad. http://expressjs.com

serverHttp

Object private

The Node.js http server instance bound to DocPad https://nodejs.org/api/http.html

skeletonsCollection

Object private

Skeletons Collection

slowPlugins

Object

Plugins that are loading really slow

string array of event names

Array private

Event Listing. String array of event names. Whenever an event is created, it must be applied here to be available to plugins and configuration files https://github.com/bevry/docpad/wiki/Events

string constant

String private

Hash Key The key that we use to hash some data before sending it to our statistic server

StylesCollection

Object

Collection of CSS style files in a DocPad project Extension of the ElementsCollection class https://github.com/docpad/docpad/blob/master/src/lib/collections/styles.coffee

trackRunnerInstance

Object private

The track runner instance bound to DocPad

userConfig

Object private

User Configuraiton Merged into the config property

userConfigPath

String

The User's configuration path (.docpad.cson)

version

Number private

DocPad's version number

watchers

Array private

Array of file watchers

websiteConfig

Object private

Website Configuration Merged into the config property

websitePackageConfig

Object private

Website Package Configuration