Documentation and Resources
John Gabriele
1 The Main Clojure Docs
The Clojure website provides numerous reference articles on their Documentation page. There’s also a terrific cheatsheet there (which includes a link at the top to enhanced cheatsheets with tooltips). More docs are listed on the Clojure Community page.
For API documentation (with user-submitted examples and comments), see ClojureDocs. The official API docs are at http://clojure.github.io/.
2 Other Docs
- Brave Clojure
- http://mbonaci.github.io/clojure/ (from Jan 2014)
- https://github.com/jafingerhut/thalia
- Clojure Style Guide
- Clojure Doc Site
- The Confluence wiki is an enterprise wiki + communication medium for core developers. It contains a number of useful pages.
3 Built-in Docstrings
Clojure (like Python) supports docstrings. These are strings embedded in the source code of functions for the purpose of documenting them. You can interactively access the docstrings (at the repl) like so:
(doc some-func) ; docstring for this function
(doc some.namespace) ; docs for the namespace itself
(doc some.namespace/some-func) ; using fully-qualified name
To see a listing of what’s available in a given namespace, use:
(dir the.namespace)
You can also search the docstrings using (find-doc #"search string")
. Note that the string inside #""
is a regex.
4 The Source
You can see the source code for any Clojure function right at the repl, for example:
(source repeat)
5 Library Source
When searching for documentation on a given library, consider reading the source. Look in ~/.m2/repository for the jars. To open one up, you might do this:
mkdir ~/temp/some-src
cp ~/.m2/repository/path/to/bar-1.0.0.jar ~/temp/some-src
cd ~/temp/some-src
jar xvf bar-1.0.0.jar
To generate docs from library source code, see Generating Docs from Libraries.
6 Example Code
For example code, you can always read the source code files of Clojure itself (download and look in clojure-i.j.k/src/clj/clojure). You might also look at contrib and 3rd-party libraries (see available libraries).
More examples:
- https://github.com/wagjo/hangman
- https://bitbucket.org/drcabana/euler/overview
- http://rosettacode.org/wiki/Category:Clojure
- The Clojure section at http://pleac.sourceforge.net/
7 Java Documentation
It will sometimes be useful to look up documentation on various Java standard classes. You could download and install the full Java API docs onto your own system (and will probably want to at some point), but for now you can access those docs at: http://docs.oracle.com/javase/8/docs/api/.