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

tern-node-api-doc

v0.0.5

Published

Tern plugin for generating Node.js API docs on the fly and associating them with the correct modules and functions in Tern

Downloads

19

Readme

tern-node-api-doc

A plugin for generating Node.js API docs on-the-fly and associating them with the corresponding modules and functions in the tern JavaScript code analysis engine.

It's currently only useful when you are using tern to edit or analyze the node.js standard library itself.

Why? Node.js API documentation exists in external Markdown files, not in docstrings embedded in the code. This plugin lets tern parse the Markdown documentation and associate it with the corresponding module, function, or variable. Without this plugin, if you use tern to edit or analyze the node.js standard library, most things will not have associated documentation.

Documentation on Sourcegraph

Build Status status authors Total views

Usage

git clone git://github.com/sourcegraph/tern-node-api-doc.git

Install dependencies

Run npm install to fetch tern.

Configure for use with tern

The plugin requires 3 paths to be specified as configuration options in your .tern-project file:

  • apiDocDir: the directory containing node.js API documentation (doc/api in the node.js git repository).
  • apiSrcDir: the directory containing the node.js API modules (lib/ in the node.js git repository).
  • generateJSPath: the path to the tools/doc/generate.js script in the node.js git repository.

The easiest way to satisfy these requirements is to clone the github.com/joyent/node repository. If you cloned it to /home/alice/node, then you would use the following configuration:

{
  "apiDocDir": "/home/alice/node/doc/api",
  "apiSrcDir": "/home/alice/node/lib",
  "generateJSPath": "/home/alice/node/tools/doc/generate.js"
}

With tern's condenser

To use this plugin with tern's condenser, specify the configuration on the command line as the following example demonstrates.

$ node_modules/tern/bin/condense --plugin node-api-doc='{"apiDocDir":"testdata/doc/api","apiSrcDir":"testdata/lib","generateJSPath":"testdata/tools/doc/generate.js"}' --plugin node --plugin doc_comment testdata/lib/foo.js

The output is:

{
  "!name": "testdata/lib/foo.js",
  "!define": {
    "!node": {
      "testdata/lib/foo`js": {
        "fizz": {
          "!type": "fn()",
          "!span": "8[0:8]-12[0:12]",
          "!doc": "<p>Fizzes the foo.\n\n</p>\n"
        },
        "Bar": {
          "zip": {
            "!type": "fn(pow: ?)",
            "!span": "118[9:4]-121[9:7]",
            "!doc": "<p>Zips the pow.\n\n</p>\n"
          },
          "prototype": {
            "baz": {
              "!type": "fn(string: ?, offset: ?)",
              "!span": "192[13:14]-195[13:17]",
              "!doc": "<p>Bazzes the bar.\n\n</p>\n<p>See <code>bar.length</code> above.\n\n</p>\n"
            }
          },
          "!type": "fn(arg: ?)",
          "!span": "58[3:8]-61[3:11]",
          "!doc": "<p>Bar is a class.\n\n</p>\n"
        },
        "Bar2": {
          "!type": "fn()",
          "!span": "78[5:8]-82[5:12]",
          "!doc": "<p>A second Bar.\n</p>\n"
        },
        "CON": {
          "!type": "number",
          "!span": "255[16:8]-258[16:11]",
          "!doc": "<p>A bar constant.\n\n</p>\n"
        }
      }
    }
  }
}

All of the docstrings came from external Markdown files in the testdata/doc/api directory.

Running tests

Run npm test.

Authors

Contributions are welcome! Submit a GitHub issue or pull request.