CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-esdoc-ecmascript-proposal-plugin

A ECMAScript proposal plugin for ESDoc

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

ESDoc ECMAScript Proposal Plugin

ESDoc ECMAScript Proposal Plugin enables parsing of experimental ECMAScript proposals in JavaScript documentation generation. This ESDoc plugin extends the parser capabilities to support cutting-edge language features that are not yet part of the official ECMAScript specification.

Package Information

  • Package Name: esdoc-ecmascript-proposal-plugin
  • Package Type: npm
  • Language: JavaScript (Node.js)
  • Installation: npm install esdoc-ecmascript-proposal-plugin
  • Node.js Version: >= 6.0.0
  • License: MIT

Core Imports

This package exports a singleton Plugin instance for ESDoc integration:

// ESDoc automatically loads the plugin - no direct imports needed
// Plugin is configured through ESDoc's configuration system
// Main export: module.exports = new Plugin()

The plugin integrates with ESDoc through the plugin system rather than direct imports. The package exports a single instance of the Plugin class, not the class itself.

Basic Usage

Configure the plugin in your ESDoc configuration file to enable all experimental features:

{
  "source": "./src",
  "destination": "./doc",
  "plugins": [
    {"name": "esdoc-ecmascript-proposal-plugin", "option": {"all": true}}
  ]
}

For selective feature enablement:

{
  "source": "./src",
  "destination": "./doc",
  "plugins": [
    {
      "name": "esdoc-ecmascript-proposal-plugin",
      "option": {
        "classProperties": true,
        "objectRestSpread": true,
        "decorators": true
      }
    }
  ]
}

Capabilities

Plugin Export

The package exports a singleton Plugin instance that integrates with ESDoc's event system.

/**
 * ESDoc plugin singleton instance that enables experimental ECMAScript proposals
 * This is the main export from the package: module.exports = new Plugin()
 */
const pluginInstance = {
  /**
   * Event handler called by ESDoc during code parsing phase
   * Modifies parser options to enable experimental language features
   * @param {Object} ev - ESDoc event object
   * @param {Object} ev.data.option - Plugin configuration options
   * @param {Array} ev.data.parserOption.plugins - Parser plugins array to modify
   * @returns {void}
   */
  onHandleCodeParser(ev) { /* implementation in src/Plugin.js */ }
};

Configuration Options

The plugin accepts configuration through ESDoc's option system:

/**
 * Plugin configuration options passed through ESDoc's option system
 * @typedef {Object} PluginOptions
 * @property {boolean} [all] - Enable all experimental features at once
 * @property {boolean} [classProperties] - Enable class properties proposal
 * @property {boolean} [objectRestSpread] - Enable object rest/spread operators
 * @property {boolean} [doExpressions] - Enable do expressions
 * @property {boolean} [functionBind] - Enable function bind operator
 * @property {boolean} [functionSent] - Enable function.sent meta property
 * @property {boolean} [asyncGenerators] - Enable async generators
 * @property {boolean} [decorators] - Enable decorators
 * @property {boolean} [exportExtensions] - Enable export extensions
 * @property {boolean} [dynamicImport] - Enable dynamic import()
 */

Supported Experimental Features

The plugin enables parsing of the following ECMAScript proposals:

Class Properties

Enables parsing of class property declarations:

class MyClass {
  myProperty = 'value';
  static staticProperty = 'static value';
}

Object Rest/Spread

Enables parsing of object rest and spread operators:

const {a, ...rest} = obj;
const newObj = {...obj, newProperty: 'value'};

Do Expressions

Enables parsing of do expressions:

const value = do {
  if (condition) 'yes';
  else 'no';
};

Function Bind

Enables parsing of function bind operator (::):

obj::func();
const boundFunc = obj::func;

Function.sent

Enables parsing of function.sent meta property:

function* gen() {
  console.log(function.sent);
}

Async Generators

Enables parsing of async generator functions:

async function* gen() {
  yield await Promise.resolve(1);
}

Decorators

Enables parsing of decorator syntax:

@decorator
class MyClass {
  @methodDecorator
  method() {}
}

Export Extensions

Enables parsing of export extensions:

export v from 'module';

Dynamic Import

Enables parsing of dynamic import() expressions:

const module = await import('./module.js');

Integration

ESDoc Plugin System

The plugin integrates with ESDoc through the event-driven plugin system:

  • Event: onHandleCodeParser - Called during code parsing phase
  • Purpose: Modifies parser configuration to enable experimental features
  • Implementation: Adds feature names to the parser plugins array

Parser Configuration

The plugin modifies ESDoc's parser options by:

  1. Reading plugin configuration from ev.data.option
  2. Accessing parser plugins array from ev.data.parserOption.plugins
  3. Adding experimental feature names as strings to enable parsing

Configuration Patterns

Enable All Features:

{"name": "esdoc-ecmascript-proposal-plugin", "option": {"all": true}}

Selective Feature Enablement:

{
  "name": "esdoc-ecmascript-proposal-plugin",
  "option": {
    "classProperties": true,
    "objectRestSpread": true
  }
}

No Configuration (No Features Enabled):

{"name": "esdoc-ecmascript-proposal-plugin"}

Install with Tessl CLI

npx tessl i tessl/npm-esdoc-ecmascript-proposal-plugin

docs

index.md

tile.json