Suppress .NET XML Intellisense generated files

This commit is contained in:
Paul Betts
2011-08-03 12:09:36 -07:00
parent adb436706d
commit 0f1c9c48fa
3 changed files with 1146 additions and 1 deletions

View File

@@ -181,7 +181,7 @@ module Linguist
def generated?
if xcode_project_file? || visual_studio_project_file?
true
elsif generated_coffeescript? || minified_javascript?
elsif generated_coffeescript? || minified_javascript? || generated_net_docfile?
true
else
false
@@ -255,6 +255,27 @@ module Linguist
end
end
# Internal: Is this a generated documentation file for a .NET assembly?
#
# Requires Blob#data
#
# .NET developers often check in the XML Intellisense file along with an
# assembly - however, these don't have a special extension, so we have to
# dig into the contents to determine if it's a docfile. Luckily, these files
# are extremely structured, so recognizing them is easy.
#
# Returns true or false
def generated_net_docfile?
return false unless extname == ".xml"
return false unless lines.count > 3
# .NET Docfiles always open with <doc> and their first tag is an
# <assembly> tag
return lines[1].include?("<doc>") &&
lines[2].include?("<assembly>") &&
lines[-2].include?("</doc>")
end
# Public: Should the blob be indexed for searching?
#
# Excluded:

1121
test/fixtures/net_docfile.xml vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -136,6 +136,9 @@ class TestBlob < Test::Unit::TestCase
assert blob("project.resx").generated?
assert blob("project.sln").generated?
# Generated .NET Docfiles
assert blob("net_docfile.xml").generated?
# Long line
assert !blob("uglify.js").generated?