From 759c85b8eb8e22ef8df6372b7af1c03f37b215bb Mon Sep 17 00:00:00 2001 From: Aerek-Yasa <88772708+Aerek-Yasa@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:06:46 +0200 Subject: [PATCH] Added support for Templ --- README.md | 1 + Unix/AUTHORS | 3 ++- Unix/cloc | 9 +++++++++ Unix/t/00_C.t | 5 +++++ cloc | 9 +++++++++ tests/inputs/templ_example.templ | 25 +++++++++++++++++++++++++ tests/outputs/templ_example.templ.yaml | 20 ++++++++++++++++++++ 7 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/inputs/templ_example.templ create mode 100644 tests/outputs/templ_example.templ.yaml diff --git a/README.md b/README.md index 051868b3..d69eb384 100644 --- a/README.md +++ b/README.md @@ -1308,6 +1308,7 @@ Tcl/Tk (itk, tcl, tk) TEAL (teal) Teamcenter met (met) Teamcenter mth (mth) +Templ (templ) TeX (aux, bbx, bib, bst, cbx, dtx, ins, lbx, ltx, mkii, mkiv, mkvi, sty, tex, cls) Text (text, txt) Thrift (thrift) diff --git a/Unix/AUTHORS b/Unix/AUTHORS index cec5d1ca..8e6413fe 100644 --- a/Unix/AUTHORS +++ b/Unix/AUTHORS @@ -30,4 +30,5 @@ https://github.com/michalmuskala https://github.com/Inventitech https://github.com/zhangzqs https://github.com/drkameleon -https://github.com/jackos \ No newline at end of file +https://github.com/jackos +https://github.com/Aerek-Yasa \ No newline at end of file diff --git a/Unix/cloc b/Unix/cloc index c5d5b63b..38a69c3f 100755 --- a/Unix/cloc +++ b/Unix/cloc @@ -8949,6 +8949,7 @@ sub set_constants { # {{{1 'tcsh' => 'C Shell' , 'tk' => 'Tcl/Tk' , 'teal' => 'TEAL' , + 'templ' => 'Templ' , 'mkvi' => 'TeX' , 'mkiv' => 'TeX' , 'mkii' => 'TeX' , @@ -10641,6 +10642,13 @@ sub set_constants { # {{{1 ], 'Teamcenter met' => [ [ 'call_regexp_common' , 'C' ], ], 'Teamcenter mth' => [ [ 'remove_matches' , '^\s*#' ], ], + 'Templ' => [ + [ 'rm_comments_in_strings', '"', '/*', '*/' ], + [ 'rm_comments_in_strings', '["`]', '*/*', '' ], + [ 'rm_comments_in_strings', '"', '//', '' ], + [ 'call_regexp_common' , 'C++' ], + [ 'remove_inline' , '//.*$' ], + ], 'TeX' => [ [ 'remove_matches' , '^\s*%' ], [ 'remove_inline' , '%.*$' ], @@ -11444,6 +11452,7 @@ sub set_constants { # {{{1 'Teamcenter def' => 1.00, 'Teamcenter met' => 1.00, 'Teamcenter mth' => 1.00, + 'Templ' => 2.50, 'TeX' => 1.50, 'Text' => 0.50, 'Thrift' => 2.50, diff --git a/Unix/t/00_C.t b/Unix/t/00_C.t index b554f736..26483501 100755 --- a/Unix/t/00_C.t +++ b/Unix/t/00_C.t @@ -1171,6 +1171,11 @@ my @Tests = ( 'ref' => '../tests/outputs/htlc.teal.yaml', 'args' => '../tests/inputs/htlc.teal', }, + { + 'name' => 'Templ', + 'ref' => '../tests/outputs/templ_example.templ.yaml', + 'args' => '../tests/inputs/templ_example.templ' + }, { 'name' => 'TeX', 'ref' => '../tests/outputs/LaTeX.tex.yaml', diff --git a/cloc b/cloc index 85e0eca1..78e91c42 100755 --- a/cloc +++ b/cloc @@ -8964,6 +8964,7 @@ sub set_constants { # {{{1 'tcsh' => 'C Shell' , 'tk' => 'Tcl/Tk' , 'teal' => 'TEAL' , + 'templ' => 'Templ' , 'mkvi' => 'TeX' , 'mkiv' => 'TeX' , 'mkii' => 'TeX' , @@ -10656,6 +10657,13 @@ sub set_constants { # {{{1 ], 'Teamcenter met' => [ [ 'call_regexp_common' , 'C' ], ], 'Teamcenter mth' => [ [ 'remove_matches' , '^\s*#' ], ], + 'Templ' => [ + [ 'rm_comments_in_strings', '"', '/*', '*/' ], + [ 'rm_comments_in_strings', '["`]', '*/*', '' ], + [ 'rm_comments_in_strings', '"', '//', '' ], + [ 'call_regexp_common' , 'C++' ], + [ 'remove_inline' , '//.*$' ], + ], 'TeX' => [ [ 'remove_matches' , '^\s*%' ], [ 'remove_inline' , '%.*$' ], @@ -11459,6 +11467,7 @@ sub set_constants { # {{{1 'Teamcenter def' => 1.00, 'Teamcenter met' => 1.00, 'Teamcenter mth' => 1.00, + 'Templ' => 2.50, 'TeX' => 1.50, 'Text' => 0.50, 'Thrift' => 2.50, diff --git a/tests/inputs/templ_example.templ b/tests/inputs/templ_example.templ new file mode 100644 index 00000000..21335dfc --- /dev/null +++ b/tests/inputs/templ_example.templ @@ -0,0 +1,25 @@ +package test + +import "time" + +// Line comment + +/* +multi +line +comment +*/ + +templ templ_function() { +
A div
+ //
A commented div
+ /*
A multiline commented div
*/ +} + +func golang_function() { + a := 5 + // a = 6 + /* + a = 7 + */ +} diff --git a/tests/outputs/templ_example.templ.yaml b/tests/outputs/templ_example.templ.yaml new file mode 100644 index 00000000..3c31f381 --- /dev/null +++ b/tests/outputs/templ_example.templ.yaml @@ -0,0 +1,20 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 2.01 + elapsed_seconds : 0.0374619960784912 + n_files : 1 + n_lines : 25 + files_per_second : 26.6937190934722 + lines_per_second : 667.342977336804 +'Templ' : + nFiles: 1 + blank: 5 + comment: 12 + code: 8 +SUM: + blank: 5 + comment: 12 + code: 8 + nFiles: 1 \ No newline at end of file