Minor docs update #fixes 1581

This commit is contained in:
Arfon Smith
2014-10-13 14:48:04 -05:00
parent 769f1b8658
commit a69b20c1a4

View File

@@ -32,33 +32,56 @@ The Language stats bar that you see on every repository is built by aggregating
The repository stats API, accessed through `#languages`, can be used on a directory: The repository stats API, accessed through `#languages`, can be used on a directory:
***API UPDATE***
Since [Version 3.0.0](https://github.com/github/linguist/releases/tag/v3.0.0) Linguist requires a git repository (in the form of a [Rugged::Repository](https://github.com/libgit2/rugged#repositories)) to be passed when initializing `Linguist::Repository`.
```ruby ```ruby
project = Linguist::Repository.from_directory(".") require 'rugged'
project.language.name #=> "Ruby" require 'linguist'
project.languages #=> { "Ruby" => 0.98, "Shell" => 0.02 }
repo = Rugged::Repository.new('.')
project = Linguist::Repository.new(repo, repo.head.target_id)
project.language #=> "Ruby"
project.languages #=> { "Ruby" => 119387 }
``` ```
These stats are also printed out by the `linguist` binary. You can use the These stats are also printed out by the `linguist` binary. You can use the
`--breakdown` flag, and the binary will also output the breakdown of files by language. `--breakdown` flag, and the binary will also output the breakdown of files by language.
You can try running `linguist` on the `lib/` directory in this repository itself: You can try running `linguist` on the root directory in this repository itself:
$ bundle exec linguist lib/ --breakdown $ bundle exec linguist --breakdown
100.00% Ruby 100.00% Ruby
Ruby: Ruby:
linguist/blob_helper.rb Gemfile
linguist/classifier.rb Rakefile
linguist/file_blob.rb bin/linguist
linguist/generated.rb github-linguist.gemspec
linguist/heuristics.rb lib/linguist.rb
linguist/language.rb lib/linguist/blob_helper.rb
linguist/md5.rb lib/linguist/classifier.rb
linguist/repository.rb lib/linguist/file_blob.rb
linguist/samples.rb lib/linguist/generated.rb
linguist/tokenizer.rb lib/linguist/heuristics.rb
linguist.rb lib/linguist/language.rb
lib/linguist/lazy_blob.rb
lib/linguist/md5.rb
lib/linguist/repository.rb
lib/linguist/samples.rb
lib/linguist/tokenizer.rb
lib/linguist/version.rb
test/test_blob.rb
test/test_classifier.rb
test/test_heuristics.rb
test/test_language.rb
test/test_md5.rb
test/test_pedantic.rb
test/test_repository.rb
test/test_samples.rb
test/test_tokenizer.rb
#### Ignore vendored files #### Ignore vendored files