Git Product home page Git Product logo

npm-doc's Introduction

npm-doc

An asynchronous fetcher of npm package documentation.

Installation

npm install npm-doc

Usage

Packages can be specified in three ways:

  • A package name (i.e. "npm" or "dropbox")
  • An array of package names (i.e. ["npm"] or ["connect", "express", "dnode"])
  • An object of package name:version pairs (i.e. {"npm-doc": "0.0.1", "oauth": "0.8.3"})

In the absence of specific version information, the docs of the latest versions are fetched.

Examples

var doc = require("npm-doc");

// Note that getDocs wouldn't normally be called in sequence like this.
// Packages can be specified by...

// ...a single package name.
doc.getDocs("npm", function (err, data) {
  if (err) console.error(err.stack);
  else console.log(data);
});

// ...an array of package names.
doc.getDocs(["npm", "express", "socket.io"] , function (err, data) {
  if (err) console.error(err.stack);
  else console.log(data);
});

// ... or an object of name:version pairs.
doc.getDocs({"oauth": "0.8.0", "jade": "0.5.6"}, function (err, data) {
  if (err) console.error(err.stack);
  else console.log(data);
});

The returned data available to the callback is an object that maps package names to nested objects containing docs. Doc objects are of the format:

{ docs: <Object containing names and text of doc markdown files>,
  README: <Text of README markdown file>
}

Thus, fetching docs for npm would yield:

{ npm:
  { docs:
    { activate: ...
      adduser: ...
      build: ...
      ...
    }
    , README: ...
  }
}

Uninstallation

npm uninstall npm-doc

TODO

  • Toggle logging.
  • Remove object argument format in favor of an array of name@version strings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.