Merge branch 'master' into sqlllll

This commit is contained in:
Arfon Smith
2015-02-27 13:32:09 -06:00
79 changed files with 8567 additions and 99 deletions

View File

@@ -236,6 +236,21 @@ module Linguist
name =~ VendoredRegexp ? true : false
end
documentation_paths = YAML.load_file(File.expand_path("../documentation.yml", __FILE__))
DocumentationRegexp = Regexp.new(documentation_paths.join('|'))
# Public: Is the blob in a documentation directory?
#
# Documentation files are ignored by language statistics.
#
# See "documentation.yml" for a list of documentation conventions that match
# this pattern.
#
# Return true or false
def documentation?
name =~ DocumentationRegexp ? true : false
end
# Public: Get each line of data
#
# Requires Blob#data
@@ -317,5 +332,15 @@ module Linguist
def tm_scope
language && language.tm_scope
end
DETECTABLE_TYPES = [:programming, :markup].freeze
# Internal: Should this blob be included in repository language statistics?
def include_in_language_stats?
!vendored? &&
!documentation? &&
!generated? &&
language && DETECTABLE_TYPES.include?(language.type)
end
end
end

View File

@@ -0,0 +1,23 @@
# Documentation files and directories are excluded from language
# statistics.
#
# Lines in this file are Regexps that are matched against the file
# pathname.
#
# Please add additional test coverage to
# `test/test_blob.rb#test_documentation` if you make any changes.
## Documentation directories ##
- ^docs?/
- (^|/)[Dd]ocumentation/
- (^|/)javadoc/
- ^man/
## Documentation files ##
- (^|/)CONTRIBUTING(\.|$)
- (^|/)COPYING(\.|$)
- (^|/)INSTALL(\.|$)
- (^|/)LICEN[CS]E(\.|$)
- (^|/)README(\.|$)

View File

@@ -62,6 +62,7 @@ module Linguist
generated_parser? ||
generated_net_docfile? ||
generated_postscript? ||
generated_protocol_buffer_go? ||
generated_protocol_buffer? ||
generated_jni_header? ||
vcr_cassette?
@@ -202,6 +203,13 @@ module Linguist
creator.include?("ImageMagick")
end
def generated_protocol_buffer_go?
return false unless extname == '.go'
return false unless lines.count > 1
return lines[0].include?("Code generated by protoc-gen-go")
end
# Internal: Is the blob a C++, Java or Python source file generated by the
# Protocol Buffer compiler?
#

View File

@@ -92,7 +92,7 @@ module Linguist
disambiguate "Perl", "Perl6", "Prolog" do |data|
if data.include?("use v6")
Language["Perl6"]
elsif data.include?("use strict")
elsif data.match(/use strict|use\s+v?5\./)
Language["Perl"]
elsif data.include?(":-")
Language["Prolog"]
@@ -107,10 +107,14 @@ module Linguist
end
end
disambiguate "IDL", "Prolog" do |data|
disambiguate "IDL", "Prolog", "INI", "QMake" do |data|
if data.include?(":-")
Language["Prolog"]
else
elsif data.include?("last_client=")
Language["INI"]
elsif data.include?("HEADERS") && data.include?("SOURCES")
Language["QMake"]
elsif /^\s*function[ \w,]+$/.match(data)
Language["IDL"]
end
end
@@ -150,14 +154,20 @@ module Linguist
end
end
disambiguate "AsciiDoc", "AGS Script" do |data|
Language["AsciiDoc"] if /^=+(\s|\n)/.match(data)
disambiguate "AsciiDoc", "AGS Script", "Public Key" do |data|
if /^[=-]+(\s|\n)|{{[A-Za-z]/.match(data)
Language["AsciiDoc"]
elsif /^(\/\/.+|((import|export)\s+)?(function|int|float|char)\s+((room|repeatedly|on|game)_)?([A-Za-z]+[A-Za-z_0-9]+)\s*[;\(])/.match(data)
Language["AGS Script"]
elsif /^-----BEGIN/.match(data)
Language["Public Key"]
end
end
disambiguate "FORTRAN", "Forth" do |data|
if /^: /.match(data)
Language["Forth"]
elsif /^([c*][^a-z]| (subroutine|program)\s|!)/i.match(data)
elsif /^([c*][^a-z]| (subroutine|program)\s|\s*!)/i.match(data)
Language["FORTRAN"]
end
end
@@ -172,11 +182,13 @@ module Linguist
end
end
disambiguate "M", "Mathematica", "Matlab", "Mercury", "Objective-C" do |data|
disambiguate "M", "MUF", "Mathematica", "Matlab", "Mercury", "Objective-C" do |data|
if ObjectiveCRegex.match(data)
Language["Objective-C"]
elsif data.include?(":- module")
Language["Mercury"]
elsif /^: /.match(data)
Language["MUF"]
elsif /^\s*;/.match(data)
Language["M"]
elsif /^\s*\(\*/.match(data)
@@ -223,23 +235,33 @@ module Linguist
Language["Text"]
end
end
disambiguate "PLSQL", "SQLPL", "PLpgSQL", "SQL" do |data|
#only return value if a definite positive
if /^\\i\b|AS \$\$|LANGUAGE '+plpgsql'+/i.match(data) || /SECURITY (DEFINER|INVOKER)/i.match(data) || /BEGIN( WORK| TRANSACTION)?;/i.match(data)
#postgres
Language["PLpgSQL"]
Language["PLpgSQL"]
elsif /(alter module)|(language sql)|(begin( NOT)+ atomic)/i.match(data) || /signal SQLSTATE '[0-9]+'/i.match(data)
#ibm db2
Language["SQLPL"]
Language["SQLPL"]
elsif /pragma|\$\$PLSQL_|XMLTYPE|sysdate|systimestamp|\.nextval|connect by|AUTHID (DEFINER|CURRENT_USER)/i.match(data) || /constructor\W+function/i.match(data)
#oraclestuff
Language["PLSQL"]
elsif ! /begin|boolean|package|exception/i.match(data)
Language["PLSQL"]
elsif ! /begin|boolean|package|exception/i.match(data)
#generic sql
Language["SQL"]
Language["SQL"]
end
end
disambiguate "D", "DTrace", "Makefile" do |data|
if /^module /.match(data)
Language["D"]
elsif /^((dtrace:::)?BEGIN|provider |#pragma (D (option|attributes)|ident)\s)/.match(data)
Language["DTrace"]
elsif /(\/.*:( .* \\)$| : \\$|^ : |: \\$)/.match(data)
Language["Makefile"]
end
end
end
end

View File

@@ -32,13 +32,6 @@ module Linguist
# Valid Languages types
TYPES = [:data, :markup, :programming, :prose]
# Names of non-programming languages that we will still detect
#
# Returns an array
def self.detectable_markup
["CSS", "Less", "Sass", "SCSS", "Stylus", "TeX"]
end
# Detect languages by a specific type
#
# type - A symbol that exists within TYPES
@@ -96,8 +89,8 @@ module Linguist
STRATEGIES = [
Linguist::Strategy::Modeline,
Linguist::Strategy::Filename,
Linguist::Shebang,
Linguist::Strategy::Filename,
Linguist::Heuristics,
Linguist::Classifier
]

View File

@@ -186,7 +186,7 @@ AsciiDoc:
- .asciidoc
- .adoc
- .asc
tm_scope: none
tm_scope: text.html.asciidoc
AspectJ:
type: programming
@@ -198,7 +198,7 @@ AspectJ:
Assembly:
type: programming
color: "#a67219"
color: "#6E4C13"
search_term: nasm
aliases:
- nasm
@@ -206,6 +206,7 @@ Assembly:
- .asm
- .ASM
- .a51
- .nasm
tm_scope: source.asm.x86
ace_mode: assembly_x86
@@ -270,6 +271,7 @@ Batchfile:
ace_mode: batchfile
Befunge:
type: programming
extensions:
- .befunge
ace_mode: text
@@ -325,6 +327,7 @@ Boo:
ace_mode: text
Brainfuck:
type: programming
extensions:
- .b
- .bf
@@ -335,7 +338,7 @@ Brightscript:
type: programming
extensions:
- .brs
tm_scope: none
tm_scope: source.brightscript
ace_mode: text
Bro:
@@ -355,6 +358,8 @@ C:
- .h
- .idc
- .w
interpreters:
- tcc
ace_mode: c_cpp
C#:
@@ -418,6 +423,7 @@ CLIPS:
ace_mode: text
CMake:
type: programming
extensions:
- .cmake
- .cmake.in
@@ -438,6 +444,8 @@ COBOL:
ace_mode: cobol
CSS:
type: markup
tm_scope: source.css
ace_mode: css
color: "#563d7c"
extensions:
@@ -475,6 +483,7 @@ Chapel:
ace_mode: text
ChucK:
type: programming
extensions:
- .ck
tm_scope: source.java
@@ -636,6 +645,7 @@ Crystal:
- crystal
Cucumber:
type: programming
extensions:
- .feature
tm_scope: text.gherkin.feature
@@ -694,7 +704,17 @@ DM:
tm_scope: source.c++
ace_mode: c_cpp
DTrace:
type: programming
extensions:
- .d
interpreters:
- dtrace
tm_scope: source.c
ace_mode: c_cpp
Darcs Patch:
type: programming
search_term: dpatch
aliases:
- dpatch
@@ -712,6 +732,7 @@ Dart:
ace_mode: dart
Diff:
type: programming
extensions:
- .diff
- .patch
@@ -961,7 +982,7 @@ GAP:
- .gd
- .gi
- .tst
tm_scope: none
tm_scope: source.gap
ace_mode: text
GAS:
@@ -1009,6 +1030,7 @@ Game Maker Language:
ace_mode: c_cpp
Genshi:
type: programming
extensions:
- .kid
tm_scope: text.xml.genshi
@@ -1018,6 +1040,7 @@ Genshi:
ace_mode: xml
Gentoo Ebuild:
type: programming
group: Shell
extensions:
- .ebuild
@@ -1025,6 +1048,7 @@ Gentoo Ebuild:
ace_mode: sh
Gentoo Eclass:
type: programming
group: Shell
extensions:
- .eclass
@@ -1032,6 +1056,7 @@ Gentoo Eclass:
ace_mode: sh
Gettext Catalog:
type: programming
search_term: pot
searchable: false
aliases:
@@ -1132,6 +1157,7 @@ Graphviz (DOT):
ace_mode: text
Groff:
type: programming
extensions:
- .man
- '.1'
@@ -1159,6 +1185,7 @@ Groovy:
- groovy
Groovy Server Pages:
type: programming
group: Groovy
aliases:
- gsp
@@ -1172,6 +1199,7 @@ HTML:
type: markup
tm_scope: text.html.basic
ace_mode: html
color: "#e44b23"
aliases:
- xhtml
extensions:
@@ -1307,6 +1335,7 @@ INI:
- .ini
- .cfg
- .prefs
- .pro
- .properties
tm_scope: source.ini
aliases:
@@ -1314,6 +1343,7 @@ INI:
ace_mode: ini
IRC log:
type: data
search_term: irc
aliases:
- irc
@@ -1344,6 +1374,7 @@ Inform 7:
ace_mode: text
Inno Setup:
type: programming
extensions:
- .iss
tm_scope: source.inno
@@ -1375,6 +1406,7 @@ Isabelle:
J:
type: programming
color: "#2d8abd"
extensions:
- .ijs
tm_scope: source.j
@@ -1438,6 +1470,7 @@ Java:
- .java
Java Server Pages:
type: programming
group: Java
search_term: jsp
aliases:
@@ -1533,6 +1566,7 @@ LFE:
ace_mode: lisp
LLVM:
type: programming
extensions:
- .ll
ace_mode: text
@@ -1584,6 +1618,13 @@ Latte:
tm_scope: source.smarty
ace_mode: smarty
Lean:
type: programming
extensions:
- .lean
- .hlean
ace_mode: lean
Less:
type: markup
group: CSS
@@ -1593,6 +1634,7 @@ Less:
ace_mode: less
LilyPond:
type: programming
extensions:
- .ly
- .ily
@@ -1713,6 +1755,15 @@ MTML:
tm_scope: text.html.basic
ace_mode: html
MUF:
type: programming
group: Forth
extensions:
- .muf
- .m
tm_scope: none
ace_mode: forth
Makefile:
type: programming
aliases:
@@ -1721,6 +1772,7 @@ Makefile:
- mf
extensions:
- .mak
- .d
- .mk
filenames:
- GNUmakefile
@@ -1731,6 +1783,7 @@ Makefile:
ace_mode: makefile
Mako:
type: programming
extensions:
- .mako
- .mao
@@ -1767,6 +1820,8 @@ Mathematica:
- .ma
- .nb
- .nbp
- .wl
- .wlt
aliases:
- mma
ace_mode: text
@@ -1823,6 +1878,7 @@ Mercury:
ace_mode: prolog
MiniD: # Legacy
type: programming
searchable: false
extensions:
- .minid # Dummy extension
@@ -1870,12 +1926,14 @@ MoonScript:
ace_mode: text
Myghty:
type: programming
extensions:
- .myt
tm_scope: none
ace_mode: text
NSIS:
type: programming
extensions:
- .nsi
- .nsh
@@ -1967,6 +2025,7 @@ Nu:
- nush
NumPy:
type: programming
group: Python
extensions:
- .numpy
@@ -2052,7 +2111,7 @@ Opal:
color: "#f7ede0"
extensions:
- .opal
tm_scope: none
tm_scope: source.opal
ace_mode: text
OpenCL:
@@ -2080,7 +2139,7 @@ OpenSCAD:
type: programming
extensions:
- .scad
tm_scope: none
tm_scope: source.scad
ace_mode: scad
Org:
@@ -2178,7 +2237,7 @@ Papyrus:
color: "#6600cc"
extensions:
- .psc
tm_scope: none
tm_scope: source.papyrus
ace_mode: text
Parrot:
@@ -2270,7 +2329,7 @@ PigLatin:
color: "#fcd7de"
extensions:
- .pig
tm_scope: none
tm_scope: source.pig_latin
ace_mode: text
Pike:
@@ -2296,7 +2355,7 @@ PogoScript:
color: "#d80074"
extensions:
- .pogo
tm_scope: none
tm_scope: source.pogoscript
ace_mode: text
PostScript:
@@ -2343,7 +2402,7 @@ Propeller Spin:
color: "#2b446d"
extensions:
- .spin
tm_scope: none
tm_scope: source.spin
ace_mode: text
Protocol Buffer:
@@ -2446,6 +2505,7 @@ QML:
ace_mode: text
QMake:
type: programming
extensions:
- .pro
- .pri
@@ -2542,6 +2602,7 @@ Ragel in Ruby Host:
ace_mode: text
Raw token data:
type: data
search_term: raw
aliases:
- raw
@@ -2573,6 +2634,7 @@ Red:
ace_mode: text
Redcode:
type: programming
extensions:
- .cw
tm_scope: none
@@ -2712,6 +2774,13 @@ STON:
tm_scope: source.smalltalk
ace_mode: text
SVG:
type: data
extensions:
- .svg
tm_scope: text.xml
ace_mode: xml
Sage:
type: programming
group: Python
@@ -2861,6 +2930,7 @@ Smalltalk:
ace_mode: text
Smarty:
type: programming
extensions:
- .tpl
ace_mode: smarty
@@ -2912,7 +2982,7 @@ Stylus:
group: CSS
extensions:
- .styl
tm_scope: none
tm_scope: source.stylus
ace_mode: stylus
SuperCollider:
@@ -3083,11 +3153,11 @@ UnrealScript:
VCL:
type: programming
ace_mode: perl
color: "#0298c3"
extensions:
- .vcl
tm_scope: source.perl
tm_scope: source.varnish.vcl
ace_mode: text
VHDL:
type: programming
@@ -3183,7 +3253,7 @@ XC:
ace_mode: c_cpp
XML:
type: markup
type: data
ace_mode: xml
aliases:
- rss
@@ -3227,7 +3297,6 @@ XML:
- .srdf
- .stTheme
- .sublime-snippet
- .svg
- .targets
- .tmCommand
- .tmLanguage
@@ -3285,6 +3354,7 @@ XQuery:
ace_mode: xquery
XS:
type: programming
extensions:
- .xs
tm_scope: source.c
@@ -3381,6 +3451,7 @@ fish:
ace_mode: text
mupad:
type: programming
extensions:
- .mu
ace_mode: text

View File

@@ -4,7 +4,7 @@ require 'rugged'
module Linguist
class LazyBlob
GIT_ATTR = ['linguist-language', 'linguist-vendored']
GIT_ATTR = ['linguist-documentation', 'linguist-language', 'linguist-vendored']
GIT_ATTR_OPTS = { :priority => [:index], :skip_system => true }
GIT_ATTR_FLAGS = Rugged::Repository::Attributes.parse_opts(GIT_ATTR_OPTS)
@@ -37,11 +37,19 @@ module Linguist
end
end
def documentation?
if attr = git_attributes['linguist-documentation']
boolean_attribute(attr)
else
super
end
end
def language
return @language if defined?(@language)
@language = if lang = git_attributes['linguist-language']
Language.find_by_name(lang)
Language.find_by_alias(lang)
else
super
end

View File

@@ -156,13 +156,8 @@ module Linguist
blob = Linguist::LazyBlob.new(repository, delta.new_file[:oid], new, mode.to_s(8))
# Skip vendored or generated blobs
next if blob.vendored? || blob.generated? || blob.language.nil?
# Only include programming languages and acceptable markup languages
if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name)
file_map[new] = [blob.language.group.name, blob.size]
end
next unless blob.include_in_language_stats?
file_map[new] = [blob.language.group.name, blob.size]
end
end

View File

@@ -251,3 +251,6 @@
# ProGuard
- proguard.pro
- proguard-rules.pro
# Android Google APIs
- (^|/)\.google_apis/

View File

@@ -1,3 +1,3 @@
module Linguist
VERSION = "4.3.1"
VERSION = "4.4.2"
end