Skip to content

Commit

Permalink
Change method of saving MatLab built-in keywords (#1300)
Browse files Browse the repository at this point in the history
To avoid instantiating a large number of strings, Rouge currently saves
the list of built-in keywords for MatLab to a file that is only read
when the MatLab lexer is in use. The keywords that are in this file are
generated by a Rake task that extracts the keywords from the official
MatLab documentation.

Since the time that the Rake task was created, MathWorks (the creators
of MatLab) have changed the way this page works such that it requires
JavaScript to load. This breaks the Rake task.

As an alternative, this commit includes the list of built-in keywords in
a YAML file. This is consistent with some of the other lexers that have
a large number of keywords (e.g. Apache lexer). It will, unfortunately,
require copying and pasting for future updates.
  • Loading branch information
pyrmont committed Aug 19, 2019
1 parent 917b39d commit 59624c1
Show file tree
Hide file tree
Showing 4 changed files with 3,519 additions and 59 deletions.
6 changes: 4 additions & 2 deletions lib/rouge/lexers/matlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def self.keywords
end

def self.builtins
load File.join(__dir__, 'matlab/builtins.rb')
self.builtins
# Load Matlab keywords from separate YML file
@builtins ||= ::YAML.load_file(File.join(__dir__, 'matlab/builtins.yml')).tap do |a|
Set.new a
end
end

state :root do
Expand Down
13 changes: 0 additions & 13 deletions lib/rouge/lexers/matlab/builtins.rb

This file was deleted.

Loading

0 comments on commit 59624c1

Please sign in to comment.