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

@author.io/metadoc-api

v1.1.1

Published

Generate a static (read-only) JSON API from metadoc output.

Downloads

21

Readme

metadoc-api

This metadoc post-processor will generate a static (read-only) JSON "API" for browsing metadoc data.

The output is structured in a simple folder that can be uploaded to a static web host. However; since there is no index.html file, it's important to configure your server to use index.json as the default file.

The file structure will always contain:

/path/to/your/output
├─┬ global
│ ├── MyClassA.json
│ ├── MyClassB.json
│ └── …
├─┬ mynamespace
│ ├── MyClassC.json
│ ├── MyClassD.json
│ └── …
├── api.bus.json
├── api.classes.json
├── api.json
├── api.bus.json
├── api.namespaces.json
└── index.json

An example of the index.json (last file) may be:

{
  "full_spec_href": "https://domain.com/4.0.0/api.json",
  "bus_href": "https://domain.com/4.0.0/api.bus.json",
  "exceptions_href": "https://domain.com/4.0.0/api.exceptions.json",
  "class_href": "https://domain.com/4.0.0/api.classes.json",
  "namespace_href": "https://domain.com/4.0.0/api.namespaces.json"
}

Usage

Simply run metadoc-api as a command in the metadoc chain. For example:

metadoc --source ./src --output ./docs | metadoc-api

There are two optional flags: --root (web root) and --version (API version/subfolder).

metadoc --source ./src --output ./docs | metadoc-api --root https://domain.com/ --version 2.0.0

The example above will produce links prefixed with https://domain.com/2.0.0/.

--version auto can be used to automatically identify the version from a local package.json file. The source directory will be searched for a package.json file first, then the current working directory.

Testing Locally

Testing your API locally can be done with any static web host. We recommend using Fenix Web Server.

Fenix Web Server

Fenix will support static hosting and default file modification. Oh, and it's free.

Guiding Principles

This is a read-only/static API, but it attempts to follow reasonable API guidelines. For example, subresources are all identified with a href or _href attribute, allowing API clients to traverse the entire API programmatically.

The API aims to be as simple as possible, but documentation websites are often more complex than they appear. To facilitate the simplest development flow possible, a few helper files are generated and put in the API root:

index.json

This file acts like index.html would in a web server, i.e. the default page served when no other is specified. It contains links to the primary resources documented in the API.

api.json

This is a failsafe file. It contains all of the output from metadoc, in case you can't get the detail you need from anywhere else. WARNING: This file can be really, really big (10K+ lines). Use alternatives whenever possible.

api.bus.json

Remember, metadoc was designed for NGN, which is an object oriented programming library focused around a core event emitter. The bus is an event bus. This file contains all of the events triggered by an event bus. If you're not using NGN, this file may or may not be of use to you.

api.classes.json

This file contains a list of all available classes in the code being documented.

api.exceptions.json

This file contains all of the global/customer exceptions triggered by the code being documented.

api.namespaces.com

This file contains all of the namespaces recognized within the code being documented.