我的 repo 有几个包含 smartBASIC 源代码的 *.sb 文件。这些文件不会出现在 repo 的语言栏中(因为 smartBASIC 及其关联的文件扩展名不是默认语言学家定义的一部分)。
制图 sb
扩展到 smartBASIC 在 .gitattributes
文件:
**/*.sb linguist-language=smartBASIC
并确保映射不被“忽略”:
**/*.sb linguist-vendored=false
**/*.sb linguist-generated=false
**/*.sb linguist-documentation=false
**/*.sb linguist-detectable=true
没有达到预期的效果。
sb
文件按预期处理,但 smartBASIC
不是预定义的语言,因此自定义映射不会产生任何语言统计信息。 (我通过将文件映射到另一种语言(C++)并让它们显示在语言栏统计信息中(如 C++)来验证这一点。从其他问题( Add custom language to a GitHub repository , Custom language in github repository )看来,要将新扩展映射到新语言需要将它们添加到 Linguist (更具体地说,至少必须添加语言)。从语言学家文档中可以清楚地看出,只有在 GitHub 存储库中有足够的存在时,才会添加新语言/扩展。这完全有道理。但是,这也意味着没有明显的方法可以映射
sb
扩展到 smartBASIC
语言并将其显示在语言栏中(例如,repo stats 为 60% smartBASIC、30% Python、10% 其他)。问题:是否可以使用语言学家覆盖将文件扩展名映射到 GitHub 上的新语言,而无需将新语言添加到语言学家本身?
是否可以使用任何其他方式?
(这个问题是关于 repo 的语言统计信息。语法高亮和其他自定义在这个阶段是次要的。)
最佳答案
当前最新 lib/linguist/languages.yml
确实不包括 smartBasic。
Is it possible to map a filename extension to a new language on GitHub using Linguist overrides without adding the new language to Linguist itself
不,它不受支持。
您有类似 3665 的问题:“如果 'xyz' 不是已知语言,则 lingust-language=xyz 在 github 上似乎会被忽略。建议:使其显示为未知语言”
但即使这样也不被接受。
Adding support for custom names in the language bar requires a lot more than a few tweaks in Linguist as the GitHub-side changes are far from trivial and would require an internally commissioned project to implement it.
关于github - 如何在 GitHub 上设置自定义扩展到语言的映射而不向 Linguist 添加新语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60592340/