5

My repo has several *.sb files containing smartBASIC source code. The files do not show up in language bar of the repo (because smartBASIC and its associated filename extension are not part of default Linguist definitions).

Mapping sb extension to smartBASIC in .gitattributes file:

**/*.sb linguist-language=smartBASIC

and ensuring the mapping is not "ignored":

**/*.sb linguist-vendored=false
**/*.sb linguist-generated=false
**/*.sb linguist-documentation=false
**/*.sb linguist-detectable=true 

does not have the desired effect. The sb files are processed as expected but smartBASIC is not a predefined langauge so the custom mapping does not produce any language stats info. (I verified this by mapping the files to another language (C++) and having them then show up in the language bar stats (as C++).

From other questions (Add custom language to a GitHub repository, Custom language in github repository) it seems that to get a new extension mapped to a new language requires their addition to Linguist (more specifically, at least the language must be added). From Linguist documentation it is clear that new languages/extensions are added only once they have sufficient presence in GitHub repos. This makes complete sense. However, it also means that there is no apparent way to map sb extension to smartBASIC language and have this appear in the language bar (e.g. repo stats as 60% smartBASIC, 30% Python, 10% other).

QUESTION: 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?

Is it possible using any other means?

(This question is about language stats of the repo. Syntax higlighting and other customizations are secondary at this stage.)

Petr Vepřek
  • 1,547
  • 2
  • 24
  • 35

1 Answers1

3

The current latest lib/linguist/languages.yml does not include smartBasic indeed.

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

No, it is not supported.
You have issues like 3665: "lingust-language=xyz appears to be ignored on github if 'xyz' is not a known language. Proposal: make it appear as unknown language"

But even that is not accepted.

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.

pchaigno
  • 11,313
  • 2
  • 29
  • 54
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Okay, thanks for your confirmation. I understand reasons why not to add every possible language to Linguist and why implementing user-defined tags (yes, tags, I would like more than one :-) may be dfficult. Still, having repos with less common languages (there must be quite a few) makes the language bar much less usefull (misleading perhaps). For now, I opted to map my `sb` sources to `Text`. This way, at least the bar indicates that the majority of source code in the repo is **not** Python, – Petr Vepřek Mar 09 '20 at 09:11
  • @PetrVepřek Good alternative. I agree, the language bar needs work. – VonC Mar 09 '20 at 09:17