[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7638":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":33,"discoverSource":34},7638,"linguist","github-linguist\u002Flinguist","github-linguist","Language Savant. If your repository's language is being reported incorrectly, send us a pull request!","",null,"Ruby",13522,5223,572,175,0,2,11,65,10,45,"MIT License",false,"main",[26,27,28,29],"language-grammars","language-statistics","linguistic","syntax-highlighting","2026-06-12 02:01:42","# Linguist\n\n[![Actions Status](https:\u002F\u002Fgithub.com\u002Fgithub\u002Flinguist\u002Fworkflows\u002FRun%20Tests\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fgithub\u002Flinguist\u002Factions) \n\n[![Open in GitHub Codespaces](https:\u002F\u002Fgithub.com\u002Fcodespaces\u002Fbadge.svg)](https:\u002F\u002Fcodespaces.new\u002Fgithub-linguist\u002Flinguist)\n\nThis 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.\n\n## Documentation\n\n- [How Linguist works](\u002Fdocs\u002Fhow-linguist-works.md)\n- [Change Linguist's behaviour with overrides](\u002Fdocs\u002Foverrides.md)\n- [Troubleshooting](\u002Fdocs\u002Ftroubleshooting.md)\n- [Contributing guidelines](CONTRIBUTING.md)\n\n## Installation\n\nInstall the gem:\n\n```bash\ngem install github-linguist\n```\n\n### Dependencies\n\nLinguist is a Ruby library so you will need a recent version of Ruby installed.\nThere are known problems with the macOS\u002FXcode supplied version of Ruby that causes problems installing some of the dependencies.\nAccordingly, 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.\n\nLinguist uses [`charlock_holmes`](https:\u002F\u002Fgithub.com\u002Fbrianmario\u002Fcharlock_holmes) for character encoding and [`rugged`](https:\u002F\u002Fgithub.com\u002Flibgit2\u002Frugged) for libgit2 bindings for Ruby.\nThese components have their own dependencies.\n\n1. charlock_holmes\n    * cmake\n    * pkg-config\n    * [ICU](http:\u002F\u002Fsite.icu-project.org\u002F)\n    * [zlib](https:\u002F\u002Fzlib.net\u002F)\n2. rugged\n    * [libcurl](https:\u002F\u002Fcurl.haxx.se\u002Flibcurl\u002F)\n    * [OpenSSL](https:\u002F\u002Fwww.openssl.org)\n\nYou may need to install missing dependencies before you can install Linguist.\nFor example, on macOS with [Homebrew](http:\u002F\u002Fbrew.sh\u002F):\n\n```bash\nbrew install cmake pkg-config icu4c\n```\n\nOn Ubuntu:\n\n```bash\nsudo apt-get install build-essential cmake pkg-config libicu-dev zlib1g-dev libcurl4-openssl-dev libssl-dev ruby-dev\n```\n\n## Usage\n\n### Application usage\n\nLinguist can be used in your application as follows:\n\n```ruby\nrequire 'rugged'\nrequire 'linguist'\n\nrepo = Rugged::Repository.new('.')\nproject = Linguist::Repository.new(repo, repo.head.target_id)\nproject.language       #=> \"Ruby\"\nproject.languages      #=> { \"Ruby\" => 119387 }\n```\n\n### Command line usage\n\nThe `github-linguist` executable operates in two distinct modes:\n\n1. **[Git Repository mode](#git-repository)** - Analyzes an entire Git repository (when given a directory path or no path)\n2. **[Single file mode](#single-file)** - Analyzes a specific file (when given a file path)\n\n#### Git Repository\n\nA repository's languages stats can be assessed from the command line using the `github-linguist` executable.\nWithout any options, `github-linguist` will output the language breakdown by percentage and file size.\n\n```bash\ncd \u002Fpath-to-repository\ngithub-linguist\n```\n\nYou can try running `github-linguist` on the root directory in this repository itself:\n\n```console\n$ github-linguist\n66.84%  264519     Ruby\n24.68%  97685      C\n6.57%   25999      Go\n1.29%   5098       Lex\n0.32%   1257       Shell\n0.31%   1212       Dockerfile\n```\n\n#### Additional options\n\n##### `--rev REV`\n\nThe `--rev REV` flag will change the git revision being analyzed to any [gitrevisions(1)](https:\u002F\u002Fgit-scm.com\u002Fdocs\u002Fgitrevisions#_specifying_revisions) compatible revision you specify.\n\nThis is useful to analyze the makeup of a repo as of a certain tag, or in a certain branch.\n\nFor example, here is the popular [Jekyll open source project](https:\u002F\u002Fgithub.com\u002Fjekyll\u002Fjekyll).\n\n```console\n$ github-linguist jekyll\n\n70.64%  709959     Ruby\n23.04%  231555     Gherkin\n3.80%   38178      JavaScript\n1.19%   11943      HTML\n0.79%   7900       Shell\n0.23%   2279       Dockerfile\n0.13%   1344       Earthly\n0.10%   1019       CSS\n0.06%   606        SCSS\n0.02%   234        CoffeeScript\n0.01%   90         Hack\n```\n\nAnd here is Jekyll's published website, from the gh-pages branch inside their repository.\n\n```console\n$ github-linguist jekyll --rev origin\u002Fgh-pages\n100.00% 2568354    HTML\n```\n\n##### `--breakdown`\n\nThe `--breakdown` or `-b` flag will additionally show the breakdown of files by language.\n\nYou can try running `github-linguist` on the root directory in this repository itself:\n\n```console\n$ github-linguist --breakdown\n66.84%  264519     Ruby\n24.68%  97685      C\n6.57%   25999      Go\n1.29%   5098       Lex\n0.32%   1257       Shell\n0.31%   1212       Dockerfile\n\nRuby:\nGemfile\nRakefile\nbin\u002Fgit-linguist\nbin\u002Fgithub-linguist\next\u002Flinguist\u002Fextconf.rb\ngithub-linguist.gemspec\nlib\u002Flinguist.rb\n…\n```\n\n##### `--strategies`\n\nThe `--strategies` or `-s` flag will show the language detection strategy used for each file. This is useful for understanding how Linguist determined the language of specific files. Note that unless the `--json` flag is specified, this flag will set the `--breakdown` flag implicitly.\n\nYou can try running `github-linguist` on the root directory in this repository itself with the strategies flag:\n\n```console\n$ github-linguist --breakdown --strategies\n66.84%  264519     Ruby\n24.68%  97685      C\n6.57%   25999      Go\n1.29%   5098       Lex\n0.32%   1257       Shell\n0.31%   1212       Dockerfile\n\nRuby:\n  Gemfile [Filename]\n  Rakefile [Filename]\n  bin\u002Fgit-linguist [Extension]\n  bin\u002Fgithub-linguist [Extension]\n  lib\u002Flinguist.rb [Extension]\n  …\n```\n\nIf a file's language is affected by `.gitattributes`, the strategy will show the original detection method along with a note indicating whether the gitattributes setting changed the result or confirmed it.\n\nFor instance, if you had the following .gitattributes overrides in your repo:\n\n```gitattributes\n\n*.ts linguist-language=JavaScript\n*.js linguist-language=JavaScript\n\n```\n\nthe output of Linguist would be something like this:\n\n```console\n100.00% 217        JavaScript\n\nJavaScript:\n  demo.ts [Heuristics (overridden by .gitattributes)]\n  demo.js [Extension (confirmed by .gitattributes)]\n```\n\n##### `--json`\n\nThe `--json` or `-j` flag output the data into JSON format.\n\n```console\n$ github-linguist --json\n{\"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\"}}\n```\n\nThis option can be used in conjunction with `--breakdown` to get a full list of files along with the size and percentage data.\n\n```console\n$ github-linguist --breakdown --json\n{\"Dockerfile\":{\"size\":1212,\"percentage\":\"0.31\",\"files\":[\"Dockerfile\",\"tools\u002Fgrammars\u002FDockerfile\"]},\"Ruby\":{\"size\":264519,\"percentage\":\"66.84\",\"files\":[\"Gemfile\",\"Rakefile\",\"bin\u002Fgit-linguist\",\"bin\u002Fgithub-linguist\",\"ext\u002Flinguist\u002Fextconf.rb\",\"github-linguist.gemspec\",\"lib\u002Flinguist.rb\",...]}}\n\n```\n\nNB. The `--strategies` flag has no effect, when the `--json` flag is present.\n\n#### Single file\n\nAlternatively you can find stats for a single file using the `github-linguist` executable.\n\nYou can try running `github-linguist` on files in this repository itself:\n\n```console\n$ github-linguist grammars.yml\ngrammars.yml: 884 lines (884 sloc)\n  type:      Text\n  mime type: text\u002Fx-yaml\n  language:  YAML\n```\n\n#### Additional options\n\n##### `--breakdown`\n\nThis flag has no effect in *Single file* mode.\n\n##### `--strategies`\n\nWhen using the `--strategies` or `-s` flag with a single file, you can see which detection method was used:\n\n```console\n$ github-linguist --strategies lib\u002Flinguist.rb \nlib\u002Flinguist.rb: 105 lines (96 sloc)\n  type:      Text\n  mime type: application\u002Fx-ruby\n  language:  Ruby\n  strategy:  Extension\n```\n\nIf a file's language is affected by `.gitattributes`, the strategy will show whether the gitattributes setting changed the result or confirmed it:\n\nIn this fictitious example, it says \"confirmed by .gitattributes\" since the detection process (using the Filename strategy) would have given the same output as the override:\n```console\n.devcontainer\u002Fdevcontainer.json: 27 lines (27 sloc)\n  type:      Text\n  mime type: application\u002Fjson\n  language:  JSON with Comments\n  strategy:  Filename (confirmed by .gitattributes)\n```\n\nIn this other fictitious example, it says \"overridden by .gitattributes\" since the gitattributes setting changes the detected language to something different:\n\n```console\ntest.rb: 13 lines (11 sloc)\n  type:      Text\n  mime type: application\u002Fx-ruby\n  language:  Java\n  strategy:  Extension (overridden by .gitattributes)\n```\n\nHere, the `.rb` file would normally be detected as Ruby by the Extension strategy, but `.gitattributes` overrides it to be detected as Java instead.\n\n##### `--json`\n\nUsing the `--json` flag will give you the output for a single file in JSON format:\n\n```console\n$ github-linguist --strategies --json  lib\u002Flinguist.rb\n{\"lib\u002Flinguist.rb\":{\"lines\":105,\"sloc\":96,\"type\":\"Text\",\"mime_type\":\"application\u002Fx-ruby\",\"language\":\"Ruby\",\"large\":false,\"generated\":false,\"vendored\":false}}\n```\n\nNB. The `--strategies` has no effect, when the `--json` flag is present.\n\n#### Docker\n\nIf you have Docker installed you can either build or use\nour pre-built images and run Linguist within a container:\n\n```console\n$ docker run --rm -v $(pwd):$(pwd):Z -w $(pwd) -t ghcr.io\u002Fgithub-linguist\u002Flinguist:latest\n66.84%  264519     Ruby\n24.68%  97685      C\n6.57%   25999      Go\n1.29%   5098       Lex\n0.32%   1257       Shell\n0.31%   1212       Dockerfile\n```\n\n##### Building the image\n\n```console\n$ docker build -t linguist .\n$ docker run --rm -v $(pwd):$(pwd):Z -w $(pwd) -t linguist\n66.84%  264519     Ruby\n24.68%  97685      C\n6.57%   25999      Go\n1.29%   5098       Lex\n0.32%   1257       Shell\n0.31%   1212       Dockerfile\n$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -t linguist github-linguist --breakdown\n66.84%  264519     Ruby\n24.68%  97685      C\n6.57%   25999      Go\n1.29%   5098       Lex\n0.32%   1257       Shell\n0.31%   1212       Dockerfile\n\nRuby:\nGemfile\nRakefile\nbin\u002Fgit-linguist\nbin\u002Fgithub-linguist\next\u002Flinguist\u002Fextconf.rb\ngithub-linguist.gemspec\nlib\u002Flinguist.rb\n…\n```\n\n## Contributing\n\nPlease check out our [contributing guidelines](CONTRIBUTING.md).\n\n## License\n\nThe language grammars included in this gem are covered by their repositories' respective licenses.\n[`vendor\u002FREADME.md`](\u002Fvendor\u002FREADME.md) lists the repository for each grammar.\n\nAll other files are covered by the MIT license, see [`LICENSE`](.\u002FLICENSE).\n","Linguist 是一个用于识别代码仓库中文件语言的工具。它能够检测文件的语言类型、忽略二进制或供应商文件、在差异中抑制生成的文件，并生成语言分布图。该项目采用 Ruby 语言编写，支持多种依赖项如 charlock_holmes 和 rugged，以确保准确性和功能性。适用于需要分析项目语言组成、优化代码仓库管理和提高开发者效率的场景。","2026-06-11 03:13:30","top_language"]