Last active
August 4, 2025 09:54
-
-
Save pmonks/e2449584c4f519672460c3f5fe3dd730 to your computer and use it in GitHub Desktop.
Print the docstrings of all public vars in a namespace, as well as the doctring of the namespace itself
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; | |
; Copyright © 2016 Peter Monks | |
; | |
; This Source Code Form is subject to the terms of the Mozilla Public | |
; License, v. 2.0. If a copy of the MPL was not distributed with this | |
; file, You can obtain one at https://mozilla.org/MPL/2.0/. | |
; | |
; SPDX-License-Identifier: MPL-2.0 | |
; | |
(require '[clojure.repl :refer :all]) | |
(defn ns-docs | |
"Print the docstring of a namespace, and the docstrings of all public vars it | |
contains." | |
[ns-symbol] | |
(when ns-symbol | |
(println ns-symbol) | |
(println "-------------------------") | |
(println " " (:doc (meta (find-ns ns-symbol)))) | |
(run! (comp #'clojure.repl/print-doc meta) | |
(->> ns-symbol | |
ns-publics | |
sort | |
vals)))) | |
; Example usage: | |
(comment | |
(require '[clojure.string]) | |
(ns-docs 'clojure.string) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment