From 308c433562362b1519cf6c91e1b17d48749baed4 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Tue, 7 Nov 2023 15:17:58 -0800 Subject: [PATCH] add lein-marginalia ns into uberdoc --- docs/uberdoc.html | 66 +++++++++++++++++++++++++++++++++++++++++++++-- project.clj | 5 ++-- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/docs/uberdoc.html b/docs/uberdoc.html index c3b9db02..abe11e21 100644 --- a/docs/uberdoc.html +++ b/docs/uberdoc.html @@ -2866,7 +2866,69 @@ }; })(SyntaxHighlighter); marginalia -- Marginalia

marginalia

0.9.2-SNAPSHOT


lightweight literate programming for clojure -- inspired by docco

-

dependencies

org.clojure/clojure
1.11.1
org.clojure/clojurescript
1.7.228
org.clojure/tools.namespace
0.2.10
org.clojure/tools.cli
0.3.3
org.markdownj/markdownj
0.3.0-1.0.2b4
de.ubercode.clostache/clostache
1.4.0



(this space intentionally left almost blank)
 

A new way to think about programs

+

dependencies

org.clojure/clojure
1.11.1
org.clojure/clojurescript
1.7.228
org.clojure/tools.namespace
0.2.10
org.clojure/tools.cli
0.3.3
org.markdownj/markdownj
0.3.0-1.0.2b4
de.ubercode.clostache/clostache
1.4.0



(this space intentionally left almost blank)
 
+
(ns leiningen.marg)

Support eval-in-project in both Leiningen 1.x and 2.x.

+
(defn eval-in-project
+  [project form init]
+  (let [[eip two?] (or (try (require 'leiningen.core.eval)
+                            [(resolve 'leiningen.core.eval/eval-in-project)
+                             true]
+                            (catch java.io.FileNotFoundException _))
+                       (try (require 'leiningen.compile)
+                            [(resolve 'leiningen.compile/eval-in-project)]
+                            (catch java.io.FileNotFoundException _)))]
+    (if two?
+      (eip project form init)
+      (eip project form nil nil init))))
+
(def dep ['marginalia "0.9.1"])
+
(defn- add-marg-dep [project]
+  ;; Leiningen 2 is a bit smarter about only conjing it in if it
+  ;; doesn't already exist and warning the user.
+  (if-let [conj-dependency (resolve 'leiningen.core.project/conj-dependency)]
+    (conj-dependency project dep)
+    (update-in project [:dependencies] conj dep)))

Note:

+ +

The docstring for the marg function is used by Leiningen when a +user types lein help marg. Because of this, and because, for +instance, an escaped asterisk in a docstring will cause errors when +you attempt to run lein marg, some extra care (read: hacking) is +required to get this docstring to look reasonable both in the lein +help output and in a marginalia uberdoc.

+

Run Marginalia against your project source files.

+ +

Usage:

+ +
lein marg <options> <files>
+
+ +

Marginalia accepts options as described below:

+ +

-d --dir Directory into which the documentation will be written (default docs)

+ +

-f --file File into which the documentation will be written (default uberdoc.html)

+ +

-n --name Project name (Taken from project.clj by default.)

+ +

-v --version Project version (Taken from project.clj by default.)

+ +

-D --desc Project description (Taken from project.clj by default.)

+ +

-a --deps Project dependencies in the form <group1>:<artifact1>:<version1>;<group2>... + (Taken from project.clj by default.)

+ +

-c --css Additional css resources <resource1>;<resource2>;... + (Taken from project.clj by default.)

+ +

-j --js Additional javascript resources <jsfile1>;<jsfile2>;... + (Taken from project.clj by default.)

+ +

-m --multi Generate each namespace documentation as a separate file

+
(defn marg
+  [project & args]
+  (eval-in-project (add-marg-dep project)
+                   `(binding [marginalia.html/*resources* ""]
+                      (marginalia.core/run-marginalia (list ~@args)))
+                   '(require 'marginalia.core)))
 

A new way to think about programs

What if your code and its documentation were one and the same?

@@ -3669,7 +3731,7 @@

The one true way

(defmulti ns-kw-mm identity)
 (defmethod ns-kw-mm ::foo [_] :problem-cases.general/foo)
 (defmethod ns-kw-mm :user/foo [_] :user/foo)
-(defmethod ns-kw-mm :foo [_] :foo)