Skip to content
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

Show documentation in hover window #73

Merged
merged 1 commit into from
Jan 1, 2022

Conversation

shocoman
Copy link
Contributor

I think this is an important feature for any programming tool to have.
Maybe there is a less insane approach to get that documentation text (though if there was, probably it would be implemented already), but I just parse it with html-parsing lib, extract relevant pieces of the documentaion for the selected element, convert this pieces of html into a Markdown string, and put that Markdown in hover response.
Demonstration:

demo.mp4

Looks surprisingly decent.

I've tried to make generated Markdown as human-readable as possible (in general, Markdown can be extremely human unreadable), so even if the used text editor doesn't support Markdown (for some incomprehensible reason), it still should be fairly usable. Here is an example of generated Markdown and how it would look in VS Code

And I've also fixed a couple of small bugs.

  1. Links that contain a closing paren ()) aren't rendered correctly in Atom (because Atom's Md parser treats it as a link 'delimiter'). Now the links are encoded properly.
    Screenshot with the bug:
    bug1

  2. Currently links aren't constructed correctly if the documentation is not in a usual place (by usual I mean something like C:/Program Files/Racket/doc/...). For example, on Ubuntu, when Racket is installed from the default packet manager (i.e. apt install racket), docs are located in /usr/share/doc/racket/.... The problem here is that racket part goes after doc. The current approach was to simple split path by /doc/ and I've just changed it to simply splittling by /doc/(racket/)?, which is enough for this particular case.
    That kinda fixes Unable to get document for symbols imported from racket #72.
    Screenshot with the bug:
    bug2

  3. I really don't know why, but sometimes URLs come without url-tags (like #(def._((quote._~23~25kernel)._hasheq))), but 'raw' tags (i.e. '(def ((quote #%kernel) hasheq))) are still there. I've solved it by additionaly converting this 'raw' tags into url-tags when original url-tags are not present.
    Screenshot with the bug:
    bug3

I hope I did everything right, never programmed anything significant in lisp.

Copy link
Owner

@jeapostrophe jeapostrophe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty cool :)

@jeapostrophe jeapostrophe merged commit a1141f0 into jeapostrophe:master Jan 1, 2022
@jeapostrophe
Copy link
Owner

Great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to get document for symbols imported from racket
2 participants