Skip to content

Commit 9b85e63

Browse files
author
jneen
committed
various doc fixes
1 parent a50e476 commit 9b85e63

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ for a year are automatically closed by GitHub's [Probot][].
260260
These submission will be rejected and we don't want you to waste your time.
261261

262262
We want to make it as easy as we can for anyone to contribute a lexer to Rouge.
263-
To help get you started, we have [a shiny new guide][lexer-dev-doc] on lexer
263+
To help get you started, we have [a guide][lexer-dev-doc] on lexer
264264
development in the documentation. The best place is to start there.
265265

266266
[lexer-dev-doc]: https://rouge-ruby.github.io/docs/file.LexerDevelopment.html "Rouge's lexer development guide"
@@ -289,12 +289,6 @@ you should have a web server running and ready to go. Visit
289289
Once you've selected a particular lexer, you can add `?debug=1` to your URL
290290
string to see a lot of helpful debugging info printed on stdout.
291291

292-
## Versioning
293-
294-
Rouge uses [Semantic Versioning 2.0.0][sv2].
295-
296-
[sv2]: http://semver.org/
297-
298292
## Maintainers
299293

300294
Rouge is largely the result of the hard work of unpaid volunteers. It was

docs/LexerDevelopment.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,18 @@ Inside a complex rule's block, it's possible to call {Rouge::RegexLexer#push},
243243
{Rouge::RegexLexer#pop!}, {Rouge::RegexLexer#token} and
244244
{Rouge::RegexLexer#delegate}.
245245

246+
One common use case of the block syntax is to use {Rouge::RegexLexer#groups}
247+
to easily assign token types to various capture groups of the regex. For
248+
example, in Java, we might detect attribute accessors with:
249+
250+
```rb
251+
rule /([.])(\w+)/ do
252+
groups Operator, Name::Attribute
253+
end
254+
```
255+
256+
Make sure you don't forget to include *all* of the matched text in the output!
257+
246258
You can see an example of these more complex rules in [the Ruby lexer][ruby-lexer].
247259

248260
### Additional Features
@@ -283,10 +295,10 @@ Filename Globs][conflict-globs] below.
283295

284296
#### Special Words
285297

286-
Every programming language reserves certain words for use as identifiers that
298+
Most programming languages reserve certain words for use as identifiers that
287299
have a special meaning in the language. To make regular expressions that search
288-
for these words easier, many lexers will put the applicable keywords in an
289-
array and make them available in a particular way (be it as a local variable,
300+
for these words easier, many lexers will put the applicable keywords in a
301+
set and make them available in a particular way (be it as a local variable,
290302
an instance variable or what have you).
291303

292304
For performance and safety, we strongly recommend lexers use a class method:
@@ -295,13 +307,14 @@ For performance and safety, we strongly recommend lexers use a class method:
295307
module Rouge
296308
module Lexers
297309
class YetAnotherLanguage < RegexLexer
298-
...
310+
...
299311

300-
def self.keywords
301-
@keywords ||= Set.new %w(key words used in this language)
302-
end
312+
def self.keywords
313+
@keywords ||= Set.new %w(key words used in this language)
314+
end
303315

304-
...
316+
...
317+
end
305318
end
306319
end
307320
```
@@ -495,10 +508,8 @@ The spec and the demo can be run using the `rake` command. You can run this by
495508
typing `bundle exec rake` at the command line. If everything works, you should
496509
see a series of dots. If you have an error, this will appear here, too.
497510

498-
You can also run `bundle exec rake VERBOSE=1` to see all warnings.
499-
500511
To see your visual sample, launch Rouge's visual test app by running
501-
`bundle exec rackup`. You can choose your sample from the complete list by going
512+
`bundle exec puma`. You can choose your sample from the complete list by going
502513
to <http://localhost:9292>.
503514

504515
## How to Submit

0 commit comments

Comments
 (0)