github - 如何在 GitHub 上设置自定义扩展到语言的映射而不向 Linguist 添加新语言

标签 github github-linguist

我的 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 repositoryCustom 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/

相关文章:

git - 查看 gitlab 中子模块提交的差异

github - 使用 gitattributes 作为语言学家示例

github 操作失败? tar 空存档,docker run 失败,退出代码为 1

git - 单个开发人员是否需要 git 分支?

matlab - Github 将 Matlab .m 文件错误分类为 Objective-C 文件

git - 如何使用 .gitattributes 让 Github 显示正确的 repo 主要语言?

ruby - 如何检测片段的编程语言?

android - 如何为现有的Github存储库添加Gradle支持?

git - 如何在 Atom 中设置 Git-plus 以与 Github 一起工作