Docpad Class
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
- action
- addCollection
- addModel
- addModels
- attachModelEvents
- checkRequest
- clean
- compareVersion
- constructor
- contextualizeFiles
- createDocument
- createError
- createFile
- createModel
- createModels
- createProgress
- createRegenerateTimer
- destroy
- destroyBlocks
- destroyCollection
- destroyCollections
- destroyDatabase
- destroyLoggers
- destroyPlugins
- destroyProgress
- destroyRegenerateTimer
- destroyServer
- destroyWatchers
- eachBlock
- eachCollection
- emitParallel
- emitSerial
- error
- extendCollections
- fatal
- fixNodePackageVersions
- generate
- getActionRunner
- getBlock
- getBlocks
- getCollection
- getCollections
- getConfig
- getConfigPath
- getDatabase
- getDatabaseSafe
- getDebugging
- getEnvironment
- getEnvironments
- getErrorRunner
- getEvents
- getExchange
- getFile
- getFileAtPath
- getFileById
- getFileByRoute
- getFileBySelector
- getFileByUrl
- getFiles
- getFilesAtPath
- getHostname
- getIgnoreOpts
- getLocale
- getLogger
- getLoggers
- getLogLevel
- getPlugin
- getPort
- getProcessPlatform
- getProcessVersion
- getServer
- getServerUrl
- getSimpleServerUrl
- getSkeletons
- getTemplateData
- getTrackRunner
- getUrlPathname
- getVersion
- getVersionString
- hasPlugins
- identify
- init
- initGitRepo
- initInstall
- initNodeModules
- initSkeleton
- inspector
- install
- installNodeModule
- installSkeleton
- isIgnoredPath
- load
- loadAndRenderDocument
- loadConfigPath
- loadConfigUrl
- loadDocument
- loadedPlugin
- loadLocale
- loadPlugin
- loadPlugins
- loadPluginsIn
- logError
- mergeConfigurations
- notify
- notifyError
- parseDirectory
- parseDocumentDirectory
- parseFileDirectory
- ready
- render
- renderData
- renderDocument
- renderFiles
- renderPath
- renderText
- resetCollections
- run
- scandir
- selectSkeleton
- serveDocument
- server
- serverMiddleware404
- serverMiddleware500
- serverMiddlewareHeader
- serverMiddlewareRouter
- setBlock
- setBlocks
- setCollection
- setCollections
- setConfig
- setInstanceConfig
- setLoggers
- setLogLevel
- setServer
- skeleton
- skeletonEmpty
- subscribe
- track
- trackError
- uninstall
- uninstallNodeModule
- update
- updateUserConfig
- upgrade
- useSkeleton
- warn
- watch
- watchdir
- writeFiles
Properties
- actionRunnerInstance
- BasePlugin
- blocks
- Collection
- collections
- config
- corePath
- database
- databaseTempCache FileCollection of models
- debugLogPath
- DocumentModel
- ElementsCollection
- errorRunnerInstance
- Events
- exchange
- FileModel
- filesByOutPath
- filesBySelector
- filesByUrl
- FilesCollection
- generated
- generateEnded
- generateStarted
- generating
- initialConfig
- initialTemplateData
- instanceConfig
- libPath
- loadedPlugins
- locale
- localePath
- log
- loggerInstances
- mainPath
- MetaCollection
- Model
- packagePath
- PluginLoader
- pluginsTemplateData
- pluginVersion
- QueryCollection
- regenerateTimer
- ScriptsCollection
- serverExpress
- serverHttp
- skeletonsCollection
- slowPlugins
- string array of event names
- string constant
- StylesCollection
- trackRunnerInstance
- userConfig
- userConfigPath
- version
- watchers
- websiteConfig
- websitePackageConfig
Methods
action
-
args
Apply the passed DocPad action arguments
Parameters:
-
args
Object
Returns:
addCollection
-
collection
Add a collection
Parameters:
-
collection
Object
addModel
-
model
-
opts
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
Objecteither a plain object defining the required properties, in particular the file path or an actual model object
-
opts
Object
Returns:
the model
addModels
-
models
-
opts
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
ObjectDocPad collection of models
-
opts
Object
Returns:
the models
attachModelEvents
-
model
Attach events to a document model.
Parameters:
-
model
Object
checkRequest
-
next
Check Request
Parameters:
-
next
Function-
err
Error -
res
Object
-
clean
-
opts
-
next
DocPad cleanup tasks.
Parameters:
-
opts
Object -
next
Object-
err
Error
-
Returns:
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
Functioncallback
-
err
Error
-
contextualizeFiles
-
[opts={}]
-
next
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={}]
Create document model. Calls DocPad/createModel:method with the 'document' modelType.
Parameters:
-
[attrs={}]
Object optional -
[opts={}]
Object optional
Returns:
DocumentModel
createError
-
err
-
opts
Create an error object
Parameters:
-
err
Object -
opts
Object
Returns:
the error
createFile
-
[attrs={}]
-
[opts={}]
Create file model. Calls DocPad/createModel:method with the 'file' modelType.
Parameters:
-
[attrs={}]
Object optional -
[opts={}]
Object optional
Returns:
FileModel
createModel
-
[attrs={}]
-
[opts={}]
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
Stringthe full path to the file
-
-
[opts={}]
Object optional-
modelType
Stringeither 'file' or 'document'
-
Returns:
the file or document model
createModels
-
models
-
opts
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
ObjectDocPad collection of models
-
opts
Object
Returns:
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:
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
Destroy a collection by collection name or key
Parameters:
-
value
String
Returns:
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
Destructor. Destroy the progress object
Parameters:
-
progress
Object
Returns:
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
Emit event, parallel
Parameters:
-
eventName
String -
opts
Object -
next
Function-
err
Error
-
emitSerial
-
eventName
-
opts
-
next
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
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
Handle a fatal error
Parameters:
-
err
Object
fixNodePackageVersions
-
opts
-
next
Fix node package versions Combat to https://github.com/npm/npm/issues/4587#issuecomment-35370453
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:
the action runner instance
getBlock
-
name
-
[clone]
Get a block by block name. Optionally clone block.
Parameters:
-
name
String -
[clone]
Object optional
Returns:
block
getBlocks
()
Object
Get all blocks
Returns:
collection of blocks
getCollection
-
value
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:
collection
getCollections
()
Object
Get the DocPad project's collections
Returns:
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:
the DocPad configuration object
getConfigPath
-
opts
-
next
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:
getDebugging
()
Boolean
Are we debugging?
Returns:
getEnvironment
()
String
Get the DocPad environment, eg: development, production or static
Returns:
the environment
getEnvironments
()
Array
Get the environments
Returns:
array of environment strings
getErrorRunner
()
Object
Get the error runner instance
Returns:
the error runner instance
getEvents
()
Object
Get the list of available events
Returns:
string array of event names
getExchange
-
next
Get DocPad's exchange data Requires internet access next(err,exchange)
Parameters:
-
next
Function-
err
Error -
exchange
Objectdocpad.exchange
-
getFile
-
query
-
sorting
-
paging
Get a single file based on a query
Parameters:
-
query
Object -
sorting
Object -
paging
Object
Returns:
a file
getFileAtPath
-
path
-
sorting
-
paging
Get a file at a relative or absolute path or url
Parameters:
-
path
String -
sorting
Object -
paging
Object
Returns:
a file
getFileById
-
id
-
[opts={}]
Get a file by its id
Parameters:
-
id
String -
[opts={}]
Object optional
Returns:
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={}]
Get a file by its selector
Parameters:
-
selector
Object -
[opts={}]
Object optional
Returns:
a file
getFileByUrl
-
url
-
[opts={}]
Get a file by its url
Parameters:
-
url
String -
[opts={}]
Object optional
Returns:
a file
getFiles
-
query
-
sorting
-
paging
Get all the files in the DocPad database (will use live collections)
Parameters:
-
query
Object -
sorting
Object -
paging
Object
Returns:
collection
getFilesAtPath
-
path
-
sorting
-
paging
Get files at a path
Parameters:
-
path
String -
sorting
Object -
paging
Object
Returns:
files
getHostname
()
String
Get the Hostname
Returns:
getIgnoreOpts
()
Array
Get the ignore options for the DocPad project
Returns:
string array of ignore options
getLocale
()
Object
Get the locale (language code and locale code)
Returns:
locale
getLogger
()
Object
Get the caterpillar logger instance bound to DocPad
Returns:
caterpillar logger
getLoggers
()
Object
Get all the caterpillar logger instances bound to DocPad
Returns:
collection of caterpillar loggers
getLogLevel
()
Number
Get the log level
Returns:
the log level
getPlugin
-
pluginName
Get a plugin by it's name
Parameters:
-
pluginName
Object
Returns:
a DocPad plugin
getPort
()
Number
Get the port that DocPad is listening on (eg 9778)
Returns:
the port number
getProcessPlatform
()
Object
Get the process platform
Returns:
getProcessVersion
()
String
Get the process version string
Returns:
getServer
-
[both=false]
Get the DocPad express.js server instance and, optionally, the node.js https server instance
Parameters:
-
[both=false]
Boolean optional
Returns:
getServerUrl
-
[opts={}]
Get address
Parameters:
-
[opts={}]
Object optional
Returns:
getSimpleServerUrl
-
[opts={}]
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:
getSkeletons
-
next
Get Skeletons Get all the available skeletons with their details and return this collection to the supplied callback.
Parameters:
-
next
Function-
err
Error -
skeletonsCollection
ObjectDocPad collection of skeletons
-
Returns:
DocPad skeleton collection
getTemplateData
-
userTemplateData
Get Complete Template Data
Parameters:
-
userTemplateData
Object
Returns:
templateData
getTrackRunner
()
Object
Get the track runner instance
Returns:
the track runner instance
getUrlPathname
-
url
Remove the query string from a url Pathname convention taken from document.location.pathname
Parameters:
-
url
String
Returns:
getVersion
()
Number
Get the DocPad version number
Returns:
getVersionString
()
String
Get the DocPad version string
Returns:
hasPlugins
()
Boolean
Check if we have any plugins
Returns:
identify
-
next
Identify DocPad user
Parameters:
-
next
Function-
err
Error
-
init
-
opts
-
next
Initialize the project directory with the basic skeleton.
Parameters:
-
opts
Object -
next
Object-
err
Error
-
Returns:
description
initGitRepo
-
opts
-
next
Initialise git repo
Parameters:
-
opts
Object -
next
Function-
err
Error -
results
Object
-
initInstall
-
opts
-
next
Initialize the skeleton install process.
Parameters:
-
opts
Object -
next
Function-
err
Error
-
initNodeModules
-
opts
-
next
Init node modules
Parameters:
-
opts
Object -
next
Function-
err
Error -
results
Object
-
initSkeleton
-
skeletonModel
-
opts
-
next
Initialize a Skeleton into to a Directory
Parameters:
-
skeletonModel
Object -
opts
Object -
next
Function-
err
Error
-
inspector
-
obj
-
opts
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:
JSON string of passed object
install
-
opts
-
next
Install a plugin
Parameters:
-
opts
Object -
next
Function-
err
Error
-
installNodeModule
-
names
-
opts
-
next
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
Install a Skeleton into a Directory
Parameters:
-
skeletonModel
Object -
opts
Object -
next
Function-
err
Error
-
isIgnoredPath
-
path
-
[opts={}]
Is the supplied path ignored?
Parameters:
-
path
String -
[opts={}]
Object optional
Returns:
load
-
instanceConfig
-
next
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
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
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
Load the locale
Parameters:
-
code
String
Returns:
locale
loadPlugin
-
fileFullPath
-
_next
Load a plugin from its full file path _next(err)
Parameters:
-
fileFullPath
String -
_next
Function-
err
Error
-
Returns:
description
loadPlugins
-
next
Load plugins from the file system next(err)
Parameters:
-
next
Function-
err
Error
-
loadPluginsIn
-
pluginsPath
-
next
Load plugins from a directory path
Parameters:
-
pluginsPath
String -
next
Function-
err
Error
-
logError
-
err
Log an error
Parameters:
-
err
Object
mergeConfigurations
-
configPackages
-
configsToMerge
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
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
Objectfiles 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
Objectfiles collection of documents
-
parseFileDirectory
-
[opts={}]
-
next
Parse the files directory and return a files collection to the passed callback
Parameters:
-
[opts={}]
Object optional -
next
Functioncallback
-
err
Error -
files
Objectfiles collection
-
ready
-
[opts]
-
next
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
Objectthe 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
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
Objectthe rendered document
-
renderText
-
text
-
opts
-
next
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
Objectthe rendered content
-
document
Objectthe rendered document model
-
resetCollections
-
opts
-
next
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
Select a Skeleton
Parameters:
-
opts
Object -
next
Function-
err
Error -
skeletonModel
Error
-
serveDocument
-
opts
-
next
Serve a document
Parameters:
-
opts
Object -
next
Function-
err
Error
-
server
-
opts
-
next
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
Server Middleware: 404
Parameters:
-
req
Object -
res
Object -
next
Object
serverMiddleware500
-
err
-
req
-
res
-
next
Server Middleware: 500
Parameters:
-
err
Object -
req
Object -
res
Object -
next
Function
serverMiddlewareHeader
-
req
-
res
-
next
Server Middleware: Header
Parameters:
-
req
Object -
res
Object -
next
Object
serverMiddlewareRouter
-
req
-
res
-
next
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
Stringthe name to give to the collection
-
collection
Objecta DocPad collection
setCollections
()
Set the DocPad project's collections
setConfig
-
instanceConfig
-
next
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
Set the instance configuration by merging the properties of the passed object with the existing DocPad instanceConfig object
Parameters:
-
instanceConfig
Object
setLoggers
-
loggers
Sets the caterpillar logger instances bound to DocPad
Parameters:
-
loggers
Object
Returns:
logger instances bound to DocPad
setLogLevel
-
level
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
Initialize the project directory with the basic skeleton.
Parameters:
-
opts
Object -
next
Function-
err
Error
-
skeletonEmpty
-
path
-
next
Skeleton Empty?
Parameters:
-
path
Object -
next
Function-
err
Error
-
subscribe
-
next
Subscribe to the DocPad email list.
Parameters:
-
next
Function-
err
Error
-
track
-
name
-
[things={}]
-
next
Track
Parameters:
-
name
String -
[things={}]
Object optional -
next
Function-
err
Error
-
trackError
-
err
Track an error in the background
Parameters:
-
err
Object
uninstall
-
opts
-
next
Uninstall a plugin.
Parameters:
-
opts
Object -
next
Function-
err
Error
-
uninstallNodeModule
-
names
-
opts
-
next
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
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
Update global NPM and DocPad
Parameters:
-
opts
Object -
next
Object-
err
Error
-
Returns:
description
useSkeleton
-
skeletonModel
-
opts
-
next
Use a Skeleton
Parameters:
-
skeletonModel
Object -
opts
Object -
next
Object-
err
Error
-
Returns:
description
warn
-
message
-
err
Log an error of level 'warn'
Parameters:
-
message
String -
err
Object
Returns:
description
watch
-
opts
-
next
Start up file watchers used by DocPad
Parameters:
-
opts
Object -
next
Function-
err
Error
-
watchdir
-
[opts={}]
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 optionala single path to watch.
-
[paths]
Array optionalan array of paths to watch.
-
[listener]
Function optionala single change listener to fire when a change occurs.
-
[listeners]
Array optionalan array of listeners.
-
[next]
Function optionalcallback.
-
[stat]
Object optionala file stat object to use for the path, instead of fetching a new one.
-
[interval=5007]
Number optionalfor systems that poll to detect file changes, how often should it poll in millseconds.
-
[catupDelay=200]
Number optionalhandles system swap file deletions and renaming
-
[preferredMethods=['watch','watchFile']
Array optionalwhich order should we prefer our watching methods to be tried?.
-
[followLinks=true]
Boolean optionalfollow symlinks, i.e. use stat rather than lstat.
-
[ignorePaths=false]
Boolean | Array optionalan array of full paths to ignore.
-
[ignoreHiddenFiles=false]
Boolean | Array optionalwhether or not to ignored files which filename starts with a ".".
-
[ignoreCommonPatterns=true]
Boolean optionalwhether or not to ignore common undesirable file patterns (e.g. .svn, .git, .DS_Store, thumbs.db, etc).
-
[ignoreCustomPatterns=null]
Boolean | Array optionalany custom ignore patterns that you would also like to ignore along with the common patterns.
-
Returns:
the watcher
writeFiles
-
[opts={}]
-
next
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
Base class for all DocPad plugins https://github.com/docpad/docpad/blob/master/src/lib/plugin.coffee
blocks
Object
private
Blocks
Collection
Object
Collection class Extension of the Backbone Collection class https://github.com/docpad/docpad/blob/master/src/lib/base.coffee http://backbonejs.org/#Collection
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
Model class Extension of the Backbone Model class http://backbonejs.org/#Model https://github.com/docpad/docpad/blob/master/src/lib/base.coffee
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
QueryCollection
Object
QueryCollection class Extension of the Query Engine QueryCollection class https://github.com/docpad/docpad/blob/master/src/lib/base.coffee https://github.com/bevry/query-engine/blob/master/src/documents/lib/query-engine.js.coffee
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
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