npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

megadoc-plugin-js

v7.1.0

Published

megadoc plugin for JavaScript sources.

Downloads

722

Readme

megadoc-plugin-js

Build Status

This plugin parses JSDoc3 annotated JavaScript source code files. The parser performs an AST-based analysis of the source files and it tries to infer what it can for you when you leave some parts blank (like function parameter names, property types and names, etc.)

Usage

npm install megadoc megadoc-plugin-js

In your megadoc.conf.js:

exports.plugins = [
  require('megadoc-plugin-js')({
    source: [ 'lib/**/*.js' ]
  })
];

Configuration

See lib/config.js.

Features: supported tags

  • @module
  • @namespace
  • @type
  • @property
  • @param
  • @return
  • @throws
  • @example
  • @interface
  • @memberOf
  • @protected
  • @private
  • @alias
  • @lends

TODO explain these tags.

Features: CommonJS support

Variant 1:

var SomeModule = {};
module.exports = SomeModule;

Variant 2:

var SomeModule = exports;

Variant 3:

module.exports = {
    someProperty: 'a',
    someFunction: function() {
    }
};

Variant 4:

module.exports = function someNamedFunction() {
};

Features: module identification

The parser (and UI) will classify modules into several categories based on how they look like (and how, consequently, their usage is expected to be like.)

Those categories are described below.

Object Modules

A plain object that has no custom prototype and may contain a number of functions and properties.

var SomeModule = {};

SomeModule.someStaticFunction = function() {
};

SomeModule.someStaticProperty = 'a';

Function Modules

Variant 1 - a function declaration expression:

function SomeModule() {}

Variant 2 - a function assigned to a variable:

var SomeModule = function() {}

Variant 3 - a function with static properties:

var SomeModule = function() {};

SomeModule.someStaticFunction = function() {};
SomeModule.someStaticProperty = 'a';

Prototypal Modules (or classes, really)

Any Object that writes something to its prototype is considered a "prototype" module and is expected to be instantiated using the new keyword.

function SomeModule() {
    this.someProperty = 'a';
}

SomeModule.prototype.someMethod = function() {};

// Static functions are supported too:
SomeModule.someStaticFunction = function() {};

// As well as static properties:
SomeModule.staticProp = 'a';

ES6 Classes

class SomeModule {
    static someStaticProperty = 5;
    static someStaticFunction() {
    }

    constructor() {
        this.someProperty = 'a';
    }

    someMethod() {
    }
}

Factory Modules

This is probably the trickiest of the types to classify (and probably the most common in JavaScript), but the parser tries to do its best.

The rule it tries to follow is:

A factory module is any function that returns an object or a function.

function createSomeModule() {
    return {
        someProperty: 'a',
        someMethod: function() {}
    };
}

Variant 2 - assigning to some exported object.

function createSomeModule() {
    let api = {};

    api.someProperty = 'a';
    api.someMethod = function() {}
    };

    return api;
}