Skip to content

Commit

Permalink
Add github-linguist-grammars gem
Browse files Browse the repository at this point in the history
The purpose of this gem is to package up the language grammars that are
used for syntax highlighting on github.com. The grammars are TextMate,
Sublime Text, or Atom language grammars, converted to JSON and given the
filename SCOPE.json, where SCOPE is the language scope that the grammar
defines.

The github-linguist-grammars gem packages up all the grammars, and also
exports a Linguist::Grammars.path method to locate the directory
containing the grammars.

To build the gem, simply run `rake build_grammars_gem`. The grammars.yml
file lists all the repositories we download grammars from, as well as
which scopes are defined by each repository. The
script/download-grammars script takes that list and downloads and
processes the grammars into the format expected by the gem.
  • Loading branch information
aroben committed Nov 13, 2014
1 parent ff88210 commit 046fb18
Show file tree
Hide file tree
Showing 10 changed files with 875 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ Gemfile.lock
.bundle/
benchmark/
lib/linguist/samples.json
/grammars
/node_modules
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source 'https://rubygems.org'
gemspec
gemspec :name => "github-linguist"
gemspec :name => "github-linguist-grammars"
gem 'test-unit', require: false if RUBY_VERSION >= '2.2'
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ task :build_gem => :samples do
File.delete("lib/linguist/languages.json")
end

task :build_grammars_gem do
rm_rf "grammars"
sh "script/download-grammars"
sh "gem", "build", "github-linguist-grammars.gemspec"
end

namespace :benchmark do
benchmark_path = "benchmark/results"

Expand Down
14 changes: 14 additions & 0 deletions github-linguist-grammars.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.expand_path('../lib/linguist/version', __FILE__)

Gem::Specification.new do |s|
s.name = 'github-linguist-grammars'
s.version = Linguist::VERSION
s.summary = "Language grammars for use with github-linguist"

s.authors = "GitHub"
s.homepage = "https://github.com/github/linguist"

s.files = ['lib/linguist/grammars.rb'] + Dir['grammars/*']

s.add_development_dependency 'plist', '~>3.1'
end
2 changes: 1 addition & 1 deletion github-linguist.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.homepage = "https://github.com/github/linguist"
s.license = "MIT"

s.files = Dir['lib/**/*']
s.files = Dir['lib/**/*'] - ['lib/linguist/grammars.rb']
s.executables << 'linguist'

s.add_dependency 'charlock_holmes', '~> 0.7.3'
Expand Down
Loading

0 comments on commit 046fb18

Please sign in to comment.