-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
cider-doc now renders spec using cider-browse-spec--pprint-indented
#2154
Conversation
@bbatsov This is not ready to be merged yet, it works with eval-buffer but has a compilation error due to dependency cycle. I'm creating the pull request to discuss the solution. The thing is I need to create a button in cider-doc.el that when clicked calls a procedure inside cider-browse-spec.el. Can someone with more experience in elisp help me with this? Thanks |
A screenshot would be helpful: This presentation could be improved. See the existing: |
@xiongtx Don't know why it looks like that, mines looks different : I prefer it to show anonymous functions as functions and not to remove the #, because they look like the spec is invalid. Any idea how to solve that dependency cycle issue? |
Hmm, I'm not sure what's causing the differences. Perhaps @bbatsov can see what results he gets. |
Perhaps I'm missing something, but the first version does look a bit tidier to me. Perhaps we can make it configurable which version to display in the doc buffer? After all I guess the "Browse" button is the most important thing. |
Which version looks tidier? Couldn't be the first one in my post--it doesn't even line up the Anyways, I'd be fine w/ merging what @jpmonettas shows, though I don't think the |
@@ -243,6 +245,14 @@ Display TITLE at the top and SPECS are indented underneath." | |||
(string-join (mapcar #'cider-browse-spec--pprint (cl-rest form)) " ")))))) | |||
(t (format "%s" form)))) | |||
|
|||
(defun cider-browse-spec--pprint-indented (spec-form) |
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.
Seems this can be simplified w/ cider-font-lock-as-clojure
on the pprinted string.
By first, I meant the existing one. I like the nice structural distinction between |
dff7dc1
to
9abc02c
Compare
@bbatsov @xiongtx Just removed the surrounding (s/fspec ...) stuff, now it looks like: The cat looks nicer in our current version because it only has two parts, so we can show it all in one line, but as soon as you have a larger cat line I think it looks nicer to print one part in each line.
I think this too, that's why I created that elisp spec formatter, so we have control and can fine tune how we print a spec instead of relaying on vanilla s/form pprinting. Some time ago I created pretty-spec that uses fipp to pretty print specs sensitive to a width you have defined. Using something like this will require to move pprinting from elisp to cider-nrepl. (I explored those ideas some time ago when writing Inspectable |
(insert "\n")) | ||
(insert "\n")) | ||
(emit "Spec:" 'font-lock-function-name-face) | ||
(insert (cider-browse-spec--pprint-indented spec)) |
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.
Should (require 'cider-browse-spec)
at the top of the 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.
But if I do that I'm getting a dependency cycle :
In toplevel form:
cider-selector.el:35:1:Error: Recursive ‘require’ for feature ‘cider-interaction’
In toplevel form:
cider-inspector.el:32:1:Error: Recursive ‘require’ for feature ‘cider-interaction’
In toplevel form:
cider-debug.el:30:1:Error: Recursive ‘require’ for feature ‘cider-interaction’
In toplevel form:
cider-scratch.el:33:1:Error: Recursive ‘require’ for feature ‘cider-interaction’
In toplevel form:
cider-macroexpansion.el:34:1:Error: Recursive ‘require’ for feature ‘cider-interaction’
In toplevel form:
cider-interaction.el:35:1:Error: Recursive ‘require’ for feature ‘cider-repl’
In toplevel form:
cider-mode.el:35:1:Error: Recursive ‘require’ for feature ‘cider-interaction’
In toplevel form:
cider-apropos.el:28:1:Error: Recursive ‘require’ for feature ‘cider-doc’
In toplevel form:
cider-repl.el:35:1:Error: Recursive ‘require’ for feature ‘cider-doc’
In toplevel form:
cider-browse-spec.el:39:1:Error: Recursive ‘require’ for feature ‘cider-interaction’
In toplevel form:
cider-doc.el:39:1:Error: Recursive ‘require’ for feature ‘cider-browse-spec’
In toplevel form:
cider-browse-ns.el:38:1:Error: Recursive ‘require’ for feature ‘cider-interaction’
In toplevel form:
cider.el:82:1:Error: Recursive ‘require’ for feature ‘cider-repl’
Makefile:42: recipe for target 'test-bytecomp' failed
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.
Try to figure out what's causing the dependency cycle then, and break it. We probably have some unnecessary require
s in some files, or maybe some functions need to be shuffled around.
In any case, you're using cider-browse-spec--...
in cider-doc.el
so you should definitely require
it in cider-doc.el
.
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.
Yeah, was cider-browse-spec depending on cider-interaction, it doesn't need to, so this is fixed.
Yes, removing the |
30211ba
to
a08b8be
Compare
@bbatsov @xiongtx if both agree on the latest screenshot now everything is ready to be merged together with clojure-emacs/cider-nrepl#472
|
I'm fine with it. Just rebase on top of the current |
You should also add some changelog entry. |
6e14ce7
to
32c6243
Compare
@bbatsov added an entry to the changelog and rebased on top of master. |
cider-doc.el
Outdated
(insert-text-button "Browse spec" | ||
'follow-link t | ||
'action (lambda (x) | ||
(cider-browse-spec (format "%s/%s" ns 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 noticed at the build output x
is unused, which I assume is a mistake. It should be just _
if it's not needed.
There is also a button to jump to the browser
32c6243
to
2255173
Compare
There is also a button to jump to the browser
This needs to be merged together with! clojure-emacs/cider-nrepl#472
make test
)M-x checkdoc
warnings