mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Exclude documentation files from language statistics
Documentation is an important part of a software project but is not generally thought of as part of the code for that project. Repository language statistics are used to quantify the project's code, so it makes sense to exclude documentation from those computations. Documentation files are recognized similarly to vendored files. lib/linguist/documentation.yml contains regular expressions to match common names for documentation files. A new linguist-documentation Git attribute can be used to override those conventions.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user