0.1.2 • Published 8 years ago

esdoc-classlift-plugin v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

esdoc-classlift-plugin

AST modifier for ES2015 classes defined within a default export

description

lift out your ES2015 Class declaration from an export default statement to generate valid ESDoc for your class.

primarily designed to assist in documenting classes in Angular 1.x.

reasoning

the plugin is for those who dont want:

  • to store references to angular dependencies on instances of my class.
  • to involve the usage of Map or WeakMap for angular dependencies.

and for those who do want:

  • typeof checks to work™.
  • services to return a constructor function, not an instance.

limitations

only default exports and class declarations are supported for now. named exports and 'returned class expressions' could appear if there's interest in such functionality.

installation

$ npm install esdoc-classlift-plugin --save-dev

usage

In your esdoc configuration:

{
  "plugins": [
    { "name": "esdoc-classlift-plugin" },
  ]
}

In ES2015 land:

/**
 * @classlift
 */
export default function AngularDIWrapperFn ($q) {
  /**
   * Class: Foo
   */
  class Foo {
    constructor () {}

    bar () {
      return $q.reject('bar!');
    }
  }

  return Foo;
}

license

mit @ kasper lewau