danielgtaylor / nesh

An enhanced, extensible interactive shell for Node.js and CoffeeScript
http://danielgtaylor.github.io/nesh/
MIT License
288 stars 27 forks source link

Adding nesh-doc plugin as a default plugin, automatically enabled #13

Closed ccheever closed 10 years ago

ccheever commented 10 years ago

Shows some documentation for an expression; invoke it by typing Ctrl-Q inline after an expression

Ex.

    nesh> process.on<Ctrl-Q>
    [Function] (type, listener)

Hit Ctrl-Q twice to see more information, ex. the entire source code in the case of a function.

Ex.

    nesh> process.on
    [Function] (type, listener)
    function (type, listener) {
          if (isSignal(type) &&
              !signalWraps.hasOwnProperty(type)) {
            var Signal = process.binding('signal_wrap').Signal;
            var wrap = new Signal();
    ...

You can also invoke it with the .doc keyword.

Ex.

    nesh> .doc process.on
    [Function] (type, listener)

This works for all objects, but is most useful for functions and sometimes classes. I'm planning to write up a document about how to annotate your code in a way that the doc module can understand if you want to make your source more readable that way, but doing that isn't required for this plugin to be useful. The most useful thing is usually just quick access to what parameters a function expects.

danielgtaylor commented 10 years ago

I have to admit I'm not a huge fan of pulling in extra dependencies, but this plugin is so fantastically useful that I think we should ship it by default. I'm already finding it useful after just a few minutes of playing with it. Thanks for writing it!

I'm going to merge this in and do some updates to the docs so that we advertise these new commands.