-
Notifications
You must be signed in to change notification settings - Fork 441
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
Use Ripper for lexical analyser #512
Conversation
def a, b, # comment c end This is valid definition of method with a comment inside args. This commit fixes behavior for it.
Remove String#match? and heredoc with ">>~".
I warry about Rails using forked SDoc and it has wrong behavior (those are fixed original repository of SDoc, 1 and 2). @zzak: I want to join SDoc collaborators and RubyGems owners for fix some trouble in the future, and it's just an aside, let's talk about some documentations in the future. @amatsuda and/or other Rails committers: This SDoc problem is so severe for replacement lexical analyser with Ripper because RDoc crashes with this Pull Request certainly until now, especially about this monkey patch. I think that Rails should use original SDoc as new version. |
My years-long dream come true |
} && $~ | ||
line | ||
end.join("\n") | ||
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.
Too bad expand_tab doesn't support @options.tab_width
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.
No worries about the sdoc thing. We can switch to any version so far as it produces correct output. |
Everyone, please test this branch for documentation to your software and check diff between original and this one. |
I wrote doctest.sh for checking diff between original RDoc and Ripper version RDoc of specified GitHub repository. $ git clone git@gist.github.com:24a122ba798337cc3b9a7bfb32fc28f4.git doctest
$ cd doctest
$ ./doctest.sh
Usage: ./doctest.sh username/repository
$ ./doctest.sh ruby/ruby
# run diff command with less command |
Awesome work @aycabta ! 👏 ❤️ Rails is currently pointing to a fork of SDoc because the API site relies on unreleased changed and we are waiting for 1.0.0 final to be cut before updating the Gemfile but no worries, this is temporary. By the way, the generation time is reduced by ~10s in the Rails repository with this patch ; great ! As you mentioned earlier, the outputs aren't exactly the same but apart from different code highlighting, everything seems fine regarding Rails. |
OK, I understand what is going on.
Thank you, I think that this Pull Request is practically settled. |
I merged these patches into ruby core. |
I confirmed that differences of rdoc documents generated old-rdoc and ripper version. I didn't find another difference without I approved to merge this pull request and release 6.0.0.beta2 before RubyKaigi 2017. @aycabta How do you think about this release? |
@hsbt You sure can, that's why I wrote all code. |
💕 🌸 💞 |
* This version changed lexer used Ripper from lexer based IRB. see details: ruby/rdoc#512 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
🌸 |
I replaced legacy lexical analyser from IRB with Ripper what is standard library of Ruby. It's important to support new syntax.
I explain what this code can parse Ruby code with checking diff for all Ruby documents and all Rails documents.
Preparing
Checkout each branches
Generate CRuby documents
Generate Rails documents
Check diff
Ruby
Rails
Explanation of remaining differences
These are unnecessary to fix.
Ruby
Exception2MessageMapper.html
I heard about this from @nobu, this evaluation code meta programming with complex heredoc is a trick for syntax highlighting of editor. This is strange and complex case, so I think that conforming output of tihs perfectly is unnecessary.
A method is listed at
table_of_contents.html
too.alias
MonitorMixin.html
ruby/doc/syntax/miscellaneous_rdoc.html
For example,
This is difficult to lexical analyse by IRB's one because it's not separated by comma. The
alias
syntax is special case of Ruby. In Ripper version, it becomes perfect.ruby/doc/contributing_rdoc.html
Syntax highlighting for shell command as Ruby. RDoc has only Ruby syntax highlighting feature and it becomes normal quotation without syntex highlighting as Ruby when lexical analysing and parsing as Ruby fails with exception.
Regexp.html
A method definition one liner with regexp literal. It's so difficult to support this case, and if supports it, RDoc code becomes so complex. In Ripper version, it becomes perfect.
(GitHub syntax highlighting fails too...the correct syntax highlighted regexp literal is like below)
Some commented out methods what are treated as document
I sent issues to ruby-core:
But in Ripper version, these skipped.
Rails
There is one difference.
In original RDoc, the end of source code quotation is closed without newline. In Ripper RDoc, it's with newline. The IRB lexical analyser separates token to comment and the end of newline, but Ripper has the end of newline in a comment token. This is difficult to conform perfectly.
There are many cases of this in Rails diff, but these are the same as HTML rendering.
Excursus
I sent a patch for Ripper to ruby-core about lexical analysis state because this branch needed it, and I took some advices about lexical analysis state layer by @mrkn and I wrote
RDoc::RipperStateLex
for it. If the patch what is for Ripper is taken, I'll replaceRDoc::RipperStateLex
with the new Ripper after all old Ripper has gone to EOL.