mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	
			
				
					
						
					
					3ea66af17863121ec7dd84940d18f10cee7f4ee2
				
			
			
		
	Linguist
We use this library on GitHub to detect file language types for syntax highlighting, ignore binary files, suppress generated code in diffs and generate language breakdown graphs.
Features
Language detection
- Common extensions
- Shebang
- C header files (C/C++/Obj-C)
Binary detection
Generated file detection
- Generated JS files (minified js, compiled CoffeeScript)
- Generated config files (Xcode project files and nibs)
Ignore vendored libs
- Ignores common vendored libs conventions (deps/, vendor/, jquery, prototype)
Stats
- Generates project LOC stats
Usage
file = Linguist::Blob.new("linguist.rb")
file.language.name #=> "Ruby"
file = Linguist::Blob.new("linguist.gem")
file.binary? #=> true
project = Linguist::Repository.new(".")
project.language.name  #=> "Ruby"
project.languages      #=> { "Ruby" => 0.98, "Shell" => 0.02 }
Contributing
Once you've made your great commits:
- Fork it.
- Create a branch (git checkout -b detect-foo-language)
- Commit your changes (git commit -am "Added detection for the new Foo language")
- Push to the branch (git push origin detect-foo-language)
- Create a Pull Request from your branch.
- Promote it. Mention a public repository to demostration the value of your changes. Get others to drop in and 👍 it.
					Languages
				
				
								
								
									Ruby
								
								68.7%
							
						
							
								
								
									C
								
								22.3%
							
						
							
								
								
									Go
								
								7.1%
							
						
							
								
								
									Lex
								
								1.2%
							
						
							
								
								
									Shell
								
								0.4%
							
						
							
								
								
									Other
								
								0.3%