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:
titleproperty (npm modules have a name, but no pretty, properly capitalized titles)
<!-- starthide -->and
<!-- endhide -->comments you include in your markdown.
tocthat 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.
npm install module-details
var getModuleDetails = ;// you don't have to send it anything other than a callback;// available options and their default settingsvar options =sectionsToRemove:hideFirstHeading: true;// you pass options as a second argument;
If you like this follow @HenrikJoreteg on twitter.