An enhanced Clojure documentation facility that provides better docs than doc with richer formatting, multiple output formats, and comprehensive Babashka support.
clj-info modernizes Clojure documentation with:
doc functionLeiningen/Boot:
[clj-info "0.5.1"]
Clojure CLI/deps.edn:
clj-info/clj-info {:mvn/version "0.5.1"}
Babashka bb.edn:
{:deps {clj-info/clj-info {:mvn/version "0.5.1"}}}
(require '[clj-info :as ci])
;; Basic documentation (enhanced version of `doc`)
(ci/info map)
(ci/info reduce)
(ci/info String)
;; Function version for programmatic use
(ci/info* 'filter)
(ci/info* 'clojure.core/assoc)
Beautiful ANSI-colored output with structured formatting:
(require '[clj-info :as ci]
'[clj-info.doc2rich :as rich]
'[clj-info.doc2map :as doc-map])
;; Rich formatted output with colors and borders
(print (rich/doc->rich (doc-map/get-docs-map 'map)))
Perfect for documentation systems, wikis, and README files:
(require '[clj-info.doc2md :as md])
;; Generate Markdown
(md/doc->md (doc-map/get-docs-map 'reduce))
;; Save to file
(spit "function-docs.md" (md/doc->md (doc-map/get-docs-map 'map)))
Structured data for tooling and programmatic consumption:
(require '[clj-info.doc2data :as data])
;; JSON export
(data/doc->json (doc-map/get-docs-map 'filter))
;; EDN export
(data/doc->edn (doc-map/get-docs-map 'assoc))
clj-info works seamlessly in both JVM Clojure and Babashka environments:
# Start interactive Babashka nREPL server with clj-info loaded
bb bb_nrepl_server.clj
# Or use directly in Babashka scripts
bb -e "(require '[clj-info :as ci]) (ci/info map)"
The library automatically detects the runtime environment and adapts accordingly:
clj-info.platform/bb?sci.lang.Var(info symbol) - Macro version, no quoting needed(info* 'symbol) - Function version for programmatic use(tdoc symbol) - Text documentation (legacy compatibility)(rich/doc->rich doc-map) - Rich ANSI terminal formatting(md/doc->md doc-map) - Markdown generation(data/doc->json doc-map) - JSON export(data/doc->edn doc-map) - EDN export(doc-map/get-docs-map 'symbol) - Raw documentation map;; Rich terminal output
(ci/info map)
(ci/info reduce)
(ci/info filter)
;; Compare with standard doc
(doc map) ; Plain text
(ci/info map) ; Rich formatted
;; Generate documentation for multiple functions
(require '[clj-info.doc2md :as md]
'[clj-info.doc2map :as doc-map])
(defn export-function-docs [functions filename]
(->> functions
(map #(md/doc->md (doc-map/get-docs-map %)))
(clojure.string/join "\n\n---\n\n")
(spit filename)))
(export-function-docs '[map reduce filter assoc] "core-functions.md")
;; Generate JSON documentation for API consumption
(require '[clj-info.doc2data :as data])
(defn api-doc-endpoint [function-name]
{:status 200
:headers {"Content-Type" "application/json"}
:body (data/doc->json (doc-map/get-docs-map (symbol function-name)))})
# JVM Clojure
lein test
# Babashka
bb test_bb.clj
# Start nREPL server with clj-info loaded
bb bb_nrepl_server.clj
# Connect with your favorite editor/client
lein repl :connect 7888
Copyright (C) 2011-2024 Frank Siebenlist
Distributed under the Eclipse Public License 1.0, the same as Clojure uses. See the file COPYING.
Can you improve this documentation? These fine people already did:
FrankS & franks42Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |