Skip to content

Conversation

@jeremyevans
Copy link
Contributor

This uses BEGIN {return true} when evaluating the text, which will do
a syntax check, but not actually execute the code.

Using a real ruby parser is a big improvement for two reasons.
First, it highlights valid ruby syntax that was left unhighlighted
by the previous parser. Second and more important, it doesn't
highlight invalid ruby syntax, which makes it easier to catch
errors in example code in the documentation. This even fixes some
errors in the tests, where code like "class C end" was considered
valid syntax.

There is some fallout in the tests where code that wasn't highlighted
before is now highlighted, this also fixes those cases so the tests
pass.

This uses BEGIN {return true} when evaluating the text, which will do
a syntax check, but not actually execute the code.

Using a real ruby parser is a big improvement for two reasons.
First, it highlights valid ruby syntax that was left unhighlighted
by the previous parser.  Second and more important, it doesn't
highlight invalid ruby syntax, which makes it easier to catch
errors in example code in the documentation.  This even fixes some
errors in the tests, where code like "class C end" was considered
valid syntax.

There is some fallout in the tests where code that wasn't highlighted
before is now highlighted, this also fixes those cases so the tests
pass.
@zzak
Copy link
Member

zzak commented Dec 1, 2014

This is a really nice change, but I haven't run into any invalid Ruby code in my docs.. maybe this will help spot them earlier?

@jeremyevans
Copy link
Contributor Author

Here's an example of the type of doc fixes that this change can bring about: jeremyevans/sequel@e46eea8

Many of the changes are innocuous (e.g. replacing ... with something else), but there are some real documentation bug fixes in there, for missed ), }, do, and similar issues.

@zzak
Copy link
Member

zzak commented Dec 1, 2014

@jeremyevans This is great, I wonder if we should warn the user if there is any invalid Ruby code?

@jeremyevans
Copy link
Contributor Author

@zzak I don't think so. Verbatim blocks are not exclusively used for ruby code (shell and erb are pretty common at least), and we have no way of knowing whether the author intended to use ruby code for the verbatim block or not.

@zzak
Copy link
Member

zzak commented Dec 1, 2014

Fair enough, lets start with fixing the highlighter for now. Thank you!

@drbrain drbrain added the bug label Dec 7, 2014
@drbrain drbrain added this to the 4.2 milestone Dec 7, 2014
drbrain added a commit that referenced this pull request Dec 7, 2014
Use a real parser for RDoc::Markup::ToHtml#parseable? (Fixes #320)
@drbrain drbrain merged commit 9f65692 into ruby:master Dec 7, 2014
drbrain added a commit that referenced this pull request Dec 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants