module-details
Give it the name of an npm module and get tons of up-to-date details about it. Useful for things like building static documentation sites that reference npm modules.
Last updated 6 years ago by henrikjoreteg .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install module-details 
SYNC missed versions from official npm registry.

module-details

Give it the name of an npm module and get tons of up-to-date details about it. Useful for things like building static documentation sites that reference npm modules.

Turns out, getting JSON about a package from npm is super simple, for example just open this in a browser: http://registry.npmjs.org/slugger

So, this module returns everything you can see there. Plus a few more goodies...

You'll notice that JSON includes the readme, which is awesome! But, if you actually want to render it into a template for a site somewhere you likely want to do a bit more with that readme.

So, what it does it this:

  • Optionally, removes the first header an attaches it to that module data as a title property (npm modules have a name, but no pretty, properly capitalized titles)
  • Hides anything in your readme between <!-- starthide --> and <!-- endhide --> comments you include in your markdown.
    • This is useful for, say, adding a link to the readme saying where the full docs site is.
    • Or hiding other stuff
  • You can also tell it to always hide sections with a certain title. For example, you may be doing this for lots of repos, to merge into a single site and you always want to hide a section in those readmes if they start with license.
  • Creates a property called toc that it built from the headings in your readme. it includes their text content, heading-level, as well as a link text that can be used to embed an anchor to that corresponding heading.
  • Turns all your headings into github-style headings where you hover and they're links to themselves.

install

npm install module-details

example

var getModuleDetails = require('module-details');

// you don't have to send it anything other than a callback
getModuleDetails('slugger', function (err, moduleInfo) {
    // error or moduleInfo
});

// available options and their default settings
var options = {
    sectionsToRemove: [],
    hideFirstHeading: true
};

// you pass options as a second argument
getModuleDetails('slugger', options, function (err, moduleInfo) {
    // error or moduleInfo
});

credits

If you like this follow @HenrikJoreteg on twitter.

license

MIT

Current Tags

  • 2.0.1                                ...           latest (6 years ago)

6 Versions

  • 2.0.1                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 1.1.1                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 3
Dependencies (4)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |