-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add finding docs functionality from ClojureDocs #64
Conversation
007eac0
to
445e785
Compare
src/orchard/clojuredocs.clj
Outdated
@@ -0,0 +1,35 @@ | |||
(ns orchard.clojuredocs | |||
"Find docs from ClojureDocs and retrieve the result as a map." | |||
{:author "Masashi Iizuka"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add to the metadata that the namespace was added in version 0.5.
src/orchard/clojuredocs.clj
Outdated
(defn- map-from-key [f coll] | ||
(reduce #(assoc %1 (f %2) %2) {} coll)) | ||
|
||
(defn update-documents-cache! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can just name this update-cache!
, as it's clear from the namespace which cache we are referring to.
src/orchard/clojuredocs.clj
Outdated
(reset! cache)) | ||
true)) | ||
|
||
(defn find-document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can't come up with a better name here, as the word document
implies something else. Perhaps find-doc
(for documentation
). Can't think of a great name, but names are important.
Apart from my small remarks the changes look good to me. I just wonder if now we should replace the usage of the |
It would be nice to carry this along with the info as well, given this is cached it's probably going to have a reasonable performance. We are loading the full 2.8M string into memory with the |
445e785
to
6de9db7
Compare
@bbatsov Thank you for your reviewing! |
The patch looks good to me apart from the slurp of the whole thing which we could maybe do lazily ad hoc if we had a different data format (one file per ClojureDocs entry?). Could be an optimization for later. On another note we should potentially merge this to https://github.com/cljs/api for ClojureScript support. |
src/orchard/clojuredocs.clj
Outdated
|
||
Return nil if there is no matching document." | ||
{:added "0.5.0"} | ||
[export-edn-file ns-name var-name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One final remark - I think here edn-file
should be an optional param, as we know the default location of the file after it's downloaded and specifying it explicitly all the time seems redundant to me.
src/orchard/clojuredocs.clj
Outdated
A EDN format file is expected to the `export-edn-file` argument. | ||
(e.g. https://clojuredocs-edn.netlify.com/export.edn)" | ||
{:added "0.5.0"} | ||
[export-edn-file] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make this param optional and load the cache straight from the default url.
@liquidz After reading the code once more I thought of something else - it'd be nice if we were saving the export file locally, so it could be loaded directly on future invocations of Orchard. We can add some |
@bbatsov I thought to do that on the editor plugin side. How about to save the file in |
Yeah, that sounds good to me. |
https://github.com/soc/directories-jvm even if not used, should have it's methods ported, in order to properly support windows & mac properly. |
@SevereOverfl0w Thanks! |
01edbb5
to
571f9bd
Compare
@bbatsov @SevereOverfl0w Fixed! I tested |
src/orchard/directory.clj
Outdated
@@ -0,0 +1,67 @@ | |||
(ns orchard.directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this namespace should be named in some more generic way (provided we want to keep there os-related functionality). Maybe orchard.os
or orchard.platform
? Not sure how this is typically named.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like orchard.os
shorter!
src/orchard/misc.clj
Outdated
@@ -3,8 +3,19 @@ | |||
[clojure.java.io :as io] | |||
[clojure.string :as str])) | |||
|
|||
(def os-name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can put the os-* in the new namespace as well. We'll just keep the existing functions here for compatibility and deprecate them.
src/orchard/directory.clj
Outdated
:added "0.5.0"} | ||
(:require [clojure.java.io :as io] | ||
[clojure.string :as str] | ||
[orchard.misc :as u]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think misc
is a better alias than u
. :-) The weird aliases in the codebase today are due to the fact that this namespace was named util
in cider-nrepl (if I recall correctly that is).
571f9bd
to
e707c3a
Compare
@bbatsov Thank you for your reviewing! I fixed them! |
Great work! I'll cut a new beta now, so you can update |
Hmm, seems I pushed beta-9 from my other PC without doing |
0.5.0-beta10 is out! |
Thanks! I'll create a PR to cider-nrepl. |
PR for clojure-emacs/cider#2663
Introduce finding docs functionality from not Grimoire but ClojureDocs