Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add JSDoc for all events #3313

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Data/TemplateData.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ class TemplateData {
return folders;
}

/**
* @fires "eleventy.globalDataFiles"
*/
async getAllGlobalData() {
let globalData = {};
let files = TemplatePath.addLeadingDotSlashArray(await this.getGlobalDataFiles());
Expand Down Expand Up @@ -373,6 +376,9 @@ class TemplateData {
}

/* Template and Directory data files */
/**
* @fires "eleventy.dataFiles"
*/
async combineLocalData(localDataPaths) {
let localData = {};
if (!Array.isArray(localDataPaths)) {
Expand Down
22 changes: 20 additions & 2 deletions src/Eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,14 @@ class Eleventy {
/**
* Starts Eleventy.
*
* @fires "eleventy.config"
* @fires "eleventy.env"
* @fires "eleventy.extensionmap"
* @fires "eleventy.directories"
*
* @async
* @method
* @returns {} - tbd.
* @param {object} [options={}]
* @void
*/
async init(options = {}) {
options = Object.assign({ viaConfigReset: false }, options);
Expand Down Expand Up @@ -769,6 +774,9 @@ Arguments:
/**
* tbd.
*
* @fires "eleventy.templateModified"
* @fires "eleventy.resourceModified"
*
* @private
* @method
* @param {String} changedFilePath - File that triggered a re-run (added or modified)
Expand Down Expand Up @@ -833,6 +841,9 @@ Arguments:
/**
* tbd.
*
* @fires "eleventy.beforeWatch"
* @fires "eleventy.reset"
*
* @private
* @method
*/
Expand Down Expand Up @@ -1064,6 +1075,10 @@ Arguments:
/**
* Start the watching of files
*
* @listens "change"
* @listens "add"
* @listens "unlink"
*
* @async
* @method
*/
Expand Down Expand Up @@ -1208,6 +1223,9 @@ Arguments:
/**
* tbd.
*
* @fires "eleventy.before"
* @fires "eleventy.after"
*
* @async
* @method
* @returns {Promise<{}>} ret - tbd.
Expand Down
3 changes: 3 additions & 0 deletions src/EleventyFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ class EleventyFiles {
return this._templateData;
}

/**
* @fires "eleventy.ignores"
*/
setupGlobs() {
this.fileIgnores = this.getIgnores();
this.extraIgnores = this._getIncludesAndDataDirs();
Expand Down
4 changes: 4 additions & 0 deletions src/EleventyServe.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ class EleventyServe {
return this._eleventyConfig;
}


/**
* @listens "eleventy.passthrough"
*/
set eleventyConfig(config) {
this._eleventyConfig = config;
if (checkPassthroughCopyBehavior(this._eleventyConfig.userConfig, "serve")) {
Expand Down
5 changes: 5 additions & 0 deletions src/EleventyWatchTargets.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ class EleventyWatchTargets {
this.writer = templateWriter;
}

/**
* @fires "eleventy.importCacheReset"
*
* @param {string[]} filePathArray
*/
clearImportCacheFor(filePathArray) {
let paths = new Set();
for (const filePath of filePathArray) {
Expand Down
2 changes: 2 additions & 0 deletions src/Engines/Custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import getJavaScriptData from "../Util/GetJavaScriptData.js";
import eventBus from "../EventBus.js";

let lastModifiedFile = undefined;

/** @listens "eleventy.resourceModified" */
eventBus.on("eleventy.resourceModified", (path) => {
lastModifiedFile = path;
});
Expand Down
6 changes: 6 additions & 0 deletions src/Engines/Nunjucks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class Nunjucks extends TemplateEngine {
this.cacheable = true;
}

/**
* @fires "eleventy.engine.njk"
*/
_setEnv(override) {
if (override) {
this.njkEnv = override;
Expand Down Expand Up @@ -61,6 +64,9 @@ class Nunjucks extends TemplateEngine {
});
}

/**
* @listens "eleventy.resourceModified"
*/
setLibrary(override) {
this._setEnv(override);

Expand Down
3 changes: 3 additions & 0 deletions src/GlobalDependencyMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class GlobalDependencyMap {
this._map = undefined;
}

/**
* @listens "eleventy.layouts" (once)
*/
setConfig(config) {
if (this.config) {
return;
Expand Down
4 changes: 4 additions & 0 deletions src/Plugins/I18nPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ function getLocaleUrlsMap(urlToInputPath, extensionMap, options = {}) {
return urlMap;
}

/**
* @listens "eleventy.extensionmap"
* @listens "eleventy.contentMap"
*/
function EleventyPlugin(eleventyConfig, opts = {}) {
let options = DeepCopy(
{
Expand Down
6 changes: 6 additions & 0 deletions src/Plugins/InputPathToUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ function normalizeInputPath(inputPath, inputDir, contentMap) {
return inputPath;
}

/**
* @listens "eleventy.contentMap"
*/
function FilterPlugin(eleventyConfig) {
let contentMap;
eleventyConfig.on("eleventy.contentMap", function ({ inputPathToUrl }) {
Expand All @@ -45,6 +48,9 @@ function FilterPlugin(eleventyConfig) {
});
}

/**
* @listens "eleventy.contentMap"
*/
function TransformPlugin(eleventyConfig, defaultOptions = {}) {
let opts = Object.assign(
{
Expand Down
4 changes: 4 additions & 0 deletions src/Plugins/RenderPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,12 @@ async function renderShortcodeFn(fn, data) {
* string (or file) inside of another template. {@link https://www.11ty.dev/docs/plugins/render/}
*
* @since 1.0.0
*
* @param {module:11ty/eleventy/UserConfig} eleventyConfig - User-land configuration instance.
* @param {Object} options - Plugin options
*
* @listens "eleventy.config"
* @listens "eleventy.extensionmap"
*/
function EleventyPlugin(eleventyConfig, options = {}) {
/**
Expand Down
1 change: 1 addition & 0 deletions src/TemplateCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class TemplateCache {

let layoutCache = new TemplateCache();

/** @listens "eleventy.resourceModified" */
eventBus.on("eleventy.resourceModified", (path, usedBy, metadata = {}) => {
// https://github.com/11ty/eleventy-plugin-bundle/issues/10
if (metadata.viaConfigReset) {
Expand Down
3 changes: 3 additions & 0 deletions src/TemplateConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class TemplateConfig {

/**
* Resets the configuration.
* @fires "eleventy.compileCacheReset"
*/
async reset() {
debugDev("Resetting configuration: TemplateConfig and UserConfig.");
Expand Down Expand Up @@ -381,6 +382,8 @@ class TemplateConfig {
/**
* Merges different config files together.
*
* @fires "eleventy.beforeConfig"
*
* @param {String} projectConfigPath - Path to project config.
* @returns {{}} merged - The merged config file.
*/
Expand Down
9 changes: 8 additions & 1 deletion src/TemplateContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,8 @@ class TemplateContent {

TemplateContent._inputCache = new Map();
TemplateContent._compileCache = new Map();

/** @listens "eleventy.resourceModified" */
eventBus.on("eleventy.resourceModified", (path) => {
// delete from input cache
TemplateContent.deleteFromInputCache(path);
Expand All @@ -673,7 +675,12 @@ eventBus.on("eleventy.resourceModified", (path) => {
}
});

// Used when the configuration file reset https://github.com/11ty/eleventy/issues/2147
/**
* Used when the configuration file reset.
* @see https://github.com/11ty/eleventy/issues/2147
*
* @listens "eleventy.compileCacheReset"
*/
eventBus.on("eleventy.compileCacheReset", (/*path*/) => {
TemplateContent._compileCache = new Map();
});
Expand Down
4 changes: 4 additions & 0 deletions src/TemplateMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ class TemplateMap {
}
}

/**
* @fires "eleventy.contentMap"
* @fires "eleventy.layouts"
*/
async cache() {
debug("Caching collections objects.");
this.collectionsData = {};
Expand Down
6 changes: 5 additions & 1 deletion src/TemplatePassthrough.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,14 @@ class TemplatePassthrough {
return paths;
}

/* Types:
/**
* Types:
* 1. via glob, individual files found
* 2. directory, triggers an event for each file
* 3. individual file
*
* @listens copy.events.COPY_FILE_START
* @listens copy.events.COPY_FILE_COMPLETE
*/
async copy(src, dest, copyOptions) {
if (
Expand Down
1 change: 1 addition & 0 deletions src/TemplatePassthroughManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class TemplatePassthroughManager {
// Performance note: these can actually take a fair bit of time, but aren’t a
// bottleneck to eleventy. The copies are performed asynchronously and don’t affect eleventy
// write times in a significant way.
/** @fires "eleventy.passthrough" */
async copyAll(templateExtensionPaths) {
debug("TemplatePassthrough copy started.");
let normalizedPaths = this.getAllNormalizedPaths(templateExtensionPaths);
Expand Down
2 changes: 2 additions & 0 deletions src/Util/Require.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ async function loadContents(path, options = {}) {
}

let lastModifiedPaths = new Map();

/** @listens "eleventy.importCacheReset" */
eventBus.on("eleventy.importCacheReset", (fileQueue) => {
for (let filePath of fileQueue) {
let absolutePath = TemplatePath.absolutePath(filePath);
Expand Down