Clojure functions are documented by adding a string to the function definition, after the function name. This is referred to as the doc string.
def bindings can also be documented to provide context to the data the name is bound to.
Write easily understandable docstringsλ︎
Practically recommends including specific details of the arguments passed to a function and the expected return type. Including this at the end of the docstring makes that information very quick to find.
Reading source codeλ︎
clojure.repl/source will show the source code of a given function, which can be a valuable way to understand the function. Reading function source code also provides ideas when writing custom Clojure code.
Reading the source code for
clojure.core functions is a good way to learn those functions, although some functions have been optimised for performance and are harder to follow.
Writing your own documentationλ︎
Writing good documentation for your own functions take practice which pays off in the long run.
Note::Define your own functionλ︎
Practice writing a meaningful documentation in the doc string
(defn my-function "I should practice writing clear and meaningful documentation for my functions. Arguments: brief description of arguments" [arguments] (str "I should write pure functions where ever possible. " "Each function should have a specific purpose. " "A function should be clean and easy to read."))