-
Notifications
You must be signed in to change notification settings - Fork 136
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
Eep 48 markdown #1100
Eep 48 markdown #1100
Conversation
Hi @garazdawi ! I guess improving the way documentation is displayed would be a nice thing to do. I just wonder why we'd need to fork the |
You don't sound overly convinced?
I choose to make a copy of the Erlang/OTP implementation for rendering in the shell in order to get some of the basic framework in place. I've redone much of the actual rendering logic as markdown and ansi shells are different in what they need. I started out with the idea of creating a markdown renderer for EEP-48 style documentation in Erlang/OTP. But I think that in order to make the docs look nice, it will have to render different markdown depending on the editor, which leads me to think that this code belongs here instead. If it turns out that I was wrong and no difference was needed for different editors, I'm not opposed to moving it into Erlang/OTP as I would rather maintain them both in one place than two separate versions. |
I am very convinced! I was just wondering if there was any reason for not wanting this, given you asked :) |
My main concern was that it is a lot of code and might increase maintenance while not providing enough benefit. Happy to hear that you would like to have this. I'll spend more time on it and get something that can be merged soon(tm). |
Did some more work. Added documentation lookup for types: Started using edoc chunks (made possible by erlang/otp#2803 in Erlang/OTP 24) for creating docs from edoc: I haven't added so that you get documentation on completion of types (yet). Any hints you have of what has to be changed in els_completion_provider to make it work would be most welcome. I also noticed that Elixir already has done this work, though I think my renderer is a bit more correct/complete. So maybe there is an opportunity to share some code in between the projects. It would have been really neat if you could refer to other files or allow hovering on things within the returned markdown docs so that we could expand the type documentation within the function documentation if the user want that. But it seems like it is not possible. |
b352bec
to
fe65d62
Compare
@garazdawi Let us know when the PR is ready for review! |
Will do. I've added a todo list in the first post so that you can track progress. |
12ec252
to
ad993d4
Compare
ad993d4
to
3bd8d40
Compare
90d26ce
to
120ee00
Compare
I've given up on fixing it so that emacs works properly. There seems to be some strange bug in The only thing remaining is creating testcases for all the new code (and fixing any bugs I find a long the way). So, I would say the code is ready for review! |
When there are multiple versions of the same file we sometimes want to check all of them.
When developing Erlang/OTP all the modules (i.e. lists.erl) show up at least twice so when looking for the EEP-48 style docs we should check all of them in prioritization order for docs and display the first we find.
This makes the -type poi act more like -spec, which is needed for fetching the -type for rendering docs. The builtin types have documentation in 24.2, so we should create pois for them so that we can use that in future versions.
The docs will be create by els_docs instead.
3bb3f88
to
a0fa304
Compare
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.
LGTM (we may found issues later on, but I don't see a problem solving them incrementally).
Only things are support for "-opaque" as H. mentioned and the "missing_spec_all" warning that has been commented out. Otherwise we can merge, unless someone else would like to have an extra review.
I've added tests for most of the things now and addressed the other issues brought up. Tests are missing for:
When I get the CI to pass (just need to fix some linting issues) I think we can merge this and I'll try to find some more time to add more tests. |
There we go, CI passed. Feel free to merge when you want to. Or if you have any more comments for things you want me to address. |
@@ -156,6 +156,8 @@ editable_range(#{kind := type_application, id := {M, T, _A}, range := Range}) -> | |||
EditToC = EditFromC + length(atom_to_string(T)), | |||
els_protocol:range(#{ from => {FromL, EditFromC} | |||
, to => {FromL, EditToC} }); | |||
editable_range(#{kind := type_definition, data := #{ name := Range }}) -> |
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.
It can be addressed as a follow-up, but isn't it a bit counterintuitive to have a range under 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.
naming is hard :)
Thanks so much for this @garazdawi ! 🙏 |
Description
This PR adds a markdown rendering backend for EEP-48 style documentation.
TODO:
atom_to_list/1
for example.In VS code the change looks like this.
Before:
After:
I'm opening this as a draft to get some feedback if this is something you want. If so, there is more work to be done in order to add tests and also check that is actually renders the markdown nicely in most of the editors.