Micah Elliott
Micah Elliott

Reputation: 10264

Built-in help text (not html) documentation for Racket xrepl

I’m running racket as a repl (with xrepl), and I’m able to use ,doc to see some relevant documentation (almost awesome), but it fires up a web browser to see the documentation. I’d like to be able to see the docs right in the repl, similarly to how it’s presented in other repls (R, Clojure, ipython, pry, etc). Is this possible?

E.g., in Clojure’s lein repl, one can do:

user=> (doc map)
-------------------------
clojure.core/map
([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])
  Returns a lazy sequence consisting of the result of applying ...

It would also be great to be able to see source ((source map) in clojure), but I haven’t seen any hints of this being available.

I happen to be using Vim (with slime/tmux), so any Vim-based solution would also work, probably tied to its K built-in help.

Upvotes: 3

Views: 193

Answers (2)

Micah Elliott
Micah Elliott

Reputation: 10264

I put together VROD, a solution that parses the reference documentation into something that Vim can work with. This provides essentially what you can get from clojure's doc built-in help, but through Vim’s K-help. And it also does some highlighting and shows examples.

(It also happens to do auto-completion of functions.)

Upvotes: 0

Greg Hendershott
Greg Hendershott

Reputation: 16250

I'm not sure this is practical given the nature of Racket documentation.

  • The help deliverable is HTML.

  • Unlike Clojure (or Emacs Lisp), Racket doesn't have doc strings in the function definition source.

  • Racket docs don't have a convention like the one that the first line of a doc string should be a summary (a short-version to use in situations like a list of commands or in a REPL).

You can try xrepl's ,desc <id> command. Starting in Racket 6.1.1, if the function has installed documentation, it will print a rendering of the "blue box" -- the function signature with contracts and/or types. In many cases that's all you need, say to jog your memory. However there is no text describing the item. And if there is no installed help for a function, it won't attempt to show you anything based on the function's definition source.

So for example in racket-mode for Emacs, there is a racket-describe command and it does not fire up a browser -- but it shows the full HTML help (if any) using shr in a separate Emacs buffer. If there is no help, it does try to find the source and extract a contract/type and signature to show you. But again, there is no doc string in that source, to find, much less a one-line summary to show neatly in a REPL.


There are vim fans using Racket; the ones I know are use evil-mode in Emacs and feel it's the best of both worlds. However I appreciate that's not your current workflow using multiple languages, so I'm not proposing that as the solution for you.

Upvotes: 2

Related Questions