I agree with @uvtc that markdown is a nice choice. As an addendum, I'd like to note that it is trivial to generate your own markdown doc viewing function for use at the REPL. The following code assumes you have the markdown-clj package on your classpath (e.g. via dev dependencies), and are using a REPL in OSX:
(ns docs
(:require [clojure.java.shell :as s]
[markdown.core :as md]))
(defmacro opendoc [name]
`(do
(md/md-to-html (java.io.StringReader. (:doc (meta (var ~name)))) "/tmp/doc.html")
(s/sh "open" "/tmp/doc.html")
)
)
You might want to look at the source for clojure.repl/doc to handle special cases (e.g. this one assumes you'll be passing in a proper symbol for a var). It might also be nice to have the filename reflect the namespace/function name for "caching", instead of just reusing the same filename for every request...but I'm keeping it simple for illustration purposes.
The OSX open
command simply asks the OS to open a file by detecting its type. Thus:
REPL=> (docs/opendoc my.ns/f)
will cause your default browser to open the HTMLified version of your function's docstring.
One other caveat: If you indent your multiline string (which editors commonly do), then your MD may end up with weirdness (e.g. bullet lists might nest in a way you do not intend). One way to solve this is to trim that back out. For example:
(defn boo
"
# Title
My thing
* Item one
* Item two
"
[args] ...)
and then modify the opendoc function to first apply a left trim:
(defn ltrim [str] (clojure.string/replace str #"(?m)^ {0,3}" ""))
(defmacro opendoc [name]
`(do
(md/md-to-html (java.io.StringReader. (ltrim (:doc (meta (var ~name))))) "/tmp/doc.html")
(s/sh "open" "/tmp/doc.html")
)
)