mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Merge remote-tracking branch 'refs/remotes/github/master'
Conflicts: .gitmodules grammars.yml
This commit is contained in:
		
							
								
								
									
										18
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							| @@ -325,9 +325,6 @@ | ||||
| [submodule "vendor/grammars/nemerle.tmbundle"] | ||||
| 	path = vendor/grammars/nemerle.tmbundle | ||||
| 	url = https://github.com/textmate/nemerle.tmbundle | ||||
| [submodule "vendor/grammars/ninja.tmbundle"] | ||||
| 	path = vendor/grammars/ninja.tmbundle | ||||
| 	url = https://github.com/textmate/ninja.tmbundle | ||||
| [submodule "vendor/grammars/objective-c.tmbundle"] | ||||
| 	path = vendor/grammars/objective-c.tmbundle | ||||
| 	url = https://github.com/textmate/objective-c.tmbundle | ||||
| @@ -355,9 +352,6 @@ | ||||
| [submodule "vendor/grammars/r.tmbundle"] | ||||
| 	path = vendor/grammars/r.tmbundle | ||||
| 	url = https://github.com/textmate/r.tmbundle | ||||
| [submodule "vendor/grammars/ruby-haml.tmbundle"] | ||||
| 	path = vendor/grammars/ruby-haml.tmbundle | ||||
| 	url = https://github.com/textmate/ruby-haml.tmbundle | ||||
| [submodule "vendor/grammars/scheme.tmbundle"] | ||||
| 	path = vendor/grammars/scheme.tmbundle | ||||
| 	url = https://github.com/textmate/scheme.tmbundle | ||||
| @@ -776,9 +770,6 @@ | ||||
| [submodule "vendor/grammars/vhdl"] | ||||
| 	path = vendor/grammars/vhdl | ||||
| 	url = https://github.com/textmate/vhdl.tmbundle | ||||
| [submodule "vendor/grammars/xquery"] | ||||
| 	path = vendor/grammars/xquery | ||||
| 	url = https://github.com/textmate/xquery.tmbundle | ||||
| [submodule "vendor/grammars/language-rpm-spec"] | ||||
| 	path = vendor/grammars/language-rpm-spec | ||||
| 	url = https://github.com/waveclaw/language-rpm-spec | ||||
| @@ -803,6 +794,15 @@ | ||||
| [submodule "vendor/grammars/EBNF.tmbundle"] | ||||
| 	path = vendor/grammars/EBNF.tmbundle | ||||
| 	url = https://github.com/sanssecours/EBNF.tmbundle | ||||
| [submodule "vendor/grammars/language-haml"] | ||||
| 	path = vendor/grammars/language-haml | ||||
| 	url = https://github.com/ezekg/language-haml | ||||
| [submodule "vendor/grammars/language-ninja"] | ||||
| 	path = vendor/grammars/language-ninja | ||||
| 	url = https://github.com/khyo/language-ninja | ||||
| [submodule "vendor/grammars/language-fontforge"] | ||||
| 	path = vendor/grammars/language-fontforge | ||||
| 	url = https://github.com/Alhadis/language-fontforge | ||||
| [submodule "vendor/grammars/rascal-syntax-highlighting"] | ||||
| 	path = vendor/grammars/rascal-syntax-highlighting | ||||
| 	url = https://github.com/usethesource/rascal-syntax-highlighting | ||||
							
								
								
									
										15
									
								
								grammars.yml
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								grammars.yml
									
									
									
									
									
								
							| @@ -362,10 +362,17 @@ vendor/grammars/language-csound: | ||||
| - source.csound-score | ||||
| vendor/grammars/language-emacs-lisp: | ||||
| - source.emacs.lisp | ||||
| vendor/grammars/language-fontforge: | ||||
| - source.fontforge | ||||
| - source.opentype | ||||
| - text.sfd | ||||
| vendor/grammars/language-gfm: | ||||
| - source.gfm | ||||
| vendor/grammars/language-graphql: | ||||
| - source.graphql | ||||
| vendor/grammars/language-haml: | ||||
| - text.haml | ||||
| - text.hamlc | ||||
| vendor/grammars/language-haskell: | ||||
| - hint.haskell | ||||
| - hint.message.haskell | ||||
| @@ -393,6 +400,8 @@ vendor/grammars/language-maxscript: | ||||
| - source.maxscript | ||||
| vendor/grammars/language-ncl: | ||||
| - source.ncl | ||||
| vendor/grammars/language-ninja: | ||||
| - source.ninja | ||||
| vendor/grammars/language-povray: | ||||
| - source.pov-ray sdl | ||||
| vendor/grammars/language-python: | ||||
| @@ -474,8 +483,6 @@ vendor/grammars/nemerle.tmbundle: | ||||
| - source.nemerle | ||||
| vendor/grammars/nesC: | ||||
| - source.nesc | ||||
| vendor/grammars/ninja.tmbundle: | ||||
| - source.ninja | ||||
| vendor/grammars/nix: | ||||
| - source.nix | ||||
| vendor/grammars/nu.tmbundle: | ||||
| @@ -533,8 +540,6 @@ vendor/grammars/r.tmbundle: | ||||
| - text.tex.latex.rd | ||||
| vendor/grammars/rascal-syntax-highlighting: | ||||
| - source.rascal | ||||
| vendor/grammars/ruby-haml.tmbundle: | ||||
| - text.haml | ||||
| vendor/grammars/ruby-slim.tmbundle: | ||||
| - text.slim | ||||
| vendor/grammars/ruby.tmbundle: | ||||
| @@ -655,7 +660,5 @@ vendor/grammars/xc.tmbundle: | ||||
| vendor/grammars/xml.tmbundle: | ||||
| - text.xml | ||||
| - text.xml.xsl | ||||
| vendor/grammars/xquery: | ||||
| - source.xquery | ||||
| vendor/grammars/zephir-sublime: | ||||
| - source.php.zephir | ||||
|   | ||||
| @@ -63,7 +63,7 @@ module Linguist | ||||
|     # | ||||
|     # Returns an Array | ||||
|     def extensions | ||||
|       _, *segments = name.downcase.split(".") | ||||
|       _, *segments = name.downcase.split(".", -1) | ||||
|  | ||||
|       segments.map.with_index do |segment, index| | ||||
|         "." + segments[index..-1].join(".") | ||||
|   | ||||
| @@ -275,16 +275,14 @@ module Linguist | ||||
|       return lines[0].include?("Generated by the protocol buffer compiler.  DO NOT EDIT!") | ||||
|     end | ||||
|  | ||||
|     APACHE_THRIFT_EXTENSIONS = ['.rb', '.py', '.go', '.js', '.m', '.java', '.h', '.cc', '.cpp'] | ||||
|     APACHE_THRIFT_EXTENSIONS = ['.rb', '.py', '.go', '.js', '.m', '.java', '.h', '.cc', '.cpp', '.php'] | ||||
|  | ||||
|     # Internal: Is the blob generated by Apache Thrift compiler? | ||||
|     # | ||||
|     # Returns true or false | ||||
|     def generated_apache_thrift? | ||||
|       return false unless APACHE_THRIFT_EXTENSIONS.include?(extname) | ||||
|       return false unless lines.count > 1 | ||||
|  | ||||
|       return lines[0].include?("Autogenerated by Thrift Compiler") || lines[1].include?("Autogenerated by Thrift Compiler") | ||||
|       return lines.first(6).any? { |l| l.include?("Autogenerated by Thrift Compiler") } | ||||
|     end | ||||
|  | ||||
|     # Internal: Is the blob a C/C++ header generated by the Java JNI tool javah? | ||||
|   | ||||
| @@ -110,6 +110,12 @@ module Linguist | ||||
|       end | ||||
|     end | ||||
|  | ||||
|     disambiguate ".cls" do |data| | ||||
|       if /\\\w+{/.match(data) | ||||
|         Language["TeX"] | ||||
|       end | ||||
|     end | ||||
|  | ||||
|     disambiguate ".cs" do |data| | ||||
|       if /![\w\s]+methodsFor: /.match(data) | ||||
|         Language["Smalltalk"] | ||||
|   | ||||
| @@ -1141,9 +1141,9 @@ Emacs Lisp: | ||||
|   - ".gnus" | ||||
|   - ".spacemacs" | ||||
|   - ".viper" | ||||
|   - "Project.ede" | ||||
|   - "_emacs" | ||||
|   - "abbrev_defs" | ||||
|   - Project.ede | ||||
|   - _emacs | ||||
|   - abbrev_defs | ||||
|   extensions: | ||||
|   - ".el" | ||||
|   - ".emacs" | ||||
| @@ -1473,6 +1473,8 @@ Gnuplot: | ||||
| Go: | ||||
|   type: programming | ||||
|   color: "#375eab" | ||||
|   aliases: | ||||
|   - golang | ||||
|   extensions: | ||||
|   - ".go" | ||||
|   ace_mode: golang | ||||
| @@ -1659,13 +1661,16 @@ HTML+Django: | ||||
|   tm_scope: text.html.django | ||||
|   group: HTML | ||||
|   extensions: | ||||
|   - ".mustache" | ||||
|   - ".jinja" | ||||
|   - ".mustache" | ||||
|   - ".njk" | ||||
|   aliases: | ||||
|   - django | ||||
|   - html+django/jinja | ||||
|   - html+jinja | ||||
|   - htmldjango | ||||
|   - njk | ||||
|   - nunjucks | ||||
|   ace_mode: django | ||||
|   codemirror_mode: django | ||||
|   codemirror_mime_type: text/x-django | ||||
| @@ -1959,6 +1964,8 @@ JSON5: | ||||
|   type: data | ||||
|   extensions: | ||||
|   - ".json5" | ||||
|   filenames: | ||||
|   - ".babelrc" | ||||
|   tm_scope: source.js | ||||
|   ace_mode: javascript | ||||
|   codemirror_mode: javascript | ||||
| @@ -2953,6 +2960,15 @@ OpenSCAD: | ||||
|   - ".scad" | ||||
|   tm_scope: none | ||||
|   ace_mode: scad | ||||
|   language_id: 431 | ||||
| OpenType Feature File: | ||||
|   type: data | ||||
|   aliases: | ||||
|   - AFDKO | ||||
|   extensions: | ||||
|   - ".fea" | ||||
|   tm_scope: source.opentype | ||||
|   ace_mode: text | ||||
|   language_id: 266 | ||||
| Org: | ||||
|   type: prose | ||||
| @@ -3172,7 +3188,7 @@ Perl6: | ||||
| Pic: | ||||
|   type: markup | ||||
|   group: Groff | ||||
|   tm_scope: "source.pic" | ||||
|   tm_scope: source.pic | ||||
|   extensions: | ||||
|   - ".pic" | ||||
|   - ".chem" | ||||
| @@ -3694,6 +3710,7 @@ Ruby: | ||||
|   - Berksfile | ||||
|   - Brewfile | ||||
|   - Buildfile | ||||
|   - Dangerfile | ||||
|   - Deliverfile | ||||
|   - Fastfile | ||||
|   - Gemfile | ||||
| @@ -4034,6 +4051,13 @@ SourcePawn: | ||||
|   - ".sma" | ||||
|   tm_scope: source.sp | ||||
|   ace_mode: text | ||||
|   language_id: 432 | ||||
| Spline Font Database: | ||||
|   type: data | ||||
|   extensions: | ||||
|   - ".sfd" | ||||
|   tm_scope: text.sfd | ||||
|   ace_mode: yaml | ||||
|   language_id: 354 | ||||
| Squirrel: | ||||
|   type: programming | ||||
| @@ -4265,6 +4289,7 @@ Text: | ||||
|   - ".no" | ||||
|   filenames: | ||||
|   - COPYING | ||||
|   - FONTLOG | ||||
|   - INSTALL | ||||
|   - LICENSE | ||||
|   - NEWS | ||||
|   | ||||
| @@ -50,6 +50,9 @@ | ||||
| # Go dependencies | ||||
| - Godeps/_workspace/ | ||||
|  | ||||
| # GNU indent profiles | ||||
| - .indent.pro | ||||
|  | ||||
| # Minified JavaScript and CSS | ||||
| - (\.|-)min\.(js|css)$ | ||||
|  | ||||
|   | ||||
							
								
								
									
										48
									
								
								samples/HTML+Django/nunjucks.njk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								samples/HTML+Django/nunjucks.njk
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| {% from "forms.html" import label as description %} | ||||
|  | ||||
|  | ||||
| {% macro field(name, value='', type='text') %} | ||||
|     <div class="field"> | ||||
|         <input type="{{ type }}" name="{{ name }}" | ||||
|                 value="{{ value | escape }}" /> | ||||
|     </div> | ||||
| {% endmacro %} | ||||
|  | ||||
| <html> | ||||
| <head> | ||||
|     {% extends "head.html" %} | ||||
| </head> | ||||
| <body> | ||||
| {% if horse %} | ||||
|     Chuck Norris once kicked a horse in the chin. Its descendants are known today as Giraffes. | ||||
| {% elif optimus %} | ||||
|     Chuck Norris once urinated in a semi truck's gas tank as a joke....that truck is now known as Optimus Prime. | ||||
| {% else %} | ||||
|     Chuck Norris threw a grenade and killed 50 people, then the grenade exploded. | ||||
| {% endif %} | ||||
|  | ||||
| {% block left %} | ||||
|     This is the left side! | ||||
| {% endblock %} | ||||
|  | ||||
| {% block right %} | ||||
|     This is the right side! | ||||
| {% endblock %} | ||||
|  | ||||
| {{ description('Username') }} | ||||
| {{ field('user') }} | ||||
| {{ field('pass', type='password') }} | ||||
|  | ||||
| <h1>Posts</h1> | ||||
| <ul> | ||||
|     {% for item in items %} | ||||
|         <li>{{ item.title }}</li> | ||||
|     {% else %} | ||||
|         <li>This would display if the 'item' collection were empty</li> | ||||
|     {% endfor %} | ||||
| </ul> | ||||
|  | ||||
| {# Don't escape foo #} | ||||
| {{ foo | safe }} | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										6
									
								
								samples/JSON5/filenames/.babelrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								samples/JSON5/filenames/.babelrc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| { | ||||
|   "presets": [ | ||||
|     "es2015", | ||||
|     "es2016" | ||||
|   ] | ||||
| } | ||||
							
								
								
									
										93
									
								
								samples/PHP/ThriftGenerated.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								samples/PHP/ThriftGenerated.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,93 @@ | ||||
| <?php | ||||
| namespace github\com; | ||||
|  | ||||
| /** | ||||
|  * Autogenerated by Thrift Compiler (0.9.3) | ||||
|  * | ||||
|  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | ||||
|  *  @generated | ||||
|  */ | ||||
| use Thrift\Base\TBase; | ||||
| use Thrift\Type\TType; | ||||
| use Thrift\Type\TMessageType; | ||||
| use Thrift\Exception\TException; | ||||
| use Thrift\Exception\TProtocolException; | ||||
| use Thrift\Protocol\TProtocol; | ||||
| use Thrift\Protocol\TBinaryProtocolAccelerated; | ||||
| use Thrift\Exception\TApplicationException; | ||||
|  | ||||
|  | ||||
| class PullRequest { | ||||
|   static $_TSPEC; | ||||
|  | ||||
|   /** | ||||
|    * @var string | ||||
|    */ | ||||
|   public $title = null; | ||||
|  | ||||
|   public function __construct($vals=null) { | ||||
|     if (!isset(self::$_TSPEC)) { | ||||
|       self::$_TSPEC = array( | ||||
|         1 => array( | ||||
|           'var' => 'title', | ||||
|           'type' => TType::STRING, | ||||
|           ), | ||||
|         ); | ||||
|     } | ||||
|     if (is_array($vals)) { | ||||
|       if (isset($vals['title'])) { | ||||
|         $this->title = $vals['title']; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public function getName() { | ||||
|     return 'PullRequest'; | ||||
|   } | ||||
|  | ||||
|   public function read($input) | ||||
|   { | ||||
|     $xfer = 0; | ||||
|     $fname = null; | ||||
|     $ftype = 0; | ||||
|     $fid = 0; | ||||
|     $xfer += $input->readStructBegin($fname); | ||||
|     while (true) | ||||
|     { | ||||
|       $xfer += $input->readFieldBegin($fname, $ftype, $fid); | ||||
|       if ($ftype == TType::STOP) { | ||||
|         break; | ||||
|       } | ||||
|       switch ($fid) | ||||
|       { | ||||
|         case 1: | ||||
|           if ($ftype == TType::STRING) { | ||||
|             $xfer += $input->readString($this->title); | ||||
|           } else { | ||||
|             $xfer += $input->skip($ftype); | ||||
|           } | ||||
|           break; | ||||
|         default: | ||||
|           $xfer += $input->skip($ftype); | ||||
|           break; | ||||
|       } | ||||
|       $xfer += $input->readFieldEnd(); | ||||
|     } | ||||
|     $xfer += $input->readStructEnd(); | ||||
|     return $xfer; | ||||
|   } | ||||
|  | ||||
|   public function write($output) { | ||||
|     $xfer = 0; | ||||
|     $xfer += $output->writeStructBegin('PullRequest'); | ||||
|     if ($this->title !== null) { | ||||
|       $xfer += $output->writeFieldBegin('title', TType::STRING, 1); | ||||
|       $xfer += $output->writeString($this->title); | ||||
|       $xfer += $output->writeFieldEnd(); | ||||
|     } | ||||
|     $xfer += $output->writeFieldStop(); | ||||
|     $xfer += $output->writeStructEnd(); | ||||
|     return $xfer; | ||||
|   } | ||||
|  | ||||
| } | ||||
							
								
								
									
										75
									
								
								samples/Ruby/filenames/Dangerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								samples/Ruby/filenames/Dangerfile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| # Sometimes its a README fix, or something like that - which isn't relevant for | ||||
| # including in a CHANGELOG for example | ||||
| # From https://github.com/danger/danger/blob/master/Dangerfile | ||||
|  | ||||
| has_app_changes = !git.modified_files.grep(/lib/).empty? | ||||
| has_test_changes = !git.modified_files.grep(/spec/).empty? | ||||
| is_version_bump = git.modified_files.sort == ["CHANGELOG.md", "lib/danger/version.rb"].sort | ||||
|  | ||||
| if has_app_changes && !has_test_changes && !is_version_bump | ||||
|   warn("Tests were not updated", sticky: false) | ||||
| end | ||||
|  | ||||
| # Thanks other people! | ||||
| message(":tada:") if is_version_bump && github.pr_author != "orta" | ||||
|  | ||||
| # Make a note about contributors not in the organization | ||||
| unless github.api.organization_member?('danger', github.pr_author) | ||||
|   message "@#{github.pr_author} is not a contributor yet, would you like to join the Danger org?" | ||||
|  | ||||
|   # Pay extra attention if they modify the gemspec | ||||
|   if git.modified_files.include?("*.gemspec") | ||||
|     warn "External contributor has edited the Gemspec" | ||||
|   end | ||||
| end | ||||
|  | ||||
| # Mainly to encourage writing up some reasoning about the PR, rather than | ||||
| # just leaving a title | ||||
| if github.pr_body.length < 5 | ||||
|   fail "Please provide a summary in the Pull Request description" | ||||
| end | ||||
|  | ||||
| # Let people say that this isn't worth a CHANGELOG entry in the PR if they choose | ||||
| declared_trivial = (github.pr_title + github.pr_body).include?("#trivial") || !has_app_changes | ||||
|  | ||||
| if !git.modified_files.include?("CHANGELOG.md") && !declared_trivial | ||||
|   fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/danger/danger/blob/master/CHANGELOG.md).", sticky: false) | ||||
| end | ||||
|  | ||||
| # Docs are critical, so let's re-run the docs part of the specs and show any issues: | ||||
| core_plugins_docs = `bundle exec danger plugins lint lib/danger/danger_core/plugins/*.rb --warnings-as-errors` | ||||
|  | ||||
| # If it failed, fail the build, and include markdown with the output error. | ||||
| unless $?.success? | ||||
|   # We want to strip ANSI colors for our markdown, and make paths relative | ||||
|   colourless_error = core_plugins_docs.gsub(/\e\[(\d+)(;\d+)*m/, "") | ||||
|   markdown("### Core Docs Errors \n\n#{colourless_error}") | ||||
|   fail("Failing due to documentation issues, see below.", sticky: false) | ||||
| end | ||||
|  | ||||
| # Oddly enough, it's quite possible to do some testing of Danger, inside Danger | ||||
| # So, you can ignore these, if you're looking at the Dangerfile to get ideas. | ||||
| # | ||||
| # If these are all empty something has gone wrong, better to raise it in a comment | ||||
| if git.modified_files.empty? && git.added_files.empty? && git.deleted_files.empty? | ||||
|   fail "This PR has no changes at all, this is likely an issue during development." | ||||
| end | ||||
|  | ||||
| # This comes from `./danger_plugins/protect_files.rb` which is automatically parsed by Danger | ||||
| files.protect_files(path: "danger.gemspec", message: ".gemspec modified", fail_build: false) | ||||
|  | ||||
| # Ensure that our core plugins all have 100% documentation | ||||
| core_plugins = Dir.glob("lib/danger/danger_core/plugins/*.rb") | ||||
| core_lint_output = `bundle exec yard stats #{core_plugins.join ' '} --list-undoc --tag tags` | ||||
|  | ||||
| if !core_lint_output.include?("100.00%") | ||||
|   fail "The core plugins are not at 100% doc'd - see below:", sticky: false | ||||
|   markdown "```\n#{core_lint_output}```" | ||||
| elsif core_lint_output.include? "warning" | ||||
|   warn "The core plugins are have yard warnings - see below", sticky: false | ||||
|   markdown "```\n#{core_lint_output}```" | ||||
| end | ||||
|  | ||||
| junit.parse "junit-results.xml" | ||||
| junit.headers = [:file, :name] | ||||
| junit.report | ||||
| @@ -78,6 +78,8 @@ https    = "https://#{parts[:host]}/#{parts[:user]}/#{parts[:repo]}" | ||||
| repo_new = "vendor/grammars/#{parts[:repo]}" | ||||
| repo_old = parse_submodule($replace) if $replace | ||||
|  | ||||
| Dir.chdir(ROOT) | ||||
|  | ||||
| if repo_old | ||||
|   log "Deregistering: #{repo_old}" | ||||
|   `git submodule deinit #{repo_old}` | ||||
| @@ -93,4 +95,5 @@ log "Confirming license" | ||||
| `script/licensed --module "#{repo_new}"` | ||||
|  | ||||
| log "Updating grammar documentation in vendor/REAEDME.md" | ||||
| `script list-grammars` | ||||
| `bundle exec rake samples` | ||||
| `script/list-grammars` | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| #!/usr/bin/env ruby | ||||
|  | ||||
| require 'bundler/setup' | ||||
| require 'json' | ||||
| require 'net/http' | ||||
| require 'optparse' | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| #!/usr/bin/env ruby | ||||
|  | ||||
| require "bundler/setup" | ||||
| require "linguist" | ||||
| require "json" | ||||
| require "yaml" | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| #!/usr/bin/env ruby | ||||
|  | ||||
| require "bundler/setup" | ||||
| require "json" | ||||
| require "linguist" | ||||
| require "set" | ||||
| require "yaml" | ||||
|  | ||||
| ROOT = File.expand_path("../../", __FILE__) | ||||
|  | ||||
| def find_includes(json) | ||||
|   case json | ||||
|   when Hash | ||||
| @@ -32,7 +35,7 @@ def transitive_includes(scope, includes) | ||||
| end | ||||
|  | ||||
| includes = {} | ||||
| Dir["grammars/*.json"].each do |path| | ||||
| Dir[File.join(ROOT, "grammars/*.json")].each do |path| | ||||
|   scope = File.basename(path).sub(/\.json/, '') | ||||
|   json = JSON.load(File.read(path)) | ||||
|   incs = find_includes(json) | ||||
| @@ -41,7 +44,7 @@ Dir["grammars/*.json"].each do |path| | ||||
|   includes[scope] += incs | ||||
| end | ||||
|  | ||||
| yaml = YAML.load(File.read("grammars.yml")) | ||||
| yaml = YAML.load(File.read(File.join(ROOT, "grammars.yml"))) | ||||
| language_scopes = Linguist::Language.all.map(&:tm_scope).to_set | ||||
|  | ||||
| # The set of used scopes is the scopes for each language, plus all the scopes | ||||
| @@ -54,4 +57,4 @@ puts "Unused grammar repos" | ||||
| puts unused.map { |repo, scopes| sprintf("%-100s %s", repo, scopes.join(", ")) }.sort.join("\n") | ||||
|  | ||||
| yaml.delete_if { |k| unused.key?(k) } | ||||
| File.write("grammars.yml", YAML.dump(yaml)) | ||||
| File.write(File.join(ROOT, "grammars.yml"), YAML.dump(yaml)) | ||||
|   | ||||
| @@ -1,4 +1,6 @@ | ||||
| #!/usr/bin/env ruby | ||||
|  | ||||
| require 'bundler/setup' | ||||
| require 'yaml' | ||||
| require 'pry' | ||||
|  | ||||
| @@ -11,6 +13,8 @@ header = <<-EOF | ||||
| # ace_mode          - A String name of the Ace Mode used for highlighting whenever | ||||
| #                     a file is edited. This must match one of the filenames in http://git.io/3XO_Cg. | ||||
| #                     Use "text" if a mode does not exist. | ||||
| # codemirror_mode   - A String name of the CodeMirror Mode used for highlighting whenever a file is edited. | ||||
| #                     This must match a mode from https://git.io/vi9Fx | ||||
| # wrap              - Boolean wrap to enable line wrapping (default: false) | ||||
| # extensions        - An Array of associated extensions (the first one is | ||||
| #                     considered the primary extension, the others should be | ||||
| @@ -22,7 +26,7 @@ header = <<-EOF | ||||
| # language_id       - Integer used as a language-name-independent indexed field so that we can rename | ||||
| #                     languages in Linguist without reindexing all the code on GitHub. Must not be | ||||
| #                     changed for existing languages without the explicit permission of GitHub staff. | ||||
| # color             - CSS hex color to represent the language. | ||||
| # color             - CSS hex color to represent the language. Only used if type is "programming" or "prose". | ||||
| # tm_scope          - The TextMate scope that represents this programming | ||||
| #                     language. This should match one of the scopes listed in | ||||
| #                     the grammars.yml file. Use "none" if there is no grammar | ||||
| @@ -36,21 +40,23 @@ header = <<-EOF | ||||
| # Please keep this list alphabetized. Capitalization comes before lowercase. | ||||
|  | ||||
| EOF | ||||
| require 'digest' | ||||
|  | ||||
| generated = true if ARGV[0] == "--force" | ||||
| update = true if ARGV[0] == "--update" | ||||
|  | ||||
| def generate_language_id(language) | ||||
|   Digest::SHA256.hexdigest(language).to_i(16) % (2**30 - 1) | ||||
| end | ||||
|  | ||||
| if generated | ||||
|   puts "You're regenerating all of the language_id attributes for all Linguist " | ||||
|   puts "languages defined in languages.yml. This is almost certainly NOT what" | ||||
|   puts "you meant to do!" | ||||
|  | ||||
|   language_index = 0 | ||||
|  | ||||
|   languages = YAML.load(File.read("lib/linguist/languages.yml")) | ||||
|   languages.each do |name, vals| | ||||
|     vals.merge!('language_id' => language_index) | ||||
|     language_index += 1 | ||||
|     vals.merge!('language_id' => generate_language_id(name)) | ||||
|   end | ||||
|  | ||||
|   File.write("lib/linguist/languages.yml", header + YAML.dump(languages)) | ||||
| @@ -58,20 +64,12 @@ elsif update | ||||
|   puts "Adding new language_id attributes to languages.yml that don't have one set" | ||||
|   languages = YAML.load(File.read("lib/linguist/languages.yml")) | ||||
|  | ||||
|   # First grab the maximum language_id | ||||
|   language_ids = [] | ||||
|   languages.each { |name, vals| language_ids << vals['language_id'] if vals.has_key?('language_id')} | ||||
|   max_language_id = language_ids.max | ||||
|   puts "Current maximum language_id is #{max_language_id}" | ||||
|  | ||||
|   missing_count = 0 | ||||
|   language_index = max_language_id | ||||
|  | ||||
|   languages.each do |name, vals| | ||||
|     unless vals.has_key?('language_id') | ||||
|       language_index += 1 | ||||
|       missing_count += 1 | ||||
|       vals.merge!('language_id' => language_index) | ||||
|       vals.merge!('language_id' => generate_language_id(name)) | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   | ||||
| @@ -202,6 +202,7 @@ class TestBlob < Minitest::Test | ||||
|     assert sample_blob_memory("JavaScript/gen-js-linguist-thrift.js").generated? | ||||
|     assert sample_blob_memory("Ruby/gen-rb-linguist-thrift.rb").generated? | ||||
|     assert sample_blob_memory("Objective-C/gen-cocoa-linguist-thrift.m").generated? | ||||
|     assert sample_blob_memory("PHP/ThriftGenerated.php").generated? | ||||
|  | ||||
|     # Generated JNI | ||||
|     assert sample_blob_memory("C/jni_layer.h").generated? | ||||
|   | ||||
| @@ -294,6 +294,8 @@ class TestFileBlob < Minitest::Test | ||||
|     assert !sample_blob("Godeps/Godeps.json").vendored? | ||||
|     assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").vendored? | ||||
|  | ||||
|     assert sample_blob(".indent.pro").vendored? | ||||
|  | ||||
|     # Rails vendor/ | ||||
|     assert sample_blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored? | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ class TestGrammars < Minitest::Test | ||||
|   # List of projects that are allowed without licenses | ||||
|   PROJECT_WHITELIST = [ | ||||
|     "vendor/grammars/Sublime-Lasso", | ||||
|     "vendor/grammars/ant.tmbundle", | ||||
|     "vendor/grammars/sublime-spintools", | ||||
|     "vendor/grammars/blitzmax" | ||||
|   ].freeze | ||||
| @@ -40,6 +39,7 @@ class TestGrammars < Minitest::Test | ||||
|     "c9118c370411f2f049c746c0fd096554e877aea2", # perl6fe | ||||
|     "8ccf886749c32fb7e65d4d1316a7ed0479c93dc9", # language-less | ||||
|     "2f03492b52d7dd83b4e7472f01b87c6121e5b1a4", # monkey | ||||
|     "241e5ddbb4423d792216783e9f668bd670b026e4", # ant.tmbundle | ||||
|     "bdab9fdc21e6790b479ccb5945b78bc0f6ce2493"  # language-blade | ||||
|   ].freeze | ||||
|  | ||||
|   | ||||
| @@ -73,6 +73,15 @@ class TestHeuristcs < Minitest::Test | ||||
|     }) | ||||
|   end | ||||
|  | ||||
|   def test_cls_by_heuristics | ||||
|     assert_heuristics({ | ||||
|       "TeX" => all_fixtures("TeX", "*.cls"), | ||||
|       nil => all_fixtures("Apex", "*.cls"), | ||||
|       nil => all_fixtures("OpenEdge ABL", "*.cls"), | ||||
|       nil => all_fixtures("Visual Basic", "*.cls"), | ||||
|     }) | ||||
|   end | ||||
|  | ||||
|   def test_cs_by_heuristics | ||||
|     assert_heuristics({ | ||||
|       "C#" => all_fixtures("C#", "*.cs"), | ||||
|   | ||||
| @@ -235,6 +235,7 @@ class TestLanguage < Minitest::Test | ||||
|     assert_equal [Language['Clojure']], Language.find_by_filename('riemann.config') | ||||
|     assert_equal [Language['HTML+Django']], Language.find_by_filename('index.jinja') | ||||
|     assert_equal [Language['Chapel']], Language.find_by_filename('examples/hello.chpl') | ||||
|     assert_equal [], Language.find_by_filename('F.I.L.E.') | ||||
|   end | ||||
|  | ||||
|   def test_find_by_interpreter | ||||
| @@ -426,6 +427,14 @@ class TestLanguage < Minitest::Test | ||||
|     assert missing.empty?, message | ||||
|   end | ||||
|  | ||||
|   def test_all_languages_have_a_valid_id | ||||
|     invalid = Language.all.select { |language| language.language_id < 0 || language.language_id >= (2**31 - 1) } | ||||
|  | ||||
|     message = "The following languages do not have a valid language_id. Please use script/set-language-ids --update as per the contribution guidelines.\n" | ||||
|     invalid.each { |language| message << "#{language.name}\n" } | ||||
|     assert invalid.empty?, message | ||||
|   end | ||||
|  | ||||
|   def test_all_language_id_are_unique | ||||
|     duplicates = Language.all.group_by{ |language| language.language_id }.select { |k, v| v.size > 1 }.map(&:first) | ||||
|  | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/README.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/README.md
									
									
									
									
										vendored
									
									
								
							| @@ -6,6 +6,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting | ||||
| <!-- Everything below this line is auto-generated by script/list-grammars. Manual edits will be lost --> | ||||
| - **1C Enterprise:** [xDrivenDevelopment/atom-language-1c-bsl](https://github.com/xDrivenDevelopment/atom-language-1c-bsl) | ||||
| - **ABAP:** [pvl/abap.tmbundle](https://github.com/pvl/abap.tmbundle) | ||||
| - **ABNF:** [sanssecours/ABNF.tmbundle](https://github.com/sanssecours/ABNF.tmbundle) | ||||
| - **ActionScript:** [simongregory/actionscript3-tmbundle](https://github.com/simongregory/actionscript3-tmbundle) | ||||
| - **Ada:** [textmate/ada.tmbundle](https://github.com/textmate/ada.tmbundle) | ||||
| - **Agda:** [mokus0/Agda.tmbundle](https://github.com/mokus0/Agda.tmbundle) | ||||
| @@ -91,6 +92,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting | ||||
| - **DTrace:** [textmate/c.tmbundle](https://github.com/textmate/c.tmbundle) | ||||
| - **Dylan:** [textmate/dylan.tmbundle](https://github.com/textmate/dylan.tmbundle) | ||||
| - **Eagle:** [textmate/xml.tmbundle](https://github.com/textmate/xml.tmbundle) | ||||
| - **EBNF:** [sanssecours/EBNF.tmbundle](https://github.com/sanssecours/EBNF.tmbundle) | ||||
| - **eC:** [ecere/ec.tmbundle](https://github.com/ecere/ec.tmbundle) | ||||
| - **Ecere Projects:** [textmate/json.tmbundle](https://github.com/textmate/json.tmbundle) | ||||
| - **ECLiPSe:** [alnkpa/sublimeprolog](https://github.com/alnkpa/sublimeprolog) | ||||
| @@ -136,7 +138,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting | ||||
| - **Groovy:** [textmate/groovy.tmbundle](https://github.com/textmate/groovy.tmbundle) | ||||
| - **Groovy Server Pages:** [textmate/java.tmbundle](https://github.com/textmate/java.tmbundle) | ||||
| - **Hack:** [textmate/php.tmbundle](https://github.com/textmate/php.tmbundle) | ||||
| - **Haml:** [textmate/ruby-haml.tmbundle](https://github.com/textmate/ruby-haml.tmbundle) | ||||
| - **Haml:** [ezekg/language-haml](https://github.com/ezekg/language-haml) | ||||
| - **Handlebars:** [daaain/Handlebars](https://github.com/daaain/Handlebars) | ||||
| - **Harbour:** [hernad/atom-language-harbour](https://github.com/hernad/atom-language-harbour) | ||||
| - **Haskell:** [atom-haskell/language-haskell](https://github.com/atom-haskell/language-haskell) | ||||
| @@ -222,7 +224,6 @@ This is a list of grammars that Linguist selects to provide syntax highlighting | ||||
| - **NewLisp:** [textmate/lisp.tmbundle](https://github.com/textmate/lisp.tmbundle) | ||||
| - **Nginx:** [brandonwamboldt/sublime-nginx](https://github.com/brandonwamboldt/sublime-nginx) | ||||
| - **Nimrod:** [Varriount/NimLime](https://github.com/Varriount/NimLime) | ||||
| - **Ninja:** [textmate/ninja.tmbundle](https://github.com/textmate/ninja.tmbundle) | ||||
| - **Nit:** [R4PaSs/Sublime-Nit](https://github.com/R4PaSs/Sublime-Nit) | ||||
| - **Nix:** [wmertens/sublime-nix](https://github.com/wmertens/sublime-nix) | ||||
| - **NSIS:** [github-linguist/NSIS](https://github.com/github-linguist/NSIS) | ||||
| @@ -264,6 +265,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting | ||||
| - **Puppet:** [russCloak/SublimePuppet](https://github.com/russCloak/SublimePuppet) | ||||
| - **PureScript:** [purescript-contrib/atom-language-purescript](https://github.com/purescript-contrib/atom-language-purescript) | ||||
| - **Python:** [MagicStack/MagicPython](https://github.com/MagicStack/MagicPython) | ||||
| - **Python console:** [atom/language-python](https://github.com/atom/language-python) | ||||
| - **Python traceback:** [atom/language-python](https://github.com/atom/language-python) | ||||
| - **QMake:** [textmate/cpp-qt.tmbundle](https://github.com/textmate/cpp-qt.tmbundle) | ||||
| - **QML:** [skozlovf/Sublime-QML](https://github.com/skozlovf/Sublime-QML) | ||||
|   | ||||
							
								
								
									
										1
									
								
								vendor/grammars/language-fontforge
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								vendor/grammars/language-fontforge
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule vendor/grammars/language-fontforge added at b8233304fd
									
								
							
							
								
								
									
										1
									
								
								vendor/grammars/language-haml
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								vendor/grammars/language-haml
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule vendor/grammars/language-haml added at 301625dff4
									
								
							
							
								
								
									
										1
									
								
								vendor/grammars/language-ninja
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								vendor/grammars/language-ninja
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule vendor/grammars/language-ninja added at 207a60371f
									
								
							
							
								
								
									
										18
									
								
								vendor/licenses/grammar/language-fontforge.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								vendor/licenses/grammar/language-fontforge.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| --- | ||||
| type: grammar | ||||
| name: language-fontforge | ||||
| license: isc | ||||
| --- | ||||
| Copyright (c) 2016, John Gardner | ||||
|  | ||||
| Permission to use, copy, modify, and/or distribute this software for any | ||||
| purpose with or without fee is hereby granted, provided that the above | ||||
| copyright notice and this permission notice appear in all copies. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
| WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
| ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
| ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||
| OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
							
								
								
									
										25
									
								
								vendor/licenses/grammar/language-haml.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								vendor/licenses/grammar/language-haml.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| --- | ||||
| type: grammar | ||||
| name: language-haml | ||||
| license: mit | ||||
| --- | ||||
| The MIT License (MIT) | ||||
|  | ||||
| Copyright (c) 2014 Rob Cameron | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||||
| this software and associated documentation files (the "Software"), to deal in | ||||
| the Software without restriction, including without limitation the rights to | ||||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||||
| the Software, and to permit persons to whom the Software is furnished to do so, | ||||
| subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||||
| FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||||
| COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||||
| IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
							
								
								
									
										25
									
								
								vendor/licenses/grammar/language-ninja.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								vendor/licenses/grammar/language-ninja.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| --- | ||||
| type: grammar | ||||
| name: language-ninja | ||||
| license: mit | ||||
| --- | ||||
| Copyright (c) 2015 Kyle Howen | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining | ||||
| a copy of this software and associated documentation files (the | ||||
| "Software"), to deal in the Software without restriction, including | ||||
| without limitation the rights to use, copy, modify, merge, publish, | ||||
| distribute, sublicense, and/or sell copies of the Software, and to | ||||
| permit persons to whom the Software is furnished to do so, subject to | ||||
| the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be | ||||
| included in all copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||
| NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||||
| LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||||
| OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||||
| WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
							
								
								
									
										15
									
								
								vendor/licenses/grammar/ninja.tmbundle.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/licenses/grammar/ninja.tmbundle.txt
									
									
									
									
										vendored
									
									
								
							| @@ -1,15 +0,0 @@ | ||||
| --- | ||||
| type: grammar | ||||
| name: ninja.tmbundle | ||||
| license: permissive | ||||
| curated: true | ||||
| --- | ||||
|  | ||||
| If not otherwise specified (see below), files in this repository fall under the following license: | ||||
|  | ||||
| 	Permission to copy, use, modify, sell and distribute this | ||||
| 	software is granted. This software is provided "as is" without | ||||
| 	express or implied warranty, and with no claim as to its | ||||
| 	suitability for any purpose. | ||||
|  | ||||
| An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”. | ||||
							
								
								
									
										15
									
								
								vendor/licenses/grammar/ruby-haml.tmbundle.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/licenses/grammar/ruby-haml.tmbundle.txt
									
									
									
									
										vendored
									
									
								
							| @@ -1,15 +0,0 @@ | ||||
| --- | ||||
| type: grammar | ||||
| name: ruby-haml.tmbundle | ||||
| license: permissive | ||||
| curated: true | ||||
| --- | ||||
|  | ||||
| If not otherwise specified (see below), files in this repository fall under the following license: | ||||
|  | ||||
| 	Permission to copy, use, modify, sell and distribute this | ||||
| 	software is granted. This software is provided "as is" without | ||||
| 	express or implied warranty, and with no claim as to its | ||||
| 	suitability for any purpose. | ||||
|  | ||||
| An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”. | ||||
		Reference in New Issue
	
	Block a user