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

mia

v0.3.0

Published

A flexible documentation generator and source code parser.

Downloads

7

Readme

Mia - JavaScript Documentation Generator

Mia is a customizable documentation generator for JavaScript based on esprima.

Note: Mia is still in alpha status, right now it only comes with a few basic modules for parsing standard, prototypical code and it's own doc format.

Mia provides enhancements to the AST which are used by (custom) parser modules to generate documentation for all kind of different JavaScript patterns and conventions.

It tries to be open minded about the source code it is parsing and not make any particular assumptions about structure or style.

How it works

Mia works in 3 steps:

  1. It parses the JavaScript source and creates a enhanced AST with additional informations about scopes and comments
  2. It calls the user specificed parsers to detect exports, source structures and annotations
  3. It merges the generated data and returns a JSON structure with all the information

Usage

First Mia needs to parse the code in question, this is done by calling mia.parse() and specifying the parsers to be run over the source.

var mia = require('mia'),
    fs = require('fs');

var source = fs.readFileSync('source.js').toString();
var module = mia.parse(
    'Module', // Name of the module
    source, 
    {
        module: ['iife'], // Detect standard anonymous function wrappers
        source: ['prototypical'], // Detect standrad prototypical classes
        annotation: ['mia'] // Use mia annotations
    }
);

module will be a serializable JSON structure which contains all information returned by the different parsers. An example can be found in this gist.

While the structure already contains all the required information to build documentation from it, the data is still not combined in a template friendly way.

By calling mia.generate() with the module and the matching generator a nicer structure can be generated which is easy to work with using standard template engines.

var template = mia.generate(module, 'mia');

Parsers

Below is a list of the parsers Mia currently ships with.:

  • Source Parsers

    • prototypical

      • Detects classes, factories, members, static members and functions as well as prototypical inheritance and super calls to methods and constructors
  • Module Parsers

    • iife

      • Detects exports from immediately invoked function expression / anonymous wrapper
    • amd

      • Detects exports from asynchronous module definitions
    • node

      • Detects standard Node.js exports
  • Annotation Parsers

    • mia

      • Parses Mia's own - lightweight - doc format.

It is easy to extend as you can just pass your custom functions to Mia instead of a parser name.

Generators

The following generators are currently included:

  • mia

    • Works perfectly with results from the built-in parsers, but should also work fine with most custom parsers.

License

Mia is licenses under MIT.