-
Notifications
You must be signed in to change notification settings - Fork 221
Update rdoc to 6.13.1 #2355
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
Update rdoc to 6.13.1 #2355
Conversation
RDoc::{Alias,Attr,AnyMethod,MethodAttr}.new
lib/rbs/annotate/formatter.rb
Outdated
when RDoc::Markup::Document | ||
doc_or_comment | ||
when RDoc::Comment | ||
doc_or_comment.parse |
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 the test code RBS::Annotate::Formatter.translate(something.comment)
should be fixed instead of accepting comment here.
def self.each_part
(in line 60) can be also simplified.
def self.each_part(doc, &block)
if block
- document =
- case doc
- when String
- raise
- when RDoc::Comment
- document = doc.parse
- when RDoc::Markup::Document
- document = doc
- end
+ document = doc
- Formatter.each_part(subject.comment) do |doc|
+ raise if subject.comment.is_a?(String)
+ Formatter.each_part(subject.comment.parse) do |doc|
With some type modification
interface _WithRDocComment
- def comment: () -> (RDoc::Markup::Document | RDoc::Comment | String)
+ def comment: () -> (RDoc::Comment | String)
end
class CodeObject
- attr_reader comment: Markup::Document | Comment | String
+ attr_reader comment: Comment | String
- def comment=: (Markup::Document | Comment | String | nil) -> (Markup::Document | Comment | String)
+ def comment=: (Comment | String | nil) -> (Comment | String | nil)
end
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.
Thanks!
It looks like rbs uses rdoc (and ri) for 2 things:
If that's correct, I'd recommend using Prism to write a simple visitor to index the comments. Here's a good example from Ruby LSP. Since all you need are comments, the implementation could be much simpler than it as you won't need to care about stuff like visibility...etc. It will take some effort but will have a few benefits:
|
@st0012 Thank you for reviewing.
|
Does rbs use rdoc to parse C source code? Or just uses it to retrieve the generated ri data?
I see that makes sense. Interestingly, since ruby-lsp uses rbs to provide Ruby core's documentation, the dependency chain seems to be: ruby-lsp -> rbs -> rdoc. |
I didn’t fully understand before. Writing RDoc documentation into RBS files
Reading RBS file comments as RDoc documentation
We can try it with: |
@ksss Thank you for the summary, this is very helpful 🙏 I wonder if we should move the plugin into |
@st0012 Hi Stan! Moving the plugin to We have So, we should focus if it would benefit the end users, and because the rdoc plugin has a little (maybe zero?) users, the conclusion doesn't looks obvious to me. |
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.
Merge this for now.
We can consider if we can move some parts to RDoc later.
Yeah let's get it merged first and perhaps talk a bit more about future integration during RubyKaigi 😄 |
👍 |
There are several breaking changes in RDoc.
RDoc::Store.new
has been changed.Options
a required constructor argument ofStore
rdoc#1309RDoc::Attr#comment
has been changed fromRDoc::Markup::Document
toRDoc::Comment
.Document
objects asCodeObject#comment
rdoc#1210RDoc::{Alias,Attr,AnyMethod,MethodAttr}.new
has been changedsingleton
) rdoc#1312This PR limits rdoc to 6.13 or higher to support these breaking changes.