Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including docs-for with all npm packages installed. Try it out:

var docsFor = require("docs-for")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

docs-for v0.0.2

Find and display the docs for a package in your current node project.

docs-for

Build Status

This node module is a response to a common need I found when developing node projects: needing to see the documentation of the other modules I was using. This was usually a multi-step process: open a browser, search for the module and find its homepage. docs-for tries to make it go faster.

docs-for accepts a string input and will search upwards in the directory structure for a package.json file. It will then look for the best module name match for the name given, find that module's package, use it to locate the most likely url for documentation and try to open it in a web browser.

Because of the naming conventions of modules the best module name match is (in order): exact match, tail match, head match, body match.

Usage

Command Line

This module loads two executables docs-for and the alias docs4. These will try to load the docs for a package in your current node project if you are anywhere in the project hierarchy.

Example

docs4 lodash
# opens a browser window for https://lodash.com/

docs4 comm
# opens a browser window (tab) for https://github.com/tj/commander.js

Module

Find the closest thing to a documentation url for a module in a local node project. Accepts a string for the module name or a configuration object, with:

  • name - the name or partial name of the module
  • from - the directory from which to start the search for the module, defaults to the current process directory

Example

var docs4 = require('docs-for');

docs4('grunt', function(err, url){
  console.log('The documentation url for grunt is:', url);
});


docs4({
  name : 'foo',
  from : '~/myprojects/foo-bar' // look in an alternative project 
}, function(err, url){
  if(err) console.error(err);
  else console.log('The documentation url for foo is:', url);
});
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free