boyter / scc

Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go
MIT License
6.27k stars 250 forks source link

Update languages.json: MDX Support #445

Closed sgoggins closed 2 months ago

sgoggins commented 2 months ago

I believe mdx files will be supported by adding the extension to the markdown block. The syntax is markdown.

sgoggins commented 2 months ago

@boyter : I tried to get this to catch the .mdx files in a repository by making these changes. I perhaps did not compile correctly? go build ? Or, other files need to be changed. The syntax for these .mdx files does look like markdown.

sgoggins commented 2 months ago

This fixes issue #439

sgoggins commented 2 months ago

Out of morbid curiosity as a newcomer to go, I'm curious why go build doesn't make the changes work. This series of steps, which I'm sure a real GO programmer would know, worked for me. FWIW:

 go mod tidy
 go generate ./...
 go build -a
 ./scc -l  #a test 
boyter commented 2 months ago

Its the go generate part that does it. It actually triggers this https://github.com/boyter/scc/blob/master/main.go#L14C1-L14C40 which in turn calls https://github.com/boyter/scc/blob/master/scripts/include.go which does some validation and produces embedded content.

Its common practice in Go to generate code since dynamic stuff can be a pain.

It is possible to do this via a build these days using embed however it wouldn't do the pre-checks to ensure the JSON is valid, although would be picked up later on. Mostly this is a result of being created before embed was included into Go.

I actually use the https://github.com/boyter/scc/blob/master/test-all.sh script which does it for me as well as running all tests, but this step is also included in the README https://github.com/boyter/scc/tree/master?tab=readme-ov-file#development