Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

doc

Package Overview
Dependencies
0
Maintainers
2
Versions
3
Issues
File Explorer

Advanced tools

doc

Runtime documentation tool for REPL

    0.0.3latest
    GitHub

Version published
Maintainers
2
Weekly downloads
1,012
increased by12.2%

Weekly downloads

Changelog

Source

0.0.3 / 2013-12-13 ##

  • Export docAsString and docArgsAsArray for third party use

Readme

Source

doc

Runtime documentation tool for REPL.

Usage

Have you ever wished you could see docs for the given function right out of the REPL? If so, this tool is for you!

var doc = require('doc').doc doc(doc) // Prints following output: /* function doc(source) { ... } ----------------------------------------------- Prints documentanion of the given function */ // You can also document your own functions: function compose() { doc: "Returns the composition of a list of functions, where each function" | "consumes the return value of the function that follows. In math" | "terms, composing the functions `f()`, `g()`, and `h()` produces" | "`f(g(h()))`." | "Usage:" | "var greet = function(name) { return 'hi: ' + name }" | "var exclaim = function(statement) { return statement + '!' }" | "var welcome = compose(exclaim, greet)" | "welcome('moe')" | "//> 'hi: moe!'" var funcs = Array.prototype.slice.call(arguments) return function composed() { var args = slice.call(arguments) var i = funcs.length while (0 <= --i) args = [ funcs[i].apply(this, args) ] return args[0] } } doc(compose) // Prints following output: /* function compose() { ... } ----------------------------------------------- Returns the composition of a list of functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Usage: var greet = function(name) { return 'hi: ' + name } var exclaim = function(statement) { return statement + '!' } var welcome = compose(exclaim, greet) welcome('moe') //> 'hi: moe!' */ // Alternative way to documenting functions (Not cross platform though): function sum(a, b) { /** Takes arbitary number of arguments and returns their sum. Usage: sum(7, 2, 8) //> 17 **/ var count = arguments.length, index = 0, value = 0 while (index < count) value += arguments[index++] return value } doc(sum) // Prints following output: /* function sum(a, b) { ... } ----------------------------------------------- Takes arbitary number of arguments and returns their sum. Usage: sum(7, 2, 8) //> 17 */

Install

npm install doc

Keywords

FAQs

Last updated on 13 Dec 2013

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc