www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - GitHub detects .d source as Makefile?

reply XavierAP <n3minis-git yahoo.es> writes:
So I have put my first code even on GitHub (comments welcome :)) 
and GitHub seems to detect the wrong language, even if I'm not 
familiar with this GH feature.

https://github.com/XavierAP/etc/tree/master/heatsim

The repository itself ("etc") is flagged as been written in 
Makefile? Right now I have only two source files (and a couple of 
images and a pdf). If I look at syntax highlighting online, one 
of them main.d seems highlighted in D ok. But the other one 
heatsim.d is not correctly highlighted.

https://github.com/XavierAP/etc/blob/master/heatsim/src/heatsim.d
https://github.com/XavierAP/etc/blob/master/heatsim/src/main.d

Is this a known issue with D on GitHub? Should I report it I 
guess?
How smart is GH that it doesn't look at the file extension? What 
happened?
Mar 17 2017
next sibling parent Jonathan M Davis via Digitalmars-d-learn writes:
On Saturday, March 18, 2017 00:34:57 XavierAP via Digitalmars-d-learn wrote:
 So I have put my first code even on GitHub (comments welcome :))
 and GitHub seems to detect the wrong language, even if I'm not
 familiar with this GH feature.

 https://github.com/XavierAP/etc/tree/master/heatsim

 The repository itself ("etc") is flagged as been written in
 Makefile? Right now I have only two source files (and a couple of
 images and a pdf). If I look at syntax highlighting online, one
 of them main.d seems highlighted in D ok. But the other one
 heatsim.d is not correctly highlighted.

 https://github.com/XavierAP/etc/blob/master/heatsim/src/heatsim.d
 https://github.com/XavierAP/etc/blob/master/heatsim/src/main.d

 Is this a known issue with D on GitHub? Should I report it I
 guess?
 How smart is GH that it doesn't look at the file extension? What
 happened?
I don't know what to say about that. It certainly seems odd, but I have no idea how github decides such things. On bitbucket, you tell it the language explicitly, which sidesteps the whole problem. You might try what Walter likes to suggest and put // Written in the D programming language at the top of your D source files and see if that helps. - Jonathan M Davis
Mar 17 2017
prev sibling parent reply David Nadlinger <code klickverbot.at> writes:
On Saturday, 18 March 2017 at 00:34:57 UTC, XavierAP wrote:
 Is this a known issue with D on GitHub? Should I report it I 
 guess?
 How smart is GH that it doesn't look at the file extension? 
 What happened?
The extension .d can legitimately refer to makefiles as well (specifically, to dependency files). The code GitHub uses to infer source file languages is open-source, and – fittingly – available on GitHub: https://github.com/github/linguist You should check the issues for reports of similar D-related problems, and if there are none, create a new one. Or, better yet, submit a pull request with an appropriate fix. As a workaround, adding a "module …;" declaration to your file should help. You probably want to be doing that anyway. — David
Mar 17 2017
next sibling parent reply XavierAP <n3minis-git yahoo.es> writes:
On Saturday, 18 March 2017 at 01:33:13 UTC, David Nadlinger wrote:
 The code GitHub uses to infer source file languages is 
 open-source, and – fittingly – available on GitHub: 
 https://github.com/github/linguist

 You should check the issues for reports of similar D-related 
 problems, and if there are none, create a new one. Or, better 
 yet, submit a pull request with an appropriate fix.
Thanks! It seems I can also override the language detection in .gitattributes, and it is now fixed :) I'll take a look around and file an issue if it doesn't exist. Probably not PR myself as I don't know Ruby.
 As a workaround, adding a "module …;" declaration to your file 
 should help. You probably want to be doing that anyway.
I know about this and I've read the spec and Andrei's book yet I'm not entirely clear why it is such a mandatory practice. I'll ask in a new thread... [1] https://github.com/github/linguist/blob/master/lib/linguist/documentation.yml
Mar 18 2017
parent XavierAP <n3minis-git yahoo.es> writes:
On Saturday, 18 March 2017 at 10:52:31 UTC, XavierAP wrote:
 Thanks! It seems I can also override the language detection in 
 .gitattributes, and it is now fixed :)
The majority language assigned to the whole repository is fixed, but alas syntax highlighting in heatsim.d is still wrong. Looks like this is handled by code in a different repository[1] from linguist. I'll look at the issues on both... [1] https://github.com/github/linguist/blob/master/vendor/README.md
Mar 18 2017
prev sibling parent reply Seb <seb wilzba.ch> writes:
On Saturday, 18 March 2017 at 01:33:13 UTC, David Nadlinger wrote:
 On Saturday, 18 March 2017 at 00:34:57 UTC, XavierAP wrote:
 Is this a known issue with D on GitHub? Should I report it I 
 guess?
 How smart is GH that it doesn't look at the file extension? 
 What happened?
The extension .d can legitimately refer to makefiles as well (specifically, to dependency files). The code GitHub uses to infer source file languages is open-source, and – fittingly – available on GitHub: https://github.com/github/linguist You should check the issues for reports of similar D-related problems, and if there are none, create a new one. Or, better yet, submit a pull request with an appropriate fix. As a workaround, adding a "module …;" declaration to your file should help. You probably want to be doing that anyway. — David
FWIW this has been fixed by Martin last summer, but the people at GitHub aren't very responsive. The PR is still pending :/ More info: https://trello.com/c/g9PB3ISG/233-improve-d-language-recognition-on-github https://github.com/github/linguist/pull/3145
Mar 19 2017
parent XavierAP <n3minis-git yahoo.es> writes:
On Sunday, 19 March 2017 at 21:53:17 UTC, Seb wrote:
 FWIW this has been fixed by Martin last summer, but the people 
 at GitHub aren't very responsive. The PR is still pending :/
 More info:

 https://trello.com/c/g9PB3ISG/233-improve-d-language-recognition-on-github
 https://github.com/github/linguist/pull/3145
Thanks for the info. Whole thing looks beyond me, plus I'm new to GH so not sure what's polite, but I'll try to remember pinging after a while whenever no one does. In the meantime my file is finally ok, after I added an override in the .gitattributes file,* it looks like there was a time delay from the language being re-classified by the GitHub Linguist until it was processed anew by the appropriate highlight parser. Even though the majority language stat for the repository had updated instantly. * Fyi these are the lines I added to my .gitattributes file: *.d linguist-language=D *.di linguist-language=D
Mar 20 2017