失心是什么字| 什么万千| 肥肠炖什么好吃| 头发定型用什么好| 梦到自己掉头发是什么预兆| 幽门螺杆菌阳性吃什么药| 吃什么东西补气血| 白细胞偏高是什么原因引起的| 什么是胸推| 什么人容易高原反应| 战五渣是什么意思| 发烧输液输的是什么药| af是什么| 鼻子下面长痘什么原因| 红醋是什么醋| 多吃黄瓜有什么好处| 肝功能异常是什么| 毛囊炎用什么药| 肿瘤吃什么中药能消除| 宝宝风寒感冒吃什么药最好| 四月份是什么季节| 身上痒但是什么都没有| 萨瓦迪卡什么意思| 鳕鱼是什么鱼| 与狼共舞什么意思| 70年出生属什么生肖| 藿香正气水治什么| 高冷是什么意思| 猪油吃多了有什么好处和坏处| 泛化是什么意思| 什么是感光食物| 肉丝炒什么菜好吃| 幽门螺杆菌感染吃什么药| 三七粉主要治疗什么病| 住院门槛费是什么意思| 胎停是什么原因造成的| 贝母是什么| 突然头晕恶心是什么原因| 小妾是什么意思| 减肥期间适合吃什么| gccg是什么牌子| tsh代表什么| 只羡鸳鸯不羡仙是什么意思| 智齿疼吃什么药| ala是什么氨基酸| 药物流产后需要注意什么| 张紫妍为什么自杀| 尿酸偏高有什么危害| 什么样的人不能献血| 为什么额头反复长痘痘| 尿酸高什么原因引起的| 亚撒西是什么意思| 肛门坠胀吃什么消炎药| 月经不停吃什么药止血效果比较好| 暗房是什么意思| 迪士尼是什么意思| 脑癌是什么原因引起的| 室性期前收缩是什么病| 妈妈的表姐叫什么| 肝阳性是什么意思| 尿酮体是什么| 明天叫什么日| 唯小人与女子难养也什么意思| 鲥鱼是什么鱼| 肝胃不和吃什么药| 必修是什么意思| 尿肌酐低说明什么| 检查脖子挂什么科| 咖啡有什么营养| 什么的笋| 妮子什么意思| 核心抗体阳性是什么意思| 21速和24速有什么区别| 预防医学是什么| 合肥为什么叫合肥| 愚是什么意思| 白芽奇兰是什么茶| 痛风什么原因引起| 前列腺增生吃什么食物好| 传统是什么意思| 急性心力衰竭的急救措施是什么| 闲云野鹤指什么生肖| 芒果是什么季节的水果| 早上九点半是什么时辰| 什么衣服| 红馆是什么地方| 7777什么意思| 阴道痒用什么药好| 什么叫有气质| 眉毛上长痘是什么原因| 世界上最长的河流是什么| 十月十日是什么星座| 腱鞘炎用什么药治疗| 女人什么发型最有气质| 每天喝豆浆有什么好处| 0706是什么星座| 碘酒是什么| 静脉曲张用什么药| 肛门坠胀吃什么药| 女团是什么意思| 乘风破浪的意思是什么| 南京有什么好玩的地方| 家慈是什么意思| 生肖羊生什么生肖最好| 结缡什么意思| 尿毒症挂什么科| 靶向治疗是什么意思| legacy什么意思| 手指缝里长水泡还痒是什么原因| 什么是闰年什么是平年| 单丛属于什么茶| 米鱼是什么鱼| 肌膜炎是什么原因造成的| 乘的部首是什么| 有鳞状细胞是什么意思| 东成西就是什么生肖| 孕妇梦见洪水是什么意思| 滑膜炎什么症状| spa按摩是什么意思| alan什么意思| 什么叫专科| 蒸鱼豉油什么时候放| 包皮是什么| 肛塞是什么| 孕妇吃什么胎儿智商高| 正方形的纸能折什么| 血压低压高是什么原因造成的| 包皮与包茎有什么区别| CRL是胎儿的什么意思| 既往病史是什么意思| 属牛配什么属相最好| 葫芦什么时候开花| 什么级别可以配秘书| 飞行模式有什么用| 痛风用什么药| 婚检能检查出什么| 桓是什么意思| 什么是职业| 左侧卵巢囊性包块是什么意思| 两女一杯什么意思| 有趣的什么填空| 土人参长什么样| 考研都考什么科目| 故宫什么时候闭馆| lc是什么意思| 胃痛去药店买什么药| 什么叫脑梗| 一个虫一个夫念什么| 空调开什么模式最凉快| 甘油三酯高吃什么能降下来| 肚子疼吃什么| 道是什么意思| 加油站为什么不能打电话| nothomme什么牌子| 肾病吃什么水果好| 84是什么意思| 冬练三九夏练三伏是什么意思| 人放屁多是什么原因| DHL是什么| e抗原阳性是什么意思| 铁树开花是什么生肖| 窦性心动过缓什么意思| 恍恍惚惚什么意思| AMY医学上是什么意思| 血糖高一日三餐吃什么东西最适合| 120是什么意思| 小女子这厢有礼了什么意思| 9月3号是什么日子| 带状疱疹挂什么科| 眼皮发肿是什么原因| 女内分泌检查什么项目| 静脉曲张是什么病| 什么叫谈恋爱| 胃溃疡是什么原因导致的| 女性经常手淫有什么危害| 糖吃多了有什么危害| 胃病忌什么| 准确值是什么意思| size是什么意思| 进是什么结构| 甲状腺吃什么盐好| 包皮痒用什么药| 为什么小脑会萎缩| 装垃圾的工具叫什么| 爸爸的哥哥叫什么| 天经地义的意思是什么| mlb中文叫什么| h皮带是什么牌子| 记性不好吃什么药| 成年人改名字需要什么手续| 腹泻吃什么食物好| 火耗归公是什么意思| 升阳是什么意思| 波字五行属什么| 蜡笔小新的爸爸叫什么| 勿误是什么意思| clinic是什么意思| hot什么意思| 女人骨质疏松吃什么最好| 为什么会得干眼症| 我炸了是什么意思| 端字五行属什么| 孺子可教也什么意思| 出恭什么意思| 什么的嗓音| 什么是中线| 1991年什么命| eva鞋底是什么材质| 收是什么生肖| 好整以暇什么意思| 扁平足是什么意思| 秦始皇的名字叫什么| 手上的三条线分别代表什么| 辛弃疾字什么| 语文是什么意思| 92年属猴的是什么命| 梦到拔牙是什么预兆| 11月30号是什么星座| 朔字五行属什么| 肺寒吃什么药| 高血压高血糖能吃什么水果| 白带有血丝是什么原因| 肿瘤患者吃什么药可以抑制肿瘤| 尿酸520属于什么水平| 扒皮是什么意思| 胆囊壁毛糙吃什么药效果好| 梦见蛀牙掉是什么预兆| 眉毛里有痣代表什么| 敦伦是什么意思| 心脏有个小洞叫什么病| 水的ph值是什么意思| 假正经是什么意思| 翠绿色配什么颜色好看| 木薯是什么东西| 占有欲强什么意思| 一孕傻三年是什么意思| 什么是撤退性出血| 肺部斑片状高密度影是什么意思| 什么的水流| 拉稀肚子疼吃什么药| 宫颈肥大是什么原因造成的| 刀鱼和带鱼有什么区别| 台风什么时候登陆| 先祖是什么意思| 西周王陵为什么找不到| 皇帝的新装是什么意思| 打call是什么意思| 手指没有月牙是什么原因| 小学什么时候期末考试| 飞蚊症是什么原因引起的| 喝什么茶可以减肥| wedding什么意思| 心肌炎查什么能查出来| 结肠炎吃什么药治疗效果好| 公积金取出来有什么影响| 眉心跳动代表什么预兆| 咳嗽可以吃什么| 媚眼如丝是什么意思| 血糖用什么字母表示| 沉沦是什么意思| pi是什么| 什么叫三观| 阿奇霉素主治什么| pending是什么状态| 百度
Skip to content

github-linguist/linguist

Repository files navigation

Linguist

Actions Status

Open in GitHub Codespaces

This library is used on GitHub.com to detect blob languages, ignore binary or vendored files, suppress generated files in diffs, and generate language breakdown graphs.

Documentation

Installation

Install the gem:

gem install github-linguist

Dependencies

Linguist is a Ruby library so you will need a recent version of Ruby installed. There are known problems with the macOS/Xcode supplied version of Ruby that causes problems installing some of the dependencies. Accordingly, we highly recommend you install a version of Ruby using Homebrew, rbenv, rvm, ruby-build, asdf or other packaging system, before attempting to install Linguist and the dependencies.

Linguist uses charlock_holmes for character encoding and rugged for libgit2 bindings for Ruby. These components have their own dependencies.

  1. charlock_holmes
  2. rugged

You may need to install missing dependencies before you can install Linguist. For example, on macOS with Homebrew:

brew install cmake pkg-config icu4c

On Ubuntu:

sudo apt-get install build-essential cmake pkg-config libicu-dev zlib1g-dev libcurl4-openssl-dev libssl-dev ruby-dev

Usage

Application usage

Linguist can be used in your application as follows:

require 'rugged'
require 'linguist'

repo = Rugged::Repository.new('.')
project = Linguist::Repository.new(repo, repo.head.target_id)
project.language       #=> "Ruby"
project.languages      #=> { "Ruby" => 119387 }

Command line usage

Git Repository

A repository's languages stats can also be assessed from the command line using the github-linguist executable. Without any options, github-linguist will output the language breakdown by percentage and file size.

cd /path-to-repository
github-linguist

You can try running github-linguist on the root directory in this repository itself:

$ github-linguist
66.84%  264519     Ruby
24.68%  97685      C
6.57%   25999      Go
1.29%   5098       Lex
0.32%   1257       Shell
0.31%   1212       Dockerfile

Additional options

--rev REV

The --rev REV flag will change the git revision being analyzed to any gitrevisions(1) compatible revision you specify.

This is useful to analyze the makeup of a repo as of a certain tag, or in a certain branch.

For example, here is the popular Jekyll open source project.

$ github-linguist jekyll

70.64%  709959     Ruby
23.04%  231555     Gherkin
3.80%   38178      JavaScript
1.19%   11943      HTML
0.79%   7900       Shell
0.23%   2279       Dockerfile
0.13%   1344       Earthly
0.10%   1019       CSS
0.06%   606        SCSS
0.02%   234        CoffeeScript
0.01%   90         Hack

And here is Jekyll's published website, from the gh-pages branch inside their repository.

$ github-linguist jekyll --rev origin/gh-pages
100.00% 2568354    HTML
--breakdown

The --breakdown or -b flag will additionally show the breakdown of files by language.

You can try running github-linguist on the root directory in this repository itself:

$ github-linguist --breakdown
66.84%  264519     Ruby
24.68%  97685      C
6.57%   25999      Go
1.29%   5098       Lex
0.32%   1257       Shell
0.31%   1212       Dockerfile

Ruby:
Gemfile
Rakefile
bin/git-linguist
bin/github-linguist
ext/linguist/extconf.rb
github-linguist.gemspec
lib/linguist.rb
--json

The --json or -j flag output the data into JSON format.

$ github-linguist --json
{"Dockerfile":{"size":1212,"percentage":"0.31"},"Ruby":{"size":264519,"percentage":"66.84"},"C":{"size":97685,"percentage":"24.68"},"Lex":{"size":5098,"percentage":"1.29"},"Shell":{"size":1257,"percentage":"0.32"},"Go":{"size":25999,"percentage":"6.57"}}

This option can be used in conjunction with --breakdown to get a full list of files along with the size and percentage data.

$ github-linguist --breakdown --json
{"Dockerfile":{"size":1212,"percentage":"0.31","files":["Dockerfile","tools/grammars/Dockerfile"]},"Ruby":{"size":264519,"percentage":"66.84","files":["Gemfile","Rakefile","bin/git-linguist","bin/github-linguist","ext/linguist/extconf.rb","github-linguist.gemspec","lib/linguist.rb",...]}}

Single file

Alternatively you can find stats for a single file using the github-linguist executable.

You can try running github-linguist on files in this repository itself:

$ github-linguist grammars.yml
grammars.yml: 884 lines (884 sloc)
  type:      Text
  mime type: text/x-yaml
  language:  YAML

Docker

If you have Docker installed you can build an image and run Linguist within a container:

$ docker build -t linguist .
$ docker run --rm -v $(pwd):$(pwd):Z -w $(pwd) -t linguist
66.84%  264519     Ruby
24.68%  97685      C
6.57%   25999      Go
1.29%   5098       Lex
0.32%   1257       Shell
0.31%   1212       Dockerfile
$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -t linguist github-linguist --breakdown
66.84%  264519     Ruby
24.68%  97685      C
6.57%   25999      Go
1.29%   5098       Lex
0.32%   1257       Shell
0.31%   1212       Dockerfile

Ruby:
Gemfile
Rakefile
bin/git-linguist
bin/github-linguist
ext/linguist/extconf.rb
github-linguist.gemspec
lib/linguist.rb

Contributing

Please check out our contributing guidelines.

License

The language grammars included in this gem are covered by their repositories' respective licenses. vendor/README.md lists the repository for each grammar.

All other files are covered by the MIT license, see LICENSE.

肾虚是什么原因 吃蓝莓有什么好处 原木色是什么颜色 0m是什么意思 意阑珊什么意思
明天是什么日子 7月15日是什么星座 头癣用什么药膏最好 小孩牙疼有什么办法 减肥吃什么肉类
考是什么意思 泡面吃多了有什么危害 霸王花煲汤放什么材料 聊胜于无什么意思 6.30什么星座
头部容易出汗是什么原因 2018 年是什么年 谨字五行属什么 脂蛋白a高吃什么能降下来 白羊座是什么象星座
婴儿咳嗽用什么药hcv7jop9ns7r.cn 秦始皇的佩剑叫什么剑hcv7jop4ns5r.cn 白矾是什么hcv8jop2ns5r.cn 菜心是什么菜zhiyanzhang.com 经常肚子痛什么原因hcv8jop9ns6r.cn
空调外机为什么会滴水hcv8jop7ns8r.cn 红眼病有什么症状hcv7jop6ns3r.cn 七宗罪是什么hcv9jop0ns0r.cn 吃什么水果可以护肝hcv8jop8ns8r.cn 前置是什么意思liaochangning.com
嘴巴苦是什么原因hcv9jop6ns4r.cn 孩子肚子有虫子有什么症状hcv9jop2ns6r.cn 寻常疣是什么原因造成的hcv8jop0ns5r.cn 青蛙为什么叫hcv8jop8ns6r.cn 法医是干什么的hcv7jop7ns1r.cn
手指头发麻是什么原因引起的hcv8jop3ns5r.cn 孕晚期吃什么长胎不长肉hcv9jop7ns0r.cn 四季常青财运旺是什么生肖hcv7jop6ns5r.cn 双花红棍什么意思hcv8jop7ns5r.cn 中出是什么hcv9jop3ns2r.cn
百度