Menu

#17 Proposed sloc2html patch

Developmental
open
None
5
2015-05-29
2015-05-29
No

Per an email:

I was able to download the most recent SLOCCount (2.26) from
SourceForge and sloc2html directly off your website:
http://www.dwheeler.com/sloccount/sloc2html.py.txt

I have three comments/improvements:
1) there is a comma missing in the dictionary definition, causing a
syntax error (i.e. the code will not run at all)
2) sloccount 2.26 differentiates between "fortran" and "f90"; I don't
know how many other languages are missing from sloc2html, or if there
is an easy way for you to get a comprehensive list of supported
languages in sloccount and compare
3) it would appear that if a project (as determined somehow by
sloccount) has no files that are identified as code, it outputs the
string "(none)" as opposed to a language=count entry. You need to deal
with this entry, as the code throws an exception when it tries to
split on the "=".

Unidiff below:

--- sloc2html.py.original 2015-05-29 10:34:12.300809321 -0600
+++ sloc2html.py 2015-05-29 11:03:31.806032621 -0600
@@ -20,7 +20,7 @@
"cpp" : "green",
"sh" : "red",
"yacc" : "brown",
- "lex" : "silver"
+ "lex" : "silver",

Feel free to make more specific colors.

"ruby" : "maroon",
"cs" : "gray",
@@ -29,6 +29,7 @@
"lisp" : "fuchsia",
"objc" : "purple",
"fortran" : "purple",
+ "f90" : "purple",
"cobol" : "purple",
"pascal" : "purple",
"asm" : "purple",
@@ -70,6 +71,8 @@
print "" + num + "" + project + ""
print ""
for lang in split ( langs, "," ):
+ if lang == '(none)':
+ continue
l, n = split ( lang, "=" )
print ""
print "

[l] + "\\" width=\\"" + str( float(n) / float(num) * 500 ) + "\\">" + l + "=" + n + " (" +
str(int(float(n) / float(num) * 100)) + "%)
"

I don't need any credit for the 4 lines, but you may want to bump the
version number to 0.0.3, and possibly add a note against which version
of sloccount it was last tested.

Cheers,
Jan

Discussion


Log in to post a comment.