Skip to content

Getting Started ESDoc

Yongku cho edited this page Aug 15, 2018 · 2 revisions

Basic

Install

npm install --save-dev esdoc esdoc-standard-plugin

yarn add esdoc esdoc-standard-plugin --dev

Config

.esdoc.json

{
  "source": "./src",
  "destination": "./docs",
  "plugins": [
    {"name": "esdoc-standard-plugin"}
  ]
}

Sample Code

/**
 * this is MyClass.
 */
export default class MyClass {
  /**
   * @param {number} a - this is a value.
   * @param {number} b - this is a value.
   * @return {number} result of the sum value.
   */
  sum(a, b){
    return a + b;
  }
}

Run

./node_modules/.bin/esdoc
open ./docs/index.html

Integrate Test Code

.esdoc.json

{
  "source": "./src",
  "destination": "./docs",
  "plugins": [
  {
    "name": "esdoc-standard-plugin",
    "option": {
      "test": {
        "source": "./test/",
        "interfaces": ["describe", "it", "context", "suite", "test"],
        "includes": ["(spec|Spec|test|Test)\\.js$"],
        "excludes": ["\\.config\\.js$"]
      }
    }
  }]
}

use @test

/** @test {MyClass} */
describe('MyClass has foo bar feature', ()=>{

  /** @test {MyClass#baz} */
  it('MyClass#baz returns magic value', ()=>{
    assert(true);
  });
});

Install

npm i esdoc-ecmascript-proposal-plugin -D

yarn add esdoc-ecmascript-proposal-plugin -D

Config

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

If you want to enable each proposals

{
  "source": "./src",
  "destination": "./doc",
  "plugins": [
    {
      "name": "esdoc-ecmascript-proposal-plugin",
      "option": {
        "classProperties": true,
        "objectRestSpread": true,
        "doExpressions": true,
        "functionBind": true,
        "functionSent": true,
        "asyncGenerators": true,
        "decorators": true,
        "exportExtensions": true,
        "dynamicImport": true
      }
    }
  ]
}
Clone this wiki locally