Skip to content

Commit f3cbad0

Browse files
committed
Merge remote-tracking branch 'origin/master' into rewrite-readme
* origin/master: (104 commits) Added shebang sample for Pike. Added interpreter "pike" for Pike. Add support for FXML files. Add support for Turtle and SPARQL Fixed issues for web ontology to pass tests Added Web Ontology Language Support Simplify blob tests Use the original FileBlob path for filesystem access Sample sagews file, as requested Update languages.yml with *.sagews New grammar for Racket Remove grammar for Racket Modifying BlobHelper and FileBlob to use path Sample file for .cmake.in Restore the .cmake.in extension. More CMake samples. Updating file regex to support unlicense.txt Updating ref to include license Remove pry Start using path with LazyBlob ... Conflicts: CONTRIBUTING.md README.md
2 parents 4b3b1a8 + 0fcdca6 commit f3cbad0

98 files changed

Lines changed: 11730 additions & 157 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@
8282
[submodule "vendor/grammars/language-python"]
8383
path = vendor/grammars/language-python
8484
url = https://github.com/atom/language-python
85-
[submodule "vendor/grammars/language-sass"]
86-
path = vendor/grammars/language-sass
87-
url = https://github.com/atom/language-sass
8885
[submodule "vendor/grammars/language-shellscript"]
8986
path = vendor/grammars/language-shellscript
9087
url = https://github.com/atom/language-shellscript
@@ -115,9 +112,6 @@
115112
[submodule "vendor/grammars/nesC.tmbundle"]
116113
path = vendor/grammars/nesC.tmbundle
117114
url = https://github.com/cdwilson/nesC.tmbundle
118-
[submodule "vendor/grammars/racket-tmbundle"]
119-
path = vendor/grammars/racket-tmbundle
120-
url = https://github.com/christophevg/racket-tmbundle
121115
[submodule "vendor/grammars/haxe-sublime-bundle"]
122116
path = vendor/grammars/haxe-sublime-bundle
123117
url = https://github.com/clemos/haxe-sublime-bundle
@@ -244,9 +238,6 @@
244238
[submodule "vendor/grammars/abap.tmbundle"]
245239
path = vendor/grammars/abap.tmbundle
246240
url = https://github.com/pvl/abap.tmbundle
247-
[submodule "vendor/grammars/Scalate.tmbundle"]
248-
path = vendor/grammars/Scalate.tmbundle
249-
url = https://github.com/scalate/Scalate.tmbundle
250241
[submodule "vendor/grammars/mercury-tmlanguage"]
251242
path = vendor/grammars/mercury-tmlanguage
252243
url = https://github.com/sebgod/mercury-tmlanguage
@@ -486,7 +477,7 @@
486477
url = https://github.com/vkostyukov/kotlin-sublime-package
487478
[submodule "vendor/grammars/c.tmbundle"]
488479
path = vendor/grammars/c.tmbundle
489-
url = https://github.com/vmg/c.tmbundle
480+
url = https://github.com/textmate/c.tmbundle
490481
[submodule "vendor/grammars/zephir-sublime"]
491482
path = vendor/grammars/zephir-sublime
492483
url = https://github.com/vmg/zephir-sublime
@@ -509,7 +500,6 @@
509500
[submodule "vendor/grammars/sublime-mask"]
510501
path = vendor/grammars/sublime-mask
511502
url = https://github.com/tenbits/sublime-mask
512-
branch = release
513503
[submodule "vendor/grammars/sublime_cobol"]
514504
path = vendor/grammars/sublime_cobol
515505
url = https://bitbucket.org/bitlang/sublime_cobol
@@ -520,3 +510,42 @@
520510
[submodule "vendor/grammars/IDL-Syntax"]
521511
path = vendor/grammars/IDL-Syntax
522512
url = https://github.com/andik/IDL-Syntax
513+
[submodule "vendor/grammars/sas.tmbundle"]
514+
path = vendor/grammars/sas.tmbundle
515+
url = https://github.com/rpardee/sas.tmbundle
516+
[submodule "vendor/grammars/atom-salt"]
517+
path = vendor/grammars/atom-salt
518+
url = https://github.com/saltstack/atom-salt
519+
[submodule "vendor/grammars/Scalate.tmbundle"]
520+
path = vendor/grammars/Scalate.tmbundle
521+
url = https://github.com/scalate/Scalate.tmbundle
522+
[submodule "vendor/grammars/Elm.tmLanguage"]
523+
path = vendor/grammars/Elm.tmLanguage
524+
url = https://github.com/deadfoxygrandpa/Elm.tmLanguage
525+
[submodule "vendor/grammars/sublime-bsv"]
526+
path = vendor/grammars/sublime-bsv
527+
url = https://github.com/thotypous/sublime-bsv
528+
[submodule "vendor/grammars/AutoHotkey"]
529+
path = vendor/grammars/AutoHotkey
530+
url = https://github.com/robertcollier4/AutoHotkey
531+
[submodule "vendor/grammars/Sublime-HTTP"]
532+
path = vendor/grammars/Sublime-HTTP
533+
url = https://github.com/httpspec/sublime-highlighting
534+
[submodule "vendor/grammars/sass-textmate-bundle"]
535+
path = vendor/grammars/sass-textmate-bundle
536+
url = https://github.com/nathos/sass-textmate-bundle
537+
[submodule "vendor/grammars/carto-atom"]
538+
path = vendor/grammars/carto-atom
539+
url = https://github.com/yohanboniface/carto-atom
540+
[submodule "vendor/grammars/Sublime-Nit"]
541+
path = vendor/grammars/Sublime-Nit
542+
url = https://github.com/R4PaSs/Sublime-Nit
543+
[submodule "vendor/grammars/language-hy"]
544+
path = vendor/grammars/language-hy
545+
url = https://github.com/rwtolbert/language-hy
546+
[submodule "vendor/grammars/Racket"]
547+
path = vendor/grammars/Racket
548+
url = https://github.com/soegaard/racket-highlight-for-github
549+
[submodule "vendor/grammars/turtle.tmbundle"]
550+
path = vendor/grammars/turtle.tmbundle
551+
url = https://github.com/peta/turtle.tmbundle

.travis.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
before_install:
2-
- git fetch origin master:master
3-
- git fetch origin v2.0.0:v2.0.0
4-
- git fetch origin test/attributes:test/attributes
5-
- git fetch origin test/master:test/master
6-
- sudo apt-get install libicu-dev -y
7-
- git submodule init
8-
- git submodule sync --quiet
9-
- script/fast-submodule-update
1+
sudo: false
2+
before_install: script/travis/before_install
103
rvm:
114
- 1.9.3
125
- 2.0.0
@@ -16,3 +9,4 @@ notifications:
169
disabled: true
1710
git:
1811
submodules: false
12+
cache: bundler

CONTRIBUTING.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@ To add support for a new language:
1313
0. Add an entry for your language to [`languages.yml`][languages].
1414
0. Add a grammar for your language. Please only add grammars that have a license that permits redistribution.
1515
0. Add your grammar as a submodule: `git submodule add https://github.com/JaneSmith/MyGrammar vendor/grammars/MyGrammar`.
16-
0. Add your grammar to [`grammars.yml`][grammars] by running `script/download-grammars --add vendor/grammars/MyGrammar`.
16+
0. Add your grammar to [`grammars.yml`][grammars] by running `script/convert-grammars --add vendor/grammars/MyGrammar`.
1717
0. Add samples for your language to the [samples directory][samples] in the correct subdirectory.
1818
0. Open a pull request, linking to a [GitHub search result](https://github.com/search?utf8=%E2%9C%93&q=extension%3Aboot+NOT+nothack&type=Code&ref=searchresults) showing in-the-wild usage.
1919

20+
In addition, if your new language defines an extension that's already listed in [`languages.yml`][languages] (such as `.foo`) then sometimes a few more steps will need to be taken:
21+
22+
0. Make sure that example `.foo` files are present in the [samples directory][samples] for each language that uses `.foo`.
23+
0. Test the performance of the Bayesian classifier with a relatively large number (1000s) of sample `.foo` files. (ping @arfon or @bkeepers to help with this) to ensure we're not misclassifying files.
24+
0. If the Bayesian classifier does a bad job with the sample `.foo` files then a [heuristic](https://github.com/github/linguist/blob/master/lib/linguist/heuristics.rb) may need to be written to help.
25+
26+
Remember, the goal here is to try and avoid false positives!
27+
2028
## Fixing syntax highlighting
2129

2230
Syntax highlighting in GitHub is performed using TextMate-compatible grammars. These are the same grammars that TextMate, Sublime Text and Atom use. Every language in `languages.yml` is mapped to its corresponding TM `scope`. This scope will be used when picking up a grammar for highlighting.
@@ -49,6 +57,7 @@ If you are the current maintainer of this gem:
4957

5058
0. Create a branch for the release: `git checkout -b cut-release-vxx.xx.xx`
5159
0. Make sure your local dependencies are up to date: `script/bootstrap`
60+
0. If grammar submodules have not been updated recently, update them: `git submodule update --remote && git commit -a`
5261
0. Ensure that samples are updated: `bundle exec rake samples`
5362
0. Ensure that tests are green: `bundle exec rake test`
5463
0. Bump gem version in `lib/linguist/version.rb`, [like this](https://github.com/github/linguist/commit/8d2ea90a5ba3b2fe6e1508b7155aa4632eea2985).

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
source 'https://rubygems.org'
22
gemspec :name => "github-linguist"
33
gemspec :name => "github-linguist-grammars"
4-
gem 'test-unit', require: false if RUBY_VERSION >= '2.2'
54
gem 'byebug' if RUBY_VERSION >= '2.0'

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ end
4848

4949
task :build_grammars_gem do
5050
rm_rf "grammars"
51-
sh "script/download-grammars"
51+
sh "script/convert-grammars"
5252
sh "gem", "build", "github-linguist-grammars.gemspec"
5353
end
5454

github-linguist.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
1818
s.add_dependency 'mime-types', '>= 1.19'
1919
s.add_dependency 'rugged', '~> 0.22.0b4'
2020

21+
s.add_development_dependency 'minitest', '>= 5.0'
2122
s.add_development_dependency 'mocha'
2223
s.add_development_dependency 'pry'
2324
s.add_development_dependency 'rake'

grammars.yml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@ vendor/grammars/Agda.tmbundle:
2424
- source.agda
2525
vendor/grammars/Alloy.tmbundle:
2626
- source.alloy
27+
vendor/grammars/AutoHotkey:
28+
- source.ahk
2729
vendor/grammars/ColdFusion:
2830
- source.cfscript
2931
- source.cfscript.cfc
3032
- text.cfml.basic
3133
- text.html.cfm
3234
vendor/grammars/Docker.tmbundle:
3335
- source.dockerfile
36+
vendor/grammars/Elm.tmLanguage:
37+
- source.elm
3438
vendor/grammars/Handlebars:
3539
- text.html.handlebars
3640
vendor/grammars/IDL-Syntax:
@@ -45,13 +49,15 @@ vendor/grammars/LiveScript.tmbundle:
4549
vendor/grammars/NSIS:
4650
- source.nsis
4751
vendor/grammars/NimLime:
48-
- source.nimrod
49-
- source.nimrod_filter
50-
- source.nimrodcfg
52+
- source.nim
53+
- source.nim_filter
54+
- source.nimcfg
5155
vendor/grammars/PHP-Twig.tmbundle:
5256
- text.html.twig
5357
vendor/grammars/RDoc.tmbundle:
5458
- text.rdoc
59+
vendor/grammars/Racket:
60+
- source.racket
5561
vendor/grammars/SCSS.tmbundle:
5662
- source.scss
5763
vendor/grammars/Scalate.tmbundle:
@@ -64,6 +70,8 @@ vendor/grammars/Stata.tmbundle:
6470
- source.stata
6571
vendor/grammars/Sublime-Coq:
6672
- source.coq
73+
vendor/grammars/Sublime-HTTP:
74+
- source.httpspec
6775
vendor/grammars/Sublime-Inform:
6876
- source.Inform7
6977
vendor/grammars/Sublime-Lasso:
@@ -72,6 +80,8 @@ vendor/grammars/Sublime-Logos:
7280
- source.logos
7381
vendor/grammars/Sublime-Loom:
7482
- source.loomscript
83+
vendor/grammars/Sublime-Nit:
84+
- source.nit
7585
vendor/grammars/Sublime-QML:
7686
- source.qml
7787
vendor/grammars/Sublime-REBOL:
@@ -115,6 +125,9 @@ vendor/grammars/asp.tmbundle:
115125
vendor/grammars/assembly.tmbundle:
116126
- objdump.x86asm
117127
- source.x86asm
128+
vendor/grammars/atom-salt:
129+
- source.python.salt
130+
- source.yaml.salt
118131
vendor/grammars/autoitv3-tmbundle:
119132
- source.autoit.3
120133
vendor/grammars/awk-sublime:
@@ -131,6 +144,8 @@ vendor/grammars/c.tmbundle:
131144
- source.c.platform
132145
vendor/grammars/capnproto.tmbundle:
133146
- source.capnp
147+
vendor/grammars/carto-atom:
148+
- source.css.mss
134149
vendor/grammars/ceylon-sublimetext:
135150
- module.ceylon
136151
- source.ceylon
@@ -248,16 +263,16 @@ vendor/grammars/language-csharp:
248263
- source.nant-build
249264
vendor/grammars/language-gfm:
250265
- source.gfm
266+
vendor/grammars/language-hy:
267+
- source.hy
251268
vendor/grammars/language-javascript:
252269
- source.js
253270
- source.js.regexp
254271
vendor/grammars/language-python:
255272
- source.python
256273
- source.regexp.python
274+
- text.python.console
257275
- text.python.traceback
258-
vendor/grammars/language-sass:
259-
- source.css.scss
260-
- source.sass
261276
vendor/grammars/language-shellscript:
262277
- source.shell
263278
- text.shell-session
@@ -349,8 +364,6 @@ vendor/grammars/python-django.tmbundle:
349364
vendor/grammars/r.tmbundle:
350365
- source.r
351366
- text.tex.latex.rd
352-
vendor/grammars/racket-tmbundle:
353-
- source.racket
354367
vendor/grammars/restructuredtext.tmbundle:
355368
- text.restructuredtext
356369
vendor/grammars/ruby-haml.tmbundle:
@@ -366,6 +379,11 @@ vendor/grammars/ruby-slim.tmbundle:
366379
vendor/grammars/ruby.tmbundle:
367380
- source.ruby
368381
- text.html.erb
382+
vendor/grammars/sas.tmbundle:
383+
- source.SASLog
384+
- source.sas
385+
vendor/grammars/sass-textmate-bundle:
386+
- source.sass
369387
vendor/grammars/scala.tmbundle:
370388
- source.sbt
371389
- source.scala
@@ -386,6 +404,8 @@ vendor/grammars/sublime-befunge:
386404
- source.befunge
387405
vendor/grammars/sublime-better-typescript:
388406
- source.ts
407+
vendor/grammars/sublime-bsv:
408+
- source.bsv
389409
vendor/grammars/sublime-cirru:
390410
- source.cirru
391411
vendor/grammars/sublime-glsl:
@@ -432,6 +452,9 @@ vendor/grammars/thrift.tmbundle:
432452
- source.thrift
433453
vendor/grammars/toml.tmbundle:
434454
- source.toml
455+
vendor/grammars/turtle.tmbundle:
456+
- source.sparql
457+
- source.turtle
435458
vendor/grammars/verilog.tmbundle:
436459
- source.verilog
437460
vendor/grammars/x86-assembly-textmate-bundle:

lib/linguist/blob_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def disposition
9999
elsif name.nil?
100100
"attachment"
101101
else
102-
"attachment; filename=#{EscapeUtils.escape_url(File.basename(name))}"
102+
"attachment; filename=#{EscapeUtils.escape_url(name)}"
103103
end
104104
end
105105

@@ -233,7 +233,7 @@ def viewable?
233233
#
234234
# Return true or false
235235
def vendored?
236-
name =~ VendoredRegexp ? true : false
236+
path =~ VendoredRegexp ? true : false
237237
end
238238

239239
# Public: Get each line of data
@@ -301,7 +301,7 @@ def sloc
301301
#
302302
# Return true or false
303303
def generated?
304-
@_generated ||= Generated.generated?(name, lambda { data })
304+
@_generated ||= Generated.generated?(path, lambda { data })
305305
end
306306

307307
# Public: Detects the Language of the blob.

lib/linguist/file_blob.rb

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Linguist
44
# A FileBlob is a wrapper around a File object to make it quack
55
# like a Grit::Blob. It provides the basic interface: `name`,
6-
# `data`, and `size`.
6+
# `data`, `path` and `size`.
77
class FileBlob
88
include BlobHelper
99

@@ -14,43 +14,50 @@ class FileBlob
1414
#
1515
# Returns a FileBlob.
1616
def initialize(path, base_path = nil)
17-
@path = path
18-
@name = base_path ? path.sub("#{base_path}/", '') : path
17+
@fullpath = path
18+
@path = base_path ? path.sub("#{base_path}/", '') : path
1919
end
2020

2121
# Public: Filename
2222
#
2323
# Examples
2424
#
25-
# FileBlob.new("/path/to/linguist/lib/linguist.rb").name
25+
# FileBlob.new("/path/to/linguist/lib/linguist.rb").path
2626
# # => "/path/to/linguist/lib/linguist.rb"
2727
#
2828
# FileBlob.new("/path/to/linguist/lib/linguist.rb",
29-
# "/path/to/linguist").name
29+
# "/path/to/linguist").path
3030
# # => "lib/linguist.rb"
3131
#
3232
# Returns a String
33-
attr_reader :name
33+
attr_reader :path
3434

3535
# Public: Read file permissions
3636
#
3737
# Returns a String like '100644'
3838
def mode
39-
File.stat(@path).mode.to_s(8)
39+
File.stat(@fullpath).mode.to_s(8)
40+
end
41+
42+
# Public: File name
43+
#
44+
# Returns a String
45+
def name
46+
File.basename(@fullpath)
4047
end
4148

4249
# Public: Read file contents.
4350
#
4451
# Returns a String.
4552
def data
46-
File.read(@path)
53+
File.read(@fullpath)
4754
end
4855

4956
# Public: Get byte size
5057
#
5158
# Returns an Integer.
5259
def size
53-
File.size(@path)
60+
File.size(@fullpath)
5461
end
5562

5663
# Public: Get file extension.
@@ -67,7 +74,7 @@ def extension
6774
#
6875
# Returns an Array
6976
def extensions
70-
basename, *segments = File.basename(name).split(".")
77+
basename, *segments = name.split(".")
7178

7279
segments.map.with_index do |segment, index|
7380
"." + segments[index..-1].join(".")

0 commit comments

Comments
 (0)