-
Notifications
You must be signed in to change notification settings - Fork 178
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
Support document link for Rails documentation #285
Conversation
3b54e29
to
1dfb2dd
Compare
a7858d5
to
96704f8
Compare
This is looking great. One final detail: do we need to pull in VCR and webmock for testing it? Would we be able to use a Minitest stub and avoid adding the dependencies? I don't foresee the LSP having too many API requests, so I'm not sure adding the dependencies will pay off. |
b039b7b
to
31b7e2a
Compare
@vinistock Given the additional logic on processing and filtering the dataset, I want the request's tests to be as realistic as possible. And in that case, the options we have are:
I'm ok with doing 1 instead, but I also don't think it's a big problem having |
I think we will probably not be using VCR or webmock anywhere other than this one method in document links. That's why I feel like something like this would be simpler fake_docs = {
"belogs_to" => ...
}
RubyLsp::Requests::DocumentLink.stub(:rails_documents, fake_docs) do
RubyLsp::Requests::DocumentLink.new(document).run
end |
@vinistock As I said, I don't just want to test it agains a fake hash. The thing we got from |
Agreed that there's a lot of value in that, but you can also achieve it with a stub, no? Net::Http.stub(:get_response, js_content) do
...
end
``` |
Yes and I've mentioned that I'm ok with that:
I'm only against testing it with a hash directly |
492248f
to
bc210a1
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.
Two questions that came up while testing this
- Is there an option for placing the link on top of the hover documentation? These Rails methods have a lot of documentation and we end up having to scroll through a lot before finding the links
- Is there a way of disabling cmd click for document links only? Maybe some VS Code configuration? Right now, if you cmd click a method with links you jump to the browser and Sorbet jumps to the RBI file at the same time
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.
This is really cool so far! I left some questions and a suggestion!
3a955f0
to
f54712d
Compare
I tophatted this again and it's looking great, I'm really excited for it. The one thing I think we need to find a decent solution for is the overlap of this feature with go to definition by Sorbet. Right now, CMD + click will perform both operations at the same time. You get redirected to the browser with the documentation and when you come back to the editor you're suddenly in the RBI file. Two possible ideas, but we need to validate that the experience is decent
|
In terms of the But it looks like |
In Rails, there are too many classes/modules that can define common method names like `#to_s`, like `ActiveController::Parameters#to_s`, which has documentation but is usually not what the user is calling. But becaues of the lack of typing information, `ruby-lsp` can't really determine if the document is marked on the right method. So Rails document link on general method calls can have a high inaccuracy and become counter-productive. Therefore, this commit disables marking `Call` nodes and only focuses on DSL method calls (`Command` nodes).
Close in favour of #313 |
…pt-eslint/eslint-plugin-5.42.1 Bump @typescript-eslint/eslint-plugin from 5.42.0 to 5.42.1
Motivation
Closes #258
Implementation
Automated Tests
Manual Tests
TODOs
activerecord
's documents when the file is under amodels/
folder.activesupport
andactionview
actionpack
,activemodel
, andactivestorage
Demo