Skip to content

Commit 8ea426e

Browse files
authored
Use bundled ClojureDocs documents (#679)
Now cache updates have to performed explicitly by the clients.
1 parent df6f165 commit 8ea426e

File tree

6 files changed

+14
-20
lines changed

6 files changed

+14
-20
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
* [#667](https://github.com/clojure-emacs/cider-nrepl/pull/667): Filter non file urls from classpath response.
88

9+
### Changes
10+
11+
* [#679](https://github.com/clojure-emacs/cider-nrepl/pull/679): Update to use bundled ClojureDocs documents.
12+
913
## 0.25.2 (2020-06-07)
1014

1115
### Bugs fixed

doc/modules/ROOT/pages/nrepl-api/ops.adoc

-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ Required parameters::
8080
* `:sym` The symbol to lookup.
8181

8282

83-
Optional parameters::
84-
* `:export-edn-url` EDN file URL exported from ClojureDocs. Defaults to "https://clojuredocs-edn.netlify.com/export.compact.edn".
85-
86-
8783
Returns::
8884
* `:clojuredocs` A map of information in ClojureDocs.
8985
* `:status` "no-doc" if there is no document matching to ``ns`` and ``symbol``.

project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:url "http://www.eclipse.org/legal/epl-v10.html"}
66
:scm {:name "git" :url "https://github.com/clojure-emacs/cider-nrepl"}
77
:dependencies [[nrepl "0.7.0"]
8-
^:inline-dep [cider/orchard "0.5.11"]
8+
^:inline-dep [cider/orchard "0.6.0"]
99
^:inline-dep [thunknyc/profile "0.5.2"]
1010
^:inline-dep [mvxcvi/puget "1.3.1"]
1111
^:inline-dep [fipp "0.6.23"] ; can be removed in unresolved-tree mode

src/cider/nrepl.clj

-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@
512512
{:doc "Return a map of information in ClojureDocs."
513513
:requires {"ns" "The namespace where `sym` will be resolved."
514514
"sym" "The symbol to lookup."}
515-
:optional {"export-edn-url" "EDN file URL exported from ClojureDocs. Defaults to \"https://clojuredocs-edn.netlify.com/export.compact.edn\"."}
516515
:returns {"clojuredocs" "A map of information in ClojureDocs."
517516
"status" "\"no-doc\" if there is no document matching to `ns` and `symbol`."}}}})
518517

src/cider/nrepl/middleware/clojuredocs.clj

+6-8
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@
77
[cider.nrepl.middleware.util.error-handling :refer [with-safe-transport]]
88
[orchard.clojuredocs :as docs]))
99

10-
(defn- clojuredocs-lookup-reply [{:keys [export-edn-url ns sym]}]
10+
(defn- clojuredocs-lookup-reply [{:keys [ns sym]}]
1111
(try
12-
(if-let [doc (if export-edn-url
13-
;; TODO: change this to `resolve-doc` once I've added the extra arity there
14-
(docs/resolve-and-find-doc (symbol ns) (symbol sym) export-edn-url)
15-
(docs/resolve-and-find-doc (symbol ns) (symbol sym)))]
12+
;; TODO: change this to `resolve-doc` once I've added the extra arity there
13+
(if-let [doc (docs/resolve-and-find-doc (symbol ns) (symbol sym))]
1614
{:clojuredocs (util/transform-value doc)}
1715
{:status :no-doc})
1816
;; TODO: Handle a missing ns directly in Orchard
19-
(catch Exception e
17+
(catch Exception _
2018
{:status :no-doc})))
2119

2220
(defn clojuredocs-refresh-cache-reply [{:keys [export-edn-url]}]
2321
(docs/clean-cache!)
2422
(if export-edn-url
25-
(docs/load-cache! export-edn-url)
26-
(docs/load-cache!))
23+
(docs/update-cache! export-edn-url)
24+
(docs/update-cache!))
2725
{:status :ok})
2826

2927
(defn handle-clojuredocs [handler msg]

test/clj/cider/nrepl/middleware/clojuredocs_test.clj

+3-6
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@
2424
(testing "Searching for non-existing documentation"
2525
(let [response (session/message {:op "clojuredocs-lookup"
2626
:ns "non-existing"
27-
:sym "non-existing"
28-
:export-edn-url test-url})]
27+
:sym "non-existing"})]
2928
(is (contains? (:status response) "no-doc"))))
3029

3130
(testing "Searching for existing documentation"
3231
(let [response (session/message {:op "clojuredocs-lookup"
3332
:ns "clojure.core"
34-
:sym "first"
35-
:export-edn-url test-url})
33+
:sym "first"})
3634
doc (get response :clojuredocs {})]
3735
(is (contains? (:status response) "done"))
3836
(is (= "clojure.core" (:ns doc)))
@@ -42,8 +40,7 @@
4240
(testing "Resolves syms in the supplied ns"
4341
(let [response (session/message {:op "clojuredocs-lookup"
4442
:ns "cider.nrepl.middleware.clojuredocs-test"
45-
:sym "map"
46-
:export-edn-url test-url})
43+
:sym "map"})
4744
doc (get response :clojuredocs {})]
4845
(is (contains? (:status response) "done"))
4946
(is (= "clojure.core" (:ns doc)))

0 commit comments

Comments
 (0)