Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

言語一覧の追加 #102

Open
raiga0310 opened this issue Jul 8, 2020 · 8 comments
Open

言語一覧の追加 #102

raiga0310 opened this issue Jul 8, 2020 · 8 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@raiga0310
Copy link
Sponsor Contributor

No description provided.

@raiga0310 raiga0310 added the documentation Improvements or additions to documentation label Jul 8, 2020
@raiga0310 raiga0310 self-assigned this Jul 8, 2020
@mirror-kt
Copy link
Contributor

拡張子と言語のペアのデータベースが存在すれば、このリポジトリから"RADWIMPS.(.*)"のファイルを取得してCIとかから言語一覧を生成できそう?

@laminne
Copy link
Member

laminne commented Jul 8, 2020

審査待ちの言語も載せてほしいです

@raiga0310
Copy link
Sponsor Contributor Author

審査待ちについては追記予定です
自動追記についてはあとでやるとして、とりあえず今あるやつ全部ぶち込みます

@raiga0310
Copy link
Sponsor Contributor Author

拡張子と言語のペアのデータベースが存在すれば、このリポジトリから"RADWIMPS.(.*)"のファイルを取得してCIとかから言語一覧を生成できそう?

できそうではあるけども……。

@0918nobita
Copy link
Contributor

0918nobita commented Jul 9, 2020

GitHub がリポジトリ毎に言語統計を生成するために使用している、linguist という Ruby 製のツールが言語一覧の生成に使えそうです。 https://github.com/github/linguist
gem でコマンドラインツールが提供されています。

実際に僕の環境で動かしてみると、現状の master ブランチではこんな結果になりました。(--json オプションを指定して、結果を JSON 文字列で出力させています)

$ github-linguist --json > result.json

result.json :

{"AppleScript":["RADWIMPS.applescript"],"Shell":["RADWIMPS.bash","RADWIMPS.dash"],"C":["RADWIMPS.c"],"Clojure":["RADWIMPS.clj"],"C++":["RADWIMPS.cpp","RADWIMPS.h"],"Crystal":["RADWIMPS.cr"],"C#":["RADWIMPS.cs"],"D":["RADWIMPS.d"],"Dart":["RADWIMPS.dart"],"Emacs Lisp":["RADWIMPS.el"],"Elixir":["RADWIMPS.exs"],"F#":["RADWIMPS.fs"],"Forth":["RADWIMPS.fth"],"Go":["RADWIMPS.go"],"Groovy":["RADWIMPS.groovy"],"Hack":["RADWIMPS.hack"],"Haskell":["RADWIMPS.hs"],"HTML":["RADWIMPS.html"],"Haxe":["RADWIMPS.hx"],"Java":["RADWIMPS.java"],"Julia":["RADWIMPS.jl"],"JavaScript":["RADWIMPS.js"],"Kotlin":["RADWIMPS.kt"],"Common Lisp":["RADWIMPS.lsp"],"Lua":["RADWIMPS.lua"],"Objective-C":["RADWIMPS.m"],"OCaml":["RADWIMPS.ml"],"Nim":["RADWIMPS.nim"],"PHP":["RADWIMPS.php"],"Perl":["RADWIMPS.pl"],"PowerShell":["RADWIMPS.ps1"],"Python":["RADWIMPS.py"],"Ruby":["RADWIMPS.rb"],"Reason":["RADWIMPS.re"],"Racket":["RADWIMPS.rkt"],"Rust":["RADWIMPS.rs"],"Scala":["RADWIMPS.scala"],"Scheme":["RADWIMPS.scm"],"Swift":["RADWIMPS.swift"],"TeX":["RADWIMPS.tex"],"TypeScript":["RADWIMPS.ts"],"V":["RADWIMPS.v"],"Vim script":["RADWIMPS.vim"]}

こんな風に、キーが言語名の文字列で、対応する値がソースファイル名の配列になっているオブジェクトが返ります。
あとはこれを受け取って言語一覧の Markdown を吐き出すスクリプトを何かしらの言語で書けばいいと思います。

デフォルトの言語判定方法に誤りがある場合は、.gitattributes ファイルを配置して上書きすることもできます。
https://github.com/github/linguist#using-gitattributes

@0918nobita
Copy link
Contributor

0918nobita commented Jul 9, 2020

もうひとつ考えられる方法としては、そもそもソースファイルを言語ごとに異なるサブディレクトリにわけて配置して、それぞれのディレクトリ名が言語名と対応するようにする(今後言語を追加する際にもそのルールに従わせる)、という方法があると思います。

これなら linguist が対応できてないような言語でもスクリプトで柔軟に対処でき、なおかつ (Node.jsでの package.json, TypeScript での tsconfig.json, Rust での Cargo.toml のように) 別途設定ファイル等が必要な言語のプログラムでも管理しやすくなります。

ディレクトリツリーがそのまま言語一覧のような見た目になるので、この方法を採用するなら言語一覧自体生成する必要もないかもしれません。

@mirror-kt
Copy link
Contributor

#123 にてディレクトリ構成を検討します

@eggplants
Copy link
Contributor

$ github-linguist --json | jq .
indented json
{
  "Ada": [
    "RADWIMPS.adb"
  ],
  "AppleScript": [
    "RADWIMPS.applescript"
  ],
  "Shell": [
    "RADWIMPS.bash",
    "RADWIMPS.dash"
  ],
  "C": [
    "RADWIMPS.c"
  ],
  "Clojure": [
    "RADWIMPS.clj"
  ],
  "CoffeeScript": [
    "RADWIMPS.coffee"
  ],
  "C++": [
    "RADWIMPS.cpp",
    "RADWIMPS.h",
    "RADWIMPS.ino"
  ],
  "Crystal": [
    "RADWIMPS.cr"
  ],
  "C#": [
    "RADWIMPS.cs"
  ],
  "D": [
    "RADWIMPS.d"
  ],
  "Dart": [
    "RADWIMPS.dart"
  ],
  "Pascal": [
    "RADWIMPS.dpr"
  ],
  "Emacs Lisp": [
    "RADWIMPS.el"
  ],
  "Erlang": [
    "RADWIMPS.erl"
  ],
  "Elixir": [
    "RADWIMPS.exs"
  ],
  "F#": [
    "RADWIMPS.fs"
  ],
  "Forth": [
    "RADWIMPS.fth"
  ],
  "Go": [
    "RADWIMPS.go"
  ],
  "Groovy": [
    "RADWIMPS.groovy"
  ],
  "Hack": [
    "RADWIMPS.hack"
  ],
  "Haskell": [
    "RADWIMPS.hs"
  ],
  "HTML": [
    "RADWIMPS.html"
  ],
  "Haxe": [
    "RADWIMPS.hx"
  ],
  "Io": [
    "RADWIMPS.io"
  ],
  "Java": [
    "RADWIMPS.java"
  ],
  "Julia": [
    "RADWIMPS.jl"
  ],
  "JavaScript": [
    "RADWIMPS.js"
  ],
  "Kotlin": [
    "RADWIMPS.kt"
  ],
  "Common Lisp": [
    "RADWIMPS.lsp"
  ],
  "Lua": [
    "RADWIMPS.lua"
  ],
  "Objective-C": [
    "RADWIMPS.m"
  ],
  "OCaml": [
    "RADWIMPS.ml"
  ],
  "Nim": [
    "RADWIMPS.nim"
  ],
  "OpenEdge ABL": [
    "RADWIMPS.p"
  ],
  "Processing": [
    "RADWIMPS.pde"
  ],
  "PHP": [
    "RADWIMPS.php"
  ],
  "Perl": [
    "RADWIMPS.pl"
  ],
  "PowerShell": [
    "RADWIMPS.ps1"
  ],
  "Python": [
    "RADWIMPS.py"
  ],
  "Ruby": [
    "RADWIMPS.rb"
  ],
  "Reason": [
    "RADWIMPS.re"
  ],
  "Racket": [
    "RADWIMPS.rkt"
  ],
  "Rust": [
    "RADWIMPS.rs"
  ],
  "Scala": [
    "RADWIMPS.scala"
  ],
  "Scheme": [
    "RADWIMPS.scm"
  ],
  "Swift": [
    "RADWIMPS.swift"
  ],
  "TeX": [
    "RADWIMPS.tex"
  ],
  "TypeScript": [
    "RADWIMPS.ts"
  ],
  "V": [
    "RADWIMPS.v"
  ],
  "Visual Basic .NET": [
    "RADWIMPS.vb"
  ],
  "Vim script": [
    "RADWIMPS.vim"
  ],
  "Vue": [
    "RADWIMPS.vue"
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants