Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send Clojure 'doc' output through pager?

Tags:

clojure

The docstrings for some Clojure functions (e.g. defrecord) are quite long. When running Clojure at in a terminal window, I'd like to be able to in effect send doc's output through a pager such as more (or less). If someone has written a pager function in Clojure, then I think I could use it along with something like:

(with-out-str (doc defrecord))

Or if there is a standard Java class that implements a pager, I can figure out how to send the output to that.

Alternatively, how can I send the output of doc to a shell command? This doesn't do the job:

(clojure.java.shell/sh "more" :in (with-out-str (doc defrecord))))

[This topic is difficult to search: "more", "less", and "doc" are obviously very common terms, and things like "java pager" bring up pages discussing ways to break text up into pages for formatting documents.]

like image 861
Mars Avatar asked Dec 05 '25 13:12

Mars


1 Answers

echo "(doc defrecord)" |clj|more 
like image 186
Diego Basch Avatar answered Dec 07 '25 17:12

Diego Basch