From f1bcd536543ccc50194b8c385d3b85424cb802b8 Mon Sep 17 00:00:00 2001 From: boB Rudis Date: Mon, 25 Feb 2019 07:38:38 -0500 Subject: [PATCH] README --- DESCRIPTION | 2 +- README.Rmd | 18 +- README.md | 149 ++-- docs/CONDUCT.html | 130 ++++ docs/LICENSE-text.html | 124 +++ docs/authors.html | 139 ++++ docs/docsearch.css | 148 ++++ docs/docsearch.js | 85 +++ docs/index.html | 362 +++++++++ docs/link.svg | 12 + docs/news/index.html | 166 ++++ docs/pkgdown.css | 236 ++++++ docs/pkgdown.js | 115 +++ docs/pkgdown.yml | 5 + docs/reference/cloc-package.html | 194 +++++ docs/reference/cloc.html | 183 +++++ docs/reference/cloc_by_file.html | 185 +++++ docs/reference/cloc_call.html | 1009 +++++++++++++++++++++++++ docs/reference/cloc_cran.html | 180 +++++ docs/reference/cloc_git.html | 173 +++++ docs/reference/cloc_pkg.html | 185 +++++ docs/reference/cloc_pkg_md.html | 144 ++++ docs/reference/cloc_recognized_languages.html | 185 +++++ docs/reference/cloc_remove_comments.html | 160 ++++ docs/reference/index.html | 203 +++++ 25 files changed, 4411 insertions(+), 81 deletions(-) create mode 100644 docs/CONDUCT.html create mode 100644 docs/LICENSE-text.html create mode 100644 docs/authors.html create mode 100644 docs/docsearch.css create mode 100644 docs/docsearch.js create mode 100644 docs/index.html create mode 100644 docs/link.svg create mode 100644 docs/news/index.html create mode 100644 docs/pkgdown.css create mode 100644 docs/pkgdown.js create mode 100644 docs/pkgdown.yml create mode 100644 docs/reference/cloc-package.html create mode 100644 docs/reference/cloc.html create mode 100644 docs/reference/cloc_by_file.html create mode 100644 docs/reference/cloc_call.html create mode 100644 docs/reference/cloc_cran.html create mode 100644 docs/reference/cloc_git.html create mode 100644 docs/reference/cloc_pkg.html create mode 100644 docs/reference/cloc_pkg_md.html create mode 100644 docs/reference/cloc_recognized_languages.html create mode 100644 docs/reference/cloc_remove_comments.html create mode 100644 docs/reference/index.html diff --git a/DESCRIPTION b/DESCRIPTION index 0a78ae5..bc77d76 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,4 +32,4 @@ LazyData: true Suggests: testthat, covr -RoxygenNote: 6.0.1.9000 +RoxygenNote: 6.1.1 diff --git a/README.Rmd b/README.Rmd index 190e38f..399590f 100644 --- a/README.Rmd +++ b/README.Rmd @@ -1,5 +1,7 @@ --- output: rmarkdown::github_document +editor_options: + chunk_output_type: console --- @@ -81,14 +83,26 @@ cloc_cran(c("archdata", "hrbrthemes", "iptools", "dplyr")) git tree -```{r message=FALSE, warning=FALSE, error=FALSE} +```{r message=FALSE, warning=FALSE, error=FALSE, eval=FALSE} cloc_git("~/packages/cloc") +## source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct +## 1 cloc Perl 1 0.1111111 10059 0.9867569158 787 0.910879630 1292 0.9570370370 +## 2 cloc Markdown 2 0.2222222 60 0.0058858152 31 0.035879630 0 0.0000000000 +## 3 cloc R 4 0.4444444 52 0.0051010398 22 0.025462963 25 0.0185185185 +## 4 cloc Rmd 1 0.1111111 13 0.0012752600 21 0.024305556 32 0.0237037037 +## 5 cloc YAML 1 0.1111111 10 0.0009809692 3 0.003472222 1 0.0007407407 ``` git tree (with specific commit) -```{r message=FALSE, warning=FALSE, error=FALSE} +```{r message=FALSE, warning=FALSE, error=FALSE, eval=FALSE} cloc_git("~/packages/cloc", "3643cd09d4b951b1b35d32dffe35985dfe7756c4") +## source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct +## 1 cloc Perl 1 0.1111111 10059 0.9867569158 787 0.910879630 1292 0.9570370370 +## 2 cloc Markdown 2 0.2222222 60 0.0058858152 31 0.035879630 0 0.0000000000 +## 3 cloc R 4 0.4444444 52 0.0051010398 22 0.025462963 25 0.0185185185 +## 4 cloc Rmd 1 0.1111111 13 0.0012752600 21 0.024305556 32 0.0237037037 +## 5 cloc YAML 1 0.1111111 10 0.0009809692 3 0.003472222 1 0.0007407407 ``` remote git tree diff --git a/README.md b/README.md index a9d2445..3b167fc 100644 --- a/README.md +++ b/README.md @@ -62,36 +62,35 @@ Basic usage ``` r # by dir cloc(system.file("extdata", package="cloc")) -#> # A tibble: 3 x 10 +#> # A tibble: 2 x 10 #> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct #> -#> 1 extdata C++ 1 0.333 142 0.493 41 0.621 63 0.457 -#> 2 extdata R 1 0.333 138 0.479 24 0.364 71 0.514 -#> 3 extdata Java 1 0.333 8 0.0278 1 0.0152 4 0.0290 +#> 1 extdata C++ 1 0.5 142 0.507 41 0.631 63 0.470 +#> 2 extdata R 1 0.5 138 0.493 24 0.369 71 0.530 # by file cloc(system.file("extdata", "qrencoder.cpp", package="cloc")) #> # A tibble: 1 x 10 -#> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct -#> -#> 1 qrencoder… C++ 1 1. 142 1. 41 1. 63 1. +#> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct +#> +#> 1 qrencoder.… C++ 1 1 142 1 41 1 63 1 # from a url cloc("https://rud.is/dl/cloc-1.74.tar.gz") #> # A tibble: 93 x 10 -#> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct -#> -#> 1 cloc-1.… Perl 5 0.0180 19712 0.598 1353 0.420 2430 0.443 -#> 2 cloc-1.… YAML 141 0.507 2887 0.0876 1 0.000311 141 0.0257 -#> 3 cloc-1.… Markdown 1 0.00360 2195 0.0666 226 0.0702 26 0.00474 -#> 4 cloc-1.… ANTLR Gr… 2 0.00719 1012 0.0307 200 0.0621 59 0.0108 -#> 5 cloc-1.… R 3 0.0108 698 0.0212 95 0.0295 312 0.0569 -#> 6 cloc-1.… C/C++ He… 1 0.00360 617 0.0187 191 0.0593 780 0.142 -#> 7 cloc-1.… C++ 4 0.0144 570 0.0173 132 0.0410 173 0.0315 -#> 8 cloc-1.… Forth 2 0.00719 529 0.0160 17 0.00528 84 0.0153 -#> 9 cloc-1.… TypeScri… 3 0.0108 410 0.0124 52 0.0162 39 0.00711 -#> 10 cloc-1.… Logtalk 1 0.00360 368 0.0112 59 0.0183 57 0.0104 -#> # ... with 83 more rows +#> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct +#> +#> 1 cloc-1.7… Perl 5 0.0180 19712 0.598 1353 0.420 2430 0.443 +#> 2 cloc-1.7… YAML 141 0.507 2887 0.0876 1 0.000311 141 0.0257 +#> 3 cloc-1.7… Markdown 1 0.00360 2195 0.0666 226 0.0702 26 0.00474 +#> 4 cloc-1.7… ANTLR Gr… 2 0.00719 1012 0.0307 200 0.0621 59 0.0108 +#> 5 cloc-1.7… R 3 0.0108 698 0.0212 95 0.0295 312 0.0569 +#> 6 cloc-1.7… C/C++ He… 1 0.00360 617 0.0187 191 0.0593 780 0.142 +#> 7 cloc-1.7… C++ 4 0.0144 570 0.0173 132 0.0410 173 0.0315 +#> 8 cloc-1.7… Forth 2 0.00719 529 0.0160 17 0.00528 84 0.0153 +#> 9 cloc-1.7… TypeScri… 3 0.0108 410 0.0124 52 0.0162 39 0.00711 +#> 10 cloc-1.7… Logtalk 1 0.00360 368 0.0112 59 0.0183 57 0.0104 +#> # … with 83 more rows ``` Custom CRAN package counter: @@ -99,58 +98,52 @@ Custom CRAN package counter: ``` r cloc_cran(c("archdata", "hrbrthemes", "iptools", "dplyr")) #> # A tibble: 19 x 11 -#> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct -#> -#> 1 archdat… 0. 0. 0. 0. 0. 0. 0. 0. -#> 2 hrbrthe… R 20. 0.690 927. 0.627 183. 0.523 549. 0.823 -#> 3 hrbrthe… HTML 2. 0.0690 366. 0.248 48. 0.137 2. 0.00300 -#> 4 hrbrthe… CSS 1. 0.0345 113. 0.0765 27. 0.0771 0. 0. -#> 5 hrbrthe… Rmd 3. 0.103 35. 0.0237 78. 0.223 116. 0.174 -#> 6 hrbrthe… Markdown 1. 0.0345 29. 0.0196 14. 0.0400 0. 0. -#> 7 hrbrthe… YAML 2. 0.0690 8. 0.00541 0. 0. 0. 0. -#> 8 iptools… C++ 4. 0.143 846. 0.423 167. 0.408 375. 0.289 -#> 9 iptools… HTML 2. 0.0714 637. 0.319 54. 0.132 2. 0.00154 -#> 10 iptools… R 19. 0.679 431. 0.216 125. 0.306 625. 0.482 -#> 11 iptools… Rmd 2. 0.0714 48. 0.0240 33. 0.0807 72. 0.0555 -#> 12 iptools… C/C++ H… 1. 0.0357 37. 0.0185 30. 0.0733 223. 0.172 -#> 13 dplyr_0… R 147. 0.461 13231. 0.465 2672. 0.390 3879. 0.673 -#> 14 dplyr_0… C/C++ H… 125. 0.392 6689. 0.235 1837. 0.268 270. 0.0469 -#> 15 dplyr_0… C++ 33. 0.103 4730. 0.166 920. 0.134 337. 0.0585 -#> 16 dplyr_0… HTML 5. 0.0157 2040. 0.0718 174. 0.0254 5. 0.000868 -#> 17 dplyr_0… Markdown 2. 0.00627 1289. 0.0453 624. 0.0910 0. 0. -#> 18 dplyr_0… Rmd 6. 0.0188 421. 0.0148 622. 0.0907 1270. 0.220 -#> 19 dplyr_0… C 1. 0.00313 30. 0.00106 7. 0.00102 0. 0. -#> # ... with 1 more variable: pkg +#> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct +#> +#> 1 archd… 0 0 0 0. 0 0 0 0 +#> 2 hrbrt… R 21 0.7 1094 6.63e-1 215 0.560 584 0.832 +#> 3 hrbrt… HTML 2 0.0667 366 2.22e-1 48 0.125 2 0.00285 +#> 4 hrbrt… CSS 1 0.0333 113 6.85e-2 27 0.0703 0 0 +#> 5 hrbrt… Rmd 3 0.1 35 2.12e-2 78 0.203 116 0.165 +#> 6 hrbrt… Markdown 1 0.0333 33 2.00e-2 16 0.0417 0 0 +#> 7 hrbrt… YAML 2 0.0667 8 4.85e-3 0 0 0 0 +#> 8 iptoo… C++ 4 0.138 846 4.21e-1 167 0.400 375 0.286 +#> 9 iptoo… HTML 2 0.0690 633 3.15e-1 54 0.129 2 0.00153 +#> 10 iptoo… R 20 0.690 444 2.21e-1 133 0.319 638 0.487 +#> 11 iptoo… Rmd 2 0.0690 48 2.39e-2 33 0.0791 72 0.0550 +#> 12 iptoo… C/C++ H… 1 0.0345 37 1.84e-2 30 0.0719 223 0.170 +#> 13 dplyr… R 171 0.552 14999 4.76e-1 3127 0.425 4957 0.685 +#> 14 dplyr… C/C++ H… 101 0.326 6661 2.11e-1 1754 0.238 483 0.0668 +#> 15 dplyr… C++ 23 0.0742 4706 1.49e-1 954 0.130 437 0.0604 +#> 16 dplyr… HTML 5 0.0161 3206 1.02e-1 140 0.0190 5 0.000691 +#> 17 dplyr… Markdown 2 0.00645 1479 4.69e-2 708 0.0962 0 0 +#> 18 dplyr… Rmd 7 0.0226 462 1.46e-2 667 0.0907 1350 0.187 +#> 19 dplyr… C 1 0.00323 30 9.51e-4 7 0.000951 0 0 +#> # … with 1 more variable: pkg ``` git tree ``` r cloc_git("~/packages/cloc") -#> # A tibble: 7 x 10 -#> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct -#> -#> 1 cloc Perl 1 0.0333 11153 0.912 835 0.705 1291 0.722 -#> 2 cloc R 17 0.567 622 0.0509 207 0.175 360 0.201 -#> 3 cloc Markdown 3 0.100 246 0.0201 49 0.0414 0 0. -#> 4 cloc C++ 1 0.0333 142 0.0116 41 0.0346 63 0.0352 -#> 5 cloc YAML 3 0.100 35 0.00286 14 0.0118 3 0.00168 -#> 6 cloc Rmd 1 0.0333 24 0.00196 38 0.0321 71 0.0397 -#> 7 cloc JSON 4 0.133 4 0.000327 0 0. 0 0. +## source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct +## 1 cloc Perl 1 0.1111111 10059 0.9867569158 787 0.910879630 1292 0.9570370370 +## 2 cloc Markdown 2 0.2222222 60 0.0058858152 31 0.035879630 0 0.0000000000 +## 3 cloc R 4 0.4444444 52 0.0051010398 22 0.025462963 25 0.0185185185 +## 4 cloc Rmd 1 0.1111111 13 0.0012752600 21 0.024305556 32 0.0237037037 +## 5 cloc YAML 1 0.1111111 10 0.0009809692 3 0.003472222 1 0.0007407407 ``` git tree (with specific commit) ``` r cloc_git("~/packages/cloc", "3643cd09d4b951b1b35d32dffe35985dfe7756c4") -#> # A tibble: 5 x 10 -#> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct -#> -#> 1 cloc Perl 1 0.111 10059 0.987 787 0.911 1292 0.957 -#> 2 cloc Markdown 2 0.222 60 0.00589 31 0.0359 0 0. -#> 3 cloc R 4 0.444 52 0.00510 22 0.0255 25 0.0185 -#> 4 cloc Rmd 1 0.111 13 0.00128 21 0.0243 32 0.0237 -#> 5 cloc YAML 1 0.111 10 0.000981 3 0.00347 1 0.000741 +## source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct +## 1 cloc Perl 1 0.1111111 10059 0.9867569158 787 0.910879630 1292 0.9570370370 +## 2 cloc Markdown 2 0.2222222 60 0.0058858152 31 0.035879630 0 0.0000000000 +## 3 cloc R 4 0.4444444 52 0.0051010398 22 0.025462963 25 0.0185185185 +## 4 cloc Rmd 1 0.1111111 13 0.0012752600 21 0.024305556 32 0.0237037037 +## 5 cloc YAML 1 0.1111111 10 0.0009809692 3 0.003472222 1 0.0007407407 ``` remote git tree @@ -158,12 +151,12 @@ remote git tree ``` r cloc_git("git://github.com/maelle/convertagd.git") #> # A tibble: 4 x 10 -#> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct -#> -#> 1 convertag… R 7 0.583 249 0.659 70 0.560 68 0.667 -#> 2 convertag… Markdown 2 0.167 77 0.204 23 0.184 0 0. -#> 3 convertag… YAML 2 0.167 42 0.111 16 0.128 4 0.0392 -#> 4 convertag… Rmd 1 0.0833 10 0.0265 16 0.128 30 0.294 +#> source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct +#> +#> 1 convertagd… R 7 0.583 249 0.659 70 0.56 68 0.667 +#> 2 convertagd… Markdown 2 0.167 77 0.204 23 0.184 0 0 +#> 3 convertagd… YAML 2 0.167 42 0.111 16 0.128 4 0.0392 +#> 4 convertagd… Rmd 1 0.0833 10 0.0265 16 0.128 30 0.294 ``` Detailed results by file @@ -171,13 +164,13 @@ Detailed results by file ``` r # whole dir str(cloc_by_file(system.file("extdata", package="cloc"))) -#> Classes 'tbl_df', 'tbl' and 'data.frame': 3 obs. of 6 variables: -#> $ source : chr "extdata" "extdata" "extdata" -#> $ filename : chr "/Library/Frameworks/R.framework/Versions/3.5/Resources/library/cloc/extdata/qrencoder.cpp" "/Library/Frameworks/R.framework/Versions/3.5/Resources/library/cloc/extdata/dbi.r" "/Library/Frameworks/R.framework/Versions/3.5/Resources/library/cloc/extdata/App.java" -#> $ language : chr "C++" "R" "Java" -#> $ loc : int 142 138 8 -#> $ blank_lines : int 41 24 1 -#> $ comment_lines: int 63 71 4 +#> Classes 'tbl_df', 'tbl' and 'data.frame': 2 obs. of 6 variables: +#> $ source : chr "extdata" "extdata" +#> $ filename : chr "/Library/Frameworks/R.framework/Versions/3.5/Resources/library/cloc/extdata/qrencoder.cpp" "/Library/Frameworks/R.framework/Versions/3.5/Resources/library/cloc/extdata/dbi.r" +#> $ language : chr "C++" "R" +#> $ loc : int 142 138 +#> $ blank_lines : int 41 24 +#> $ comment_lines: int 63 71 # single file str(cloc_by_file(system.file("extdata", "qrencoder.cpp", package="cloc"))) @@ -207,7 +200,7 @@ cloc_recognized_languages() #> 8 ANTLR Grammar g, g4 #> 9 Apex Trigger trigger #> 10 Arduino Sketch ino, pde -#> # ... with 232 more rows +#> # … with 232 more rows ``` Strip comments and whitespace from individual source files @@ -230,10 +223,10 @@ cat( ## cloc Metrics -| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | -| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | --: | -| R | 16 | 0.94 | 484 | 0.95 | 183 | 0.83 | 289 | 0.8 | -| Rmd | 1 | 0.06 | 24 | 0.05 | 38 | 0.17 | 71 | 0.2 | +| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | +| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: | +| R | 16 | 0.94 | 484 | 0.95 | 183 | 0.83 | 289 | 0.77 | +| Rmd | 1 | 0.06 | 24 | 0.05 | 38 | 0.17 | 85 | 0.23 | ## Code of Conduct diff --git a/docs/CONDUCT.html b/docs/CONDUCT.html new file mode 100644 index 0000000..cf91b42 --- /dev/null +++ b/docs/CONDUCT.html @@ -0,0 +1,130 @@ + + + + + + + + +Contributor Code of Conduct • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+
+ + +
+ +

As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

+

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.

+

Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.

+

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.

+

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.

+

This Code of Conduct is adapted from the Contributor Covenant (http:contributor-covenant.org), version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/

+
+ +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.3.0.

+
+
+
+ + + + + + diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html new file mode 100644 index 0000000..b301bd7 --- /dev/null +++ b/docs/LICENSE-text.html @@ -0,0 +1,124 @@ + + + + + + + + +License • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+
+ + +
YEAR: 2015
+COPYRIGHT HOLDER: Bob Rudis
+
+ +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.3.0.

+
+
+
+ + + + + + diff --git a/docs/authors.html b/docs/authors.html new file mode 100644 index 0000000..5275ca5 --- /dev/null +++ b/docs/authors.html @@ -0,0 +1,139 @@ + + + + + + + + +Authors • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+
+ + +
    +
  • +

    Bob Rudis. Author, maintainer. ORCID +

    +
  • +
  • +

    Al Danial. Author. +
    cloc perl script

    +
  • +
  • +

    Maëlle Salmon. Contributor. +

    +
  • +
  • +

    Chris Muir. Contributor. +

    +
  • +
+ +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.3.0.

+
+
+
+ + + + + + diff --git a/docs/docsearch.css b/docs/docsearch.css new file mode 100644 index 0000000..e5f1fe1 --- /dev/null +++ b/docs/docsearch.css @@ -0,0 +1,148 @@ +/* Docsearch -------------------------------------------------------------- */ +/* + Source: https://github.com/algolia/docsearch/ + License: MIT +*/ + +.algolia-autocomplete { + display: block; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 +} + +.algolia-autocomplete .ds-dropdown-menu { + width: 100%; + min-width: none; + max-width: none; + padding: .75rem 0; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, .1); + box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); +} + +@media (min-width:768px) { + .algolia-autocomplete .ds-dropdown-menu { + width: 175% + } +} + +.algolia-autocomplete .ds-dropdown-menu::before { + display: none +} + +.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { + padding: 0; + background-color: rgb(255,255,255); + border: 0; + max-height: 80vh; +} + +.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { + margin-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion { + padding: 0; + overflow: visible +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + padding: .125rem 1rem; + margin-top: 0; + font-size: 1.3em; + font-weight: 500; + color: #00008B; + border-bottom: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + float: none; + padding-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { + float: none; + width: auto; + padding: 0; + text-align: left +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + float: none; + width: auto; + padding: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content::before { + display: none +} + +.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { + padding-top: .75rem; + margin-top: .75rem; + border-top: 1px solid rgba(0, 0, 0, .1) +} + +.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { + display: block; + padding: .1rem 1rem; + margin-bottom: 0.1; + font-size: 1.0em; + font-weight: 400 + /* display: none */ +} + +.algolia-autocomplete .algolia-docsearch-suggestion--title { + display: block; + padding: .25rem 1rem; + margin-bottom: 0; + font-size: 0.9em; + font-weight: 400 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + padding: 0 1rem .5rem; + margin-top: -.25rem; + font-size: 0.8em; + font-weight: 400; + line-height: 1.25 +} + +.algolia-autocomplete .algolia-docsearch-footer { + width: 110px; + height: 20px; + z-index: 3; + margin-top: 10.66667px; + float: right; + font-size: 0; + line-height: 0; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + background-image: url("data:image/svg+xml;utf8,"); + background-repeat: no-repeat; + background-position: 50%; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + width: 100%; + height: 100%; + display: block; + transform: translate(-8px); +} + +.algolia-autocomplete .algolia-docsearch-suggestion--highlight { + color: #FF8C00; + background: rgba(232, 189, 54, 0.1) +} + + +.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { + box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) +} + +.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { + background-color: rgba(192, 192, 192, .15) +} diff --git a/docs/docsearch.js b/docs/docsearch.js new file mode 100644 index 0000000..b35504c --- /dev/null +++ b/docs/docsearch.js @@ -0,0 +1,85 @@ +$(function() { + + // register a handler to move the focus to the search bar + // upon pressing shift + "/" (i.e. "?") + $(document).on('keydown', function(e) { + if (e.shiftKey && e.keyCode == 191) { + e.preventDefault(); + $("#search-input").focus(); + } + }); + + $(document).ready(function() { + // do keyword highlighting + /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ + var mark = function() { + + var referrer = document.URL ; + var paramKey = "q" ; + + if (referrer.indexOf("?") !== -1) { + var qs = referrer.substr(referrer.indexOf('?') + 1); + var qs_noanchor = qs.split('#')[0]; + var qsa = qs_noanchor.split('&'); + var keyword = ""; + + for (var i = 0; i < qsa.length; i++) { + var currentParam = qsa[i].split('='); + + if (currentParam.length !== 2) { + continue; + } + + if (currentParam[0] == paramKey) { + keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); + } + } + + if (keyword !== "") { + $(".contents").unmark({ + done: function() { + $(".contents").mark(keyword); + } + }); + } + } + }; + + mark(); + }); +}); + +/* Search term highlighting ------------------------------*/ + +function matchedWords(hit) { + var words = []; + + var hierarchy = hit._highlightResult.hierarchy; + // loop to fetch from lvl0, lvl1, etc. + for (var idx in hierarchy) { + words = words.concat(hierarchy[idx].matchedWords); + } + + var content = hit._highlightResult.content; + if (content) { + words = words.concat(content.matchedWords); + } + + // return unique words + var words_uniq = [...new Set(words)]; + return words_uniq; +} + +function updateHitURL(hit) { + + var words = matchedWords(hit); + var url = ""; + + if (hit.anchor) { + url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; + } else { + url = hit.url + '?q=' + escape(words.join(" ")); + } + + return url; +} diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..0b117a6 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,362 @@ + + + + + + + +Count Lines of Code, Comments and Whitespace in Source Files and Archives • cloc + + + + + + + + + +
+
+ + + +
+
+ + + + + + +
+ +

Count Lines of Code, Comments and Whitespace in Source Files and Archives

+
+

+Description

+

Counts blank lines, comment lines, and physical lines of source code in source files/trees/archives. An R wrapper to the Perl cloc utility https://github.com/AlDanial/cloc by @AlDanial.

+
+
+

+What’s Inside The Tin

+

The following functions are implemented:

+
    +
  • +cloc: Count lines of code, comments and whitespace in source files/archives
  • +
  • +cloc_by_file: Count lines of code, comments and whitespace in source files/archives by file
  • +
  • +cloc_cran: Count lines of code (etc) from source packages on CRAN
  • +
  • +cloc_git: Count lines of code, comments and whitespace in a git tree
  • +
  • +cloc_remove_comments: Strip comments and white space from a single source file
  • +
  • +cloc_recognized_languages: Return a data frame of ‘cloc’ recognized languages and associated extensions
  • +
  • +cloc_call: Call ‘cloc.pl’ directly with granular control over options
  • +
  • +clock_pkg_md : Run cloc_pkg() on active package and format it as a markdown table for knitting into reports
  • +
  • +cloc_help: See the command-line help
  • +
  • +cloc_version: Retrieve the version of the embedded perl script
  • +
  • +cloc_os: Ask the embedded perl script to detect the OS type
  • +
+
+
+

+Usage

+
devtools::install_github("hrbrmstr/cloc")
+ +

Basic usage

+
# by dir
+cloc(system.file("extdata", package="cloc"))
+#> # A tibble: 2 x 10
+#>   source  language file_count file_count_pct   loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct
+#>   <chr>   <chr>         <int>          <dbl> <int>   <dbl>       <int>          <dbl>         <int>            <dbl>
+#> 1 extdata C++               1            0.5   142   0.507          41          0.631            63            0.470
+#> 2 extdata R                 1            0.5   138   0.493          24          0.369            71            0.530
+
+# by file
+cloc(system.file("extdata", "qrencoder.cpp", package="cloc"))
+#> # A tibble: 1 x 10
+#>   source      language file_count file_count_pct   loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct
+#>   <chr>       <chr>         <int>          <dbl> <int>   <dbl>       <int>          <dbl>         <int>            <dbl>
+#> 1 qrencoder.… C++               1              1   142       1          41              1            63                1
+
+# from a url
+cloc("https://rud.is/dl/cloc-1.74.tar.gz")
+#> # A tibble: 93 x 10
+#>    source    language  file_count file_count_pct   loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct
+#>    <chr>     <chr>          <int>          <dbl> <int>   <dbl>       <int>          <dbl>         <int>            <dbl>
+#>  1 cloc-1.7… Perl               5        0.0180  19712  0.598         1353       0.420             2430          0.443  
+#>  2 cloc-1.7… YAML             141        0.507    2887  0.0876           1       0.000311           141          0.0257 
+#>  3 cloc-1.7… Markdown           1        0.00360  2195  0.0666         226       0.0702              26          0.00474
+#>  4 cloc-1.7… ANTLR Gr…          2        0.00719  1012  0.0307         200       0.0621              59          0.0108 
+#>  5 cloc-1.7… R                  3        0.0108    698  0.0212          95       0.0295             312          0.0569 
+#>  6 cloc-1.7… C/C++ He…          1        0.00360   617  0.0187         191       0.0593             780          0.142  
+#>  7 cloc-1.7… C++                4        0.0144    570  0.0173         132       0.0410             173          0.0315 
+#>  8 cloc-1.7… Forth              2        0.00719   529  0.0160          17       0.00528             84          0.0153 
+#>  9 cloc-1.7… TypeScri…          3        0.0108    410  0.0124          52       0.0162              39          0.00711
+#> 10 cloc-1.7… Logtalk            1        0.00360   368  0.0112          59       0.0183              57          0.0104 
+#> # … with 83 more rows
+

Custom CRAN package counter:

+ +

git tree

+ +

git tree (with specific commit)

+ +

remote git tree

+ +

Detailed results by file

+ +

Recognized languages

+ +

Strip comments and whitespace from individual source files

+ +
+
+

+cloc Metrics

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Lang# Files(%)LoC(%)Blank lines(%)# Lines(%)
R160.944840.951830.832890.8
Rmd10.06240.05380.17710.2
+
+
+

+Code of Conduct

+

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

+
+
+
+ + + +
+ + +
+ +
+

Site built with pkgdown 1.3.0.

+
+
+
+ + + + + diff --git a/docs/link.svg b/docs/link.svg new file mode 100644 index 0000000..88ad827 --- /dev/null +++ b/docs/link.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/docs/news/index.html b/docs/news/index.html new file mode 100644 index 0000000..4f7428f --- /dev/null +++ b/docs/news/index.html @@ -0,0 +1,166 @@ + + + + + + + + +Changelog • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+
+ + +
+

+cloc 0.3.0

+
    +
  • upgraded bundled cloc.pl to 1.80
  • +
+
+
+

+cloc 0.2.0

+
    +
  • included a custom cloc.pl script (cloc pending PR https://github.com/AlDanial/cloc/pull/294) that adds support for R Markdown (Rmd) files. Only the lines of code between the triple-backticks clode blocks are included. THe resultant “language” type is Rmd as the code blocks could be anything. The results will only be fully accurate for R/Python-ish syntax languages (i.e. the ones supporting the basic cloc rules for those languages) but they should be accurate enough for rough estimates for other languages used in Rmd code blocks.
  • +
  • URLs as sources work in more funtions now
  • +
  • cloc_git() can now clone repo when using git:// URLs
  • +
  • removed dplyr dependency
  • +
  • created an RStudio addin to enable reducing the active Rmd document to just code (in a new document)
  • +
+
+
+

+cloc 0.1.0

+
    +
  • added support for many cloc.pl features
  • +
  • overhaul to resurrect the package
  • +
  • upgraded to latest (1.74) cloc perl utility (@maelle)
  • +
+
+
+

+cloc 0.0.0.9000

+
    +
  • initial version
  • +
+
+
+ + + +
+ +
+ + +
+

Site built with pkgdown 1.3.0.

+
+
+
+ + + + + + diff --git a/docs/pkgdown.css b/docs/pkgdown.css new file mode 100644 index 0000000..c03fb08 --- /dev/null +++ b/docs/pkgdown.css @@ -0,0 +1,236 @@ +/* Sticky footer */ + +/** + * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ + * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css + * + * .Site -> body > .container + * .Site-content -> body > .container .row + * .footer -> footer + * + * Key idea seems to be to ensure that .container and __all its parents__ + * have height set to 100% + * + */ + +html, body { + height: 100%; +} + +body > .container { + display: flex; + height: 100%; + flex-direction: column; + + padding-top: 60px; +} + +body > .container .row { + flex: 1 0 auto; +} + +footer { + margin-top: 45px; + padding: 35px 0 36px; + border-top: 1px solid #e5e5e5; + color: #666; + display: flex; + flex-shrink: 0; +} +footer p { + margin-bottom: 0; +} +footer div { + flex: 1; +} +footer .pkgdown { + text-align: right; +} +footer p { + margin-bottom: 0; +} + +img.icon { + float: right; +} + +img { + max-width: 100%; +} + +/* Fix bug in bootstrap (only seen in firefox) */ +summary { + display: list-item; +} + +/* Typographic tweaking ---------------------------------*/ + +.contents .page-header { + margin-top: calc(-60px + 1em); +} + +/* Section anchors ---------------------------------*/ + +a.anchor { + margin-left: -30px; + display:inline-block; + width: 30px; + height: 30px; + visibility: hidden; + + background-image: url(./link.svg); + background-repeat: no-repeat; + background-size: 20px 20px; + background-position: center center; +} + +.hasAnchor:hover a.anchor { + visibility: visible; +} + +@media (max-width: 767px) { + .hasAnchor:hover a.anchor { + visibility: hidden; + } +} + + +/* Fixes for fixed navbar --------------------------*/ + +.contents h1, .contents h2, .contents h3, .contents h4 { + padding-top: 60px; + margin-top: -40px; +} + +/* Static header placement on mobile devices */ +@media (max-width: 767px) { + .navbar-fixed-top { + position: absolute; + } + .navbar { + padding: 0; + } +} + + +/* Sidebar --------------------------*/ + +#sidebar { + margin-top: 30px; +} +#sidebar h2 { + font-size: 1.5em; + margin-top: 1em; +} + +#sidebar h2:first-child { + margin-top: 0; +} + +#sidebar .list-unstyled li { + margin-bottom: 0.5em; +} + +.orcid { + height: 16px; + vertical-align: middle; +} + +/* Reference index & topics ----------------------------------------------- */ + +.ref-index th {font-weight: normal;} + +.ref-index td {vertical-align: top;} +.ref-index .icon {width: 40px;} +.ref-index .alias {width: 40%;} +.ref-index-icons .alias {width: calc(40% - 40px);} +.ref-index .title {width: 60%;} + +.ref-arguments th {text-align: right; padding-right: 10px;} +.ref-arguments th, .ref-arguments td {vertical-align: top;} +.ref-arguments .name {width: 20%;} +.ref-arguments .desc {width: 80%;} + +/* Nice scrolling for wide elements --------------------------------------- */ + +table { + display: block; + overflow: auto; +} + +/* Syntax highlighting ---------------------------------------------------- */ + +pre { + word-wrap: normal; + word-break: normal; + border: 1px solid #eee; +} + +pre, code { + background-color: #f8f8f8; + color: #333; +} + +pre code { + overflow: auto; + word-wrap: normal; + white-space: pre; +} + +pre .img { + margin: 5px 0; +} + +pre .img img { + background-color: #fff; + display: block; + height: auto; +} + +code a, pre a { + color: #375f84; +} + +a.sourceLine:hover { + text-decoration: none; +} + +.fl {color: #1514b5;} +.fu {color: #000000;} /* function */ +.ch,.st {color: #036a07;} /* string */ +.kw {color: #264D66;} /* keyword */ +.co {color: #888888;} /* comment */ + +.message { color: black; font-weight: bolder;} +.error { color: orange; font-weight: bolder;} +.warning { color: #6A0366; font-weight: bolder;} + +/* Clipboard --------------------------*/ + +.hasCopyButton { + position: relative; +} + +.btn-copy-ex { + position: absolute; + right: 0; + top: 0; + visibility: hidden; +} + +.hasCopyButton:hover button.btn-copy-ex { + visibility: visible; +} + +/* mark.js ----------------------------*/ + +mark { + background-color: rgba(255, 255, 51, 0.5); + border-bottom: 2px solid rgba(255, 153, 51, 0.3); + padding: 1px; +} + +/* vertical spacing after htmlwidgets */ +.html-widget { + margin-bottom: 10px; +} diff --git a/docs/pkgdown.js b/docs/pkgdown.js new file mode 100644 index 0000000..eb7e83d --- /dev/null +++ b/docs/pkgdown.js @@ -0,0 +1,115 @@ +/* http://gregfranko.com/blog/jquery-best-practices/ */ +(function($) { + $(function() { + + $("#sidebar") + .stick_in_parent({offset_top: 40}) + .on('sticky_kit:bottom', function(e) { + $(this).parent().css('position', 'static'); + }) + .on('sticky_kit:unbottom', function(e) { + $(this).parent().css('position', 'relative'); + }); + + $('body').scrollspy({ + target: '#sidebar', + offset: 60 + }); + + $('[data-toggle="tooltip"]').tooltip(); + + var cur_path = paths(location.pathname); + var links = $("#navbar ul li a"); + var max_length = -1; + var pos = -1; + for (var i = 0; i < links.length; i++) { + if (links[i].getAttribute("href") === "#") + continue; + // Ignore external links + if (links[i].host !== location.host) + continue; + + var nav_path = paths(links[i].pathname); + + var length = prefix_length(nav_path, cur_path); + if (length > max_length) { + max_length = length; + pos = i; + } + } + + // Add class to parent
  • , and enclosing
  • if in dropdown + if (pos >= 0) { + var menu_anchor = $(links[pos]); + menu_anchor.parent().addClass("active"); + menu_anchor.closest("li.dropdown").addClass("active"); + } + }); + + function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); + } + + // Returns -1 if not found + function prefix_length(needle, haystack) { + if (needle.length > haystack.length) + return(-1); + + // Special case for length-0 haystack, since for loop won't run + if (haystack.length === 0) { + return(needle.length === 0 ? 0 : -1); + } + + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(i); + } + + return(haystack.length); + } + + /* Clipboard --------------------------*/ + + function changeTooltipMessage(element, msg) { + var tooltipOriginalTitle=element.getAttribute('data-original-title'); + element.setAttribute('data-original-title', msg); + $(element).tooltip('show'); + element.setAttribute('data-original-title', tooltipOriginalTitle); + } + + if(ClipboardJS.isSupported()) { + $(document).ready(function() { + var copyButton = ""; + + $(".examples, div.sourceCode").addClass("hasCopyButton"); + + // Insert copy buttons: + $(copyButton).prependTo(".hasCopyButton"); + + // Initialize tooltips: + $('.btn-copy-ex').tooltip({container: 'body'}); + + // Initialize clipboard: + var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { + text: function(trigger) { + return trigger.parentNode.textContent; + } + }); + + clipboardBtnCopies.on('success', function(e) { + changeTooltipMessage(e.trigger, 'Copied!'); + e.clearSelection(); + }); + + clipboardBtnCopies.on('error', function() { + changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); + }); + }); + } +})(window.jQuery || window.$) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml new file mode 100644 index 0000000..06304c0 --- /dev/null +++ b/docs/pkgdown.yml @@ -0,0 +1,5 @@ +pandoc: '2.6' +pkgdown: 1.3.0 +pkgdown_sha: ~ +articles: [] + diff --git a/docs/reference/cloc-package.html b/docs/reference/cloc-package.html new file mode 100644 index 0000000..0745e8f --- /dev/null +++ b/docs/reference/cloc-package.html @@ -0,0 +1,194 @@ + + + + + + + + +Count Lines of Code, Comments and Whitespace in Source Files and Archives — cloc-package • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Counts blank lines, comment lines, and physical lines of source code in source +files/trees/archives. An R wrapper to the Perl cloc utility +https://github.com/AlDanial/cloc by @AlDanial.

    + +
    + + +

    How it works

    + + +

    cloc's method of operation resembles SLOCCount's: +First, create a list of files to consider. Next, attempt to determine whether or not +found files contain recognized computer language source code. Finally, for files +identified as source files, invoke language-specific routines to count the number of +source lines.

    +

    A more detailed description:

      +
    1. If the input file is an archive (such as a .tar.gz or .zip file), +create a temporary directory and expand the archive there using a +system call to an appropriate underlying utility (tar, bzip2, unzip, +etc) then add this temporary directory as one of the inputs. (This +works more reliably on Unix than on Windows.)

    2. +
    3. Use perl's File::Find to recursively descend the input directories and make +a list of candidate file names. Ignore binary and zero-sized files.

    4. +
    5. Make sure the files in the candidate list have unique contents +(first by comparing file sizes, then, for similarly sized files, +compare MD5 hashes of the file contents with perl's Digest::MD5). For each +set of identical files, remove all but the first copy, as determined +by a lexical sort, of identical files from the set. The removed +files are not included in the report.

    6. +
    7. Scan the candidate file list for file extensions which cloc +associates with programming languages. Files which match are classified as +containing source +code for that language. Each file without an extensions is opened +and its first line read to see if it is a Unix shell script +(anything that begins with #!). If it is shell script, the file is +classified by that scripting language (if the language is +recognized). If the file does not have a recognized extension or is +not a recognzied scripting language, the file is ignored.

    8. +
    9. All remaining files in the candidate list should now be source files +for known programming languages. For each of these files:

        +
      1. Read the entire file into memory.

      2. +
      3. Count the number of lines (= L original).

      4. +
      5. Remove blank lines, then count again (= L non-blank).

      6. +
      7. Loop over the comment filters defined for this language. (For +example, C++ as two filters: (1) remove lines that start with +optional whitespace followed by // and (2) remove text between +/* and */) Apply each filter to the code to remove comments. +Count the left over lines (= L code).

      8. +
      9. Save the counts for this language:

          +
        • blank lines = L original - L non-blank

        • +
        • comment lines = L non-blank - L code

        • +
        • code lines = L code

        • +
      10. +
    10. +
    + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/cloc.html b/docs/reference/cloc.html new file mode 100644 index 0000000..b6346e4 --- /dev/null +++ b/docs/reference/cloc.html @@ -0,0 +1,183 @@ + + + + + + + + +Count lines of code, comments and whitespace in source files/archives — cloc • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Count lines of code, comments and whitespace in source files/archives

    + +
    + +
    cloc(source = ".", extract_with = NULL)
    + +

    Arguments

    + + + + + + + + + + +
    source

    file, directory or archive to read from (can be a valid URL)

    extract_with

    passed into cloc command line. This option is only +needed if cloc is unable to figure out how to extract the contents of +the input file(s) by itself.

    + +

    Value

    + +

    tibble

    + + +

    Examples

    +
    # by dir +cloc(system.file("extdata", package="cloc"))
    #> # A tibble: 2 x 10 +#> source language file_count file_count_pct loc loc_pct blank_lines +#> <chr> <chr> <int> <dbl> <int> <dbl> <int> +#> 1 extda… C++ 1 0.5 142 0.507 41 +#> 2 extda… R 1 0.5 138 0.493 24 +#> # … with 3 more variables: blank_line_pct <dbl>, comment_lines <int>, +#> # comment_line_pct <dbl>
    +# by file +cloc(system.file("extdata", "qrencoder.cpp", package="cloc"))
    #> # A tibble: 1 x 10 +#> source language file_count file_count_pct loc loc_pct blank_lines +#> <chr> <chr> <int> <dbl> <int> <dbl> <int> +#> 1 qrenc… C++ 1 1 142 1 41 +#> # … with 3 more variables: blank_line_pct <dbl>, comment_lines <int>, +#> # comment_line_pct <dbl>
    +# requires a network connection therefore is set for you to run it manually +
    # NOT RUN { +# from a url +cloc("https://rud.is/dl/cloc-1.74.tar.gz") +# }
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/cloc_by_file.html b/docs/reference/cloc_by_file.html new file mode 100644 index 0000000..9a31d3c --- /dev/null +++ b/docs/reference/cloc_by_file.html @@ -0,0 +1,185 @@ + + + + + + + + +Count lines of code, comments and whitespace in source files/archives by file — cloc_by_file • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Count lines of code, comments and whitespace in source files/archives by file

    + +
    + +
    cloc_by_file(source, extract_with = NULL)
    + +

    Arguments

    + + + + + + + + + + +
    source

    file, directory or archive to read from (can be a valid URL)

    extract_with

    passed into cloc command line. This option is only +needed if cloc is unable to figure out how to extract the contents of +the input file(s) by itself.

    + +

    Value

    + +

    tibble

    + +

    Note

    + +

    Unlike it's cloc() counterpart, no percentages are reported by this function

    + + +

    Examples

    +
    # whole dir +str(cloc_by_file(system.file("extdata", package="cloc")))
    #> Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 2 obs. of 6 variables: +#> $ source : chr "extdata" "extdata" +#> $ filename : chr "/Users/bob/packages/cloc/inst/extdata/qrencoder.cpp" "/Users/bob/packages/cloc/inst/extdata/dbi.r" +#> $ language : chr "C++" "R" +#> $ loc : int 142 138 +#> $ blank_lines : int 41 24 +#> $ comment_lines: int 63 71
    +# single file +str(cloc_by_file(system.file("extdata", "qrencoder.cpp", package="cloc")))
    #> Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1 obs. of 6 variables: +#> $ source : chr "qrencoder.cpp" +#> $ filename : chr "/Users/bob/packages/cloc/inst/extdata/qrencoder.cpp" +#> $ language : chr "C++" +#> $ loc : int 142 +#> $ blank_lines : int 41 +#> $ comment_lines: int 63
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/cloc_call.html b/docs/reference/cloc_call.html new file mode 100644 index 0000000..e92ceb1 --- /dev/null +++ b/docs/reference/cloc_call.html @@ -0,0 +1,1009 @@ + + + + + + + + +Call <code>cloc.pl</code> directly with granular control over options — cloc_call • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    It is nigh impossible to predict all use-cases for the cloc.pl acript and +create associated R functions for them. To that end, this function provides direct +access to the script and enables direct passing of command-line parameters +via processx::run().

    + +
    + +
    cloc_call(args = character(), echo = TRUE, ...)
    +
    +cloc_help(echo = FALSE)
    +
    +cloc_version(echo = FALSE)
    +
    +cloc_os(echo = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    args,

    character vector, arguments to the command. They will be escaped +via base::shQuote().

    echo

    echo Whether to print the standard output and error to the screen. +Note that the order of the standard output and error lines are not necessarily +correct, as standard output is typically buffered.

    ...

    other options/parameters passed on to processx::run()

    + +

    Value

    + +

    the structure returned by processx::run() (a list with four elements).

    + +

    Caveat utilitor

    + + +

    As indicated, this is an lower-level function providing granular control over +the options for cloc.pl. You are invoking an operating system command-line +and need to read the cloc.pl help very carefully as --- unlike the higher-level +functions -- there are no "guide railss" provided to do helpful things such as e +nsure you do not clobber files in a given directory.

    +

    processx::run() supports "callback functions" to make it easier to deal with +stdout and stderr and you may need to make use of those depending on the how +you are calling the underlying script.

    + + +

    Examples

    +
    # Get help on the parameters `cloc.pl` supports +cloc_call("--help", echo_cmd=TRUE, echo=TRUE)
    #> Running /usr/local/bin/perl /Users/bob/packages/cloc/inst/bin/cloc.pl --help +#> +#> Usage: cloc.pl [options] <file(s)/dir(s)/git hash(es)> | <set 1> <set 2> | <report files> +#> +#> Count, or compute differences of, physical lines of source code in the +#> given files (may be archives such as compressed tarballs or zip files, +#> or git commit hashes or branch names) and/or recursively below the +#> given directories. +#> +#> Input Options +#> --extract-with=<cmd> This option is only needed if cloc is unable +#> to figure out how to extract the contents of +#> the input file(s) by itself. +#> Use <cmd> to extract binary archive files (e.g.: +#> .tar.gz, .zip, .Z). Use the literal '>FILE<' as +#> a stand-in for the actual file(s) to be +#> extracted. For example, to count lines of code +#> in the input files +#> gcc-4.2.tar.gz perl-5.8.8.tar.gz +#> on Unix use +#> --extract-with='gzip -dc >FILE< | tar xf -' +#> or, if you have GNU tar, +#> --extract-with='tar zxf >FILE<' +#> and on Windows use, for example: +#> --extract-with="\"c:\Program Files\WinZip\WinZip32.exe\" -e -o >FILE< ." +#> (if WinZip is installed there). +#> --list-file=<file> Take the list of file and/or directory names to +#> process from <file>, which has one file/directory +#> name per line. Only exact matches are counted; +#> relative path names will be resolved starting from +#> the directory where cloc is invoked. +#> See also --exclude-list-file. +#> --vcs=<VCS> Invoke a system call to <VCS> to obtain a list of +#> files to work on. If <VCS> is 'git', then will +#> invoke 'git ls-files' to get a file list and +#> 'git submodule status' to get a list of submodules +#> whose contents will be ignored. See also --git +#> which accepts git commit hashes and branch names. +#> If <VCS> is 'svn' then will invoke 'svn list -R'. +#> The primary benefit is that cloc will then skip +#> files explicitly excluded by the versioning tool +#> in question, ie, those in .gitignore or have the +#> svn:ignore property. +#> Alternatively <VCS> may be any system command +#> that generates a list of files. +#> Note: cloc must be in a directory which can read +#> the files as they are returned by <VCS>. cloc will +#> not download files from remote repositories. +#> 'svn list -R' may refer to a remote repository +#> to obtain file names (and therefore may require +#> authentication to the remote repository), but +#> the files themselves must be local. +#> --unicode Check binary files to see if they contain Unicode +#> expanded ASCII text. This causes performance to +#> drop noticeably. +#> +#> Processing Options +#> --autoconf Count .in files (as processed by GNU autoconf) of +#> recognized languages. See also --no-autogen. +#> --by-file Report results for every source file encountered. +#> --by-file-by-lang Report results for every source file encountered +#> in addition to reporting by language. +#> --config <file> Read command line switches from <file> instead of +#> the default location of /Users/bob/.config/cloc/options.txt. +#> The file should contain one switch, along with +#> arguments (if any), per line. Blank lines and lines +#> beginning with '#' are skipped. Options given on +#> the command line take priority over entries read from +#> the file. +#> --count-and-diff <set1> <set2> +#> First perform direct code counts of source file(s) +#> of <set1> and <set2> separately, then perform a diff +#> of these. Inputs may be pairs of files, directories, +#> or archives. If --out or --report-file is given, +#> three output files will be created, one for each +#> of the two counts and one for the diff. See also +#> --diff, --diff-alignment, --diff-timeout, +#> --ignore-case, --ignore-whitespace. +#> --diff <set1> <set2> Compute differences in code and comments between +#> source file(s) of <set1> and <set2>. The inputs +#> may be any mix of files, directories, archives, +#> or git commit hashes. Use --diff-alignment to +#> generate a list showing which file pairs where +#> compared. See also --count-and-diff, --diff-alignment, +#> --diff-timeout, --ignore-case, --ignore-whitespace. +#> --diff-timeout <N> Ignore files which take more than <N> seconds +#> to process. Default is 10 seconds. Setting <N> +#> to 0 allows unlimited time. (Large files with many +#> repeated lines can cause Algorithm::Diff::sdiff() +#> to take hours.) +#> --follow-links [Unix only] Follow symbolic links to directories +#> (sym links to files are always followed). +#> --force-lang=<lang>[,<ext>] +#> Process all files that have a <ext> extension +#> with the counter for language <lang>. For +#> example, to count all .f files with the +#> Fortran 90 counter (which expects files to +#> end with .f90) instead of the default Fortran 77 +#> counter, use +#> --force-lang="Fortran 90",f +#> If <ext> is omitted, every file will be counted +#> with the <lang> counter. This option can be +#> specified multiple times (but that is only +#> useful when <ext> is given each time). +#> See also --script-lang, --lang-no-ext. +#> --force-lang-def=<file> Load language processing filters from <file>, +#> then use these filters instead of the built-in +#> filters. Note: languages which map to the same +#> file extension (for example: +#> MATLAB/Mathematica/Objective C/MUMPS/Mercury; +#> Pascal/PHP; Lisp/OpenCL; Lisp/Julia; Perl/Prolog) +#> will be ignored as these require additional +#> processing that is not expressed in language +#> definition files. Use --read-lang-def to define +#> new language filters without replacing built-in +#> filters (see also --write-lang-def, +#> --write-lang-def-incl-dup). +#> --git Forces the inputs to be interpreted as git targets +#> (commit hashes, branch names, et cetera) if these +#> are not first identified as file or directory +#> names. This option overrides the --vcs=git logic +#> if this is given; in other words, --git gets its +#> list of files to work on directly from git using +#> the hash or branch name rather than from +#> 'git ls-files'. This option can be used with +#> --diff to perform line count diffs between git +#> commits, or between a git commit and a file, +#> directory, or archive. Use -v/--verbose to see +#> the git system commands cloc issues. +#> --ignore-whitespace Ignore horizontal white space when comparing files +#> with --diff. See also --ignore-case. +#> --ignore-case Ignore changes in case; consider upper- and lower- +#> case letters equivalent when comparing files with +#> --diff. See also --ignore-whitespace. +#> --lang-no-ext=<lang> Count files without extensions using the <lang> +#> counter. This option overrides internal logic +#> for files without extensions (where such files +#> are checked against known scripting languages +#> by examining the first line for #!). See also +#> --force-lang, --script-lang. +#> --max-file-size=<MB> Skip files larger than <MB> megabytes when +#> traversing directories. By default, <MB>=100. +#> cloc's memory requirement is roughly twenty times +#> larger than the largest file so running with +#> files larger than 100 MB on a computer with less +#> than 2 GB of memory will cause problems. +#> Note: this check does not apply to files +#> explicitly passed as command line arguments. +#> --no-autogen[=list] Ignore files generated by code-production systems +#> such as GNU autoconf. To see a list of these files +#> (then exit), run with --no-autogen list +#> See also --autoconf. +#> --original-dir [Only effective in combination with +#> --strip-comments] Write the stripped files +#> to the same directory as the original files. +#> --read-binary-files Process binary files in addition to text files. +#> This is usually a bad idea and should only be +#> attempted with text files that have embedded +#> binary data. +#> --read-lang-def=<file> Load new language processing filters from <file> +#> and merge them with those already known to cloc. +#> If <file> defines a language cloc already knows +#> about, cloc's definition will take precedence. +#> Use --force-lang-def to over-ride cloc's +#> definitions (see also --write-lang-def, +#> --write-lang-def-incl-dup). +#> --script-lang=<lang>,<s> Process all files that invoke <s> as a #! +#> scripting language with the counter for language +#> <lang>. For example, files that begin with +#> #!/usr/local/bin/perl5.8.8 +#> will be counted with the Perl counter by using +#> --script-lang=Perl,perl5.8.8 +#> The language name is case insensitive but the +#> name of the script language executable, <s>, +#> must have the right case. This option can be +#> specified multiple times. See also --force-lang, +#> --lang-no-ext. +#> --sdir=<dir> Use <dir> as the scratch directory instead of +#> letting File::Temp chose the location. Files +#> written to this location are not removed at +#> the end of the run (as they are with File::Temp). +#> --skip-uniqueness Skip the file uniqueness check. This will give +#> a performance boost at the expense of counting +#> files with identical contents multiple times +#> (if such duplicates exist). +#> --stdin-name=<file> Give a file name to use to determine the language +#> for standard input. (Use - as the input name to +#> receive source code via STDIN.) +#> --strip-comments=<ext> For each file processed, write to the current +#> directory a version of the file which has blank +#> and commented lines removed (in-line comments +#> persist). The name of each stripped file is the +#> original file name with .<ext> appended to it. +#> It is written to the current directory unless +#> --original-dir is on. +#> --strip-str-comments Replace comment markers embedded in strings with +#> 'xx'. This attempts to work around a limitation +#> in Regexp::Common::Comment where comment markers +#> embedded in strings are seen as actual comment +#> markers and not strings, often resulting in a +#> 'Complex regular subexpression recursion limit' +#> warning and incorrect counts. There are two +#> disadvantages to using this switch: 1/code count +#> performance drops, and 2/code generated with +#> --strip-comments will contain different strings +#> where ever embedded comments are found. +#> --sum-reports Input arguments are report files previously +#> created with the --report-file option. Makes +#> a cumulative set of results containing the +#> sum of data from the individual report files. +#> --processes=NUM [Available only on systems with a recent version +#> of the Parallel::ForkManager module. Not +#> available on Windows.] Sets the maximum number of +#> cores that cloc uses. The default value of 0 +#> disables multiprocessing. +#> --unix Override the operating system autodetection +#> logic and run in UNIX mode. See also +#> --windows, --show-os. +#> --use-sloccount If SLOCCount is installed, use its compiled +#> executables c_count, java_count, pascal_count, +#> php_count, and xml_count instead of cloc's +#> counters. SLOCCount's compiled counters are +#> substantially faster than cloc's and may give +#> a performance improvement when counting projects +#> with large files. However, these cloc-specific +#> features will not be available: --diff, +#> --count-and-diff, --strip-comments, --unicode. +#> --windows Override the operating system autodetection +#> logic and run in Microsoft Windows mode. +#> See also --unix, --show-os. +#> +#> Filter Options +#> --exclude-dir=<D1>[,D2,] Exclude the given comma separated directories +#> D1, D2, D3, et cetera, from being scanned. For +#> example --exclude-dir=.cache,test will skip +#> all files and subdirectories that have /.cache/ +#> or /test/ as their parent directory. +#> Directories named .bzr, .cvs, .hg, .git, .svn, +#> and .snapshot are always excluded. +#> This option only works with individual directory +#> names so including file path separators is not +#> allowed. Use --fullpath and --not-match-d=<regex> +#> to supply a regex matching multiple subdirectories. +#> --exclude-ext=<ext1>[,<ext2>[...]] +#> Do not count files having the given file name +#> extensions. +#> --exclude-lang=<L1>[,L2[...]] +#> Exclude the given comma separated languages +#> L1, L2, L3, et cetera, from being counted. +#> --exclude-list-file=<file> Ignore files and/or directories whose names +#> appear in <file>. <file> should have one file +#> name per line. Only exact matches are ignored; +#> relative path names will be resolved starting from +#> the directory where cloc is invoked. +#> See also --list-file. +#> --fullpath Modifies the behavior of --match-f, --not-match-f, +#> and --not-match-d to include the file's path +#> in the regex, not just the file's basename. +#> (This does not expand each file to include its +#> absolute path, instead it uses as much of +#> the path as is passed in to cloc.) +#> Note: --match-d always looks at the full +#> path and therefore is unaffected by --fullpath. +#> --include-ext=<ext1>[,ext2[...]] +#> Count only languages having the given comma +#> separated file extensions. Use --show-ext to +#> see the recognized extensions. +#> --include-lang=<L1>[,L2[...]] +#> Count only the given comma separated languages +#> L1, L2, L3, et cetera. Use --show-lang to see +#> the list of recognized languages. +#> --match-d=<regex> Only count files in directories matching the Perl +#> regex. For example +#> --match-d='/(src|include)/' +#> only counts files in directories containing +#> /src/ or /include/. Unlike --not-match-d, +#> --match-f, and --not-match-f, --match-d always +#> compares the fully qualified path against the +#> regex. +#> --not-match-d=<regex> Count all files except those in directories +#> matching the Perl regex. Only the trailing +#> directory name is compared, for example, when +#> counting in /usr/local/lib, only 'lib' is +#> compared to the regex. +#> Add --fullpath to compare parent directories to +#> the regex. +#> Do not include file path separators at the +#> beginning or end of the regex. +#> --match-f=<regex> Only count files whose basenames match the Perl +#> regex. For example +#> --match-f='^[Ww]idget' +#> only counts files that start with Widget or widget. +#> Add --fullpath to include parent directories +#> in the regex instead of just the basename. +#> --not-match-f=<regex> Count all files except those whose basenames +#> match the Perl regex. Add --fullpath to include +#> parent directories in the regex instead of just +#> the basename. +#> --skip-archive=<regex> Ignore files that end with the given Perl regular +#> expression. For example, if given +#> --skip-archive='(zip|tar(.(gz|Z|bz2|xz|7z))?)' +#> the code will skip files that end with .zip, +#> .tar, .tar.gz, .tar.Z, .tar.bz2, .tar.xz, and +#> .tar.7z. +#> --skip-win-hidden On Windows, ignore hidden files. +#> +#> Debug Options +#> --categorized=<file> Save names of categorized files to <file>. +#> --counted=<file> Save names of processed source files to <file>. +#> --diff-alignment=<file> Write to <file> a list of files and file pairs +#> showing which files were added, removed, and/or +#> compared during a run with --diff. This switch +#> forces the --diff mode on. +#> --explain=<lang> Print the filters used to remove comments for +#> language <lang> and exit. In some cases the +#> filters refer to Perl subroutines rather than +#> regular expressions. An examination of the +#> source code may be needed for further explanation. +#> --help Print this usage information and exit. +#> --found=<file> Save names of every file found to <file>. +#> --ignored=<file> Save names of ignored files and the reason they +#> were ignored to <file>. +#> --print-filter-stages Print processed source code before and after +#> each filter is applied. +#> --show-ext[=<ext>] Print information about all known (or just the +#> given) file extensions and exit. +#> --show-lang[=<lang>] Print information about all known (or just the +#> given) languages and exit. +#> --show-os Print the value of the operating system mode +#> and exit. See also --unix, --windows. +#> -v[=<n>] Verbose switch (optional numeric value). +#> -verbose[=<n>] Long form of -v. +#> --version Print the version of this program and exit. +#> --write-lang-def=<file> Writes to <file> the language processing filters +#> then exits. Useful as a first step to creating +#> custom language definitions. Note: languages which +#> map to the same file extension will be excluded. +#> (See also --force-lang-def, --read-lang-def). +#> --write-lang-def-incl-dup=<file> +#> Same as --write-lang-def, but includes duplicated +#> extensions. This generates a problematic language +#> definition file because cloc will refuse to use +#> it until duplicates are removed. +#> +#> Output Options +#> --3 Print third-generation language output. +#> (This option can cause report summation to fail +#> if some reports were produced with this option +#> while others were produced without it.) +#> --by-percent X Instead of comment and blank line counts, show +#> these values as percentages based on the value +#> of X in the denominator: +#> X = 'c' -> # lines of code +#> X = 'cm' -> # lines of code + comments +#> X = 'cb' -> # lines of code + blanks +#> X = 'cmb' -> # lines of code + comments + blanks +#> For example, if using method 'c' and your code +#> has twice as many lines of comments as lines +#> of code, the value in the comment column will +#> be 200%. The code column remains a line count. +#> --csv Write the results as comma separated values. +#> --csv-delimiter=<C> Use the character <C> as the delimiter for comma +#> separated files instead of ,. This switch forces +#> --file-encoding=<E> Write output files using the <E> encoding instead of +#> the default ASCII (<E> = 'UTF-7'). Examples: 'UTF-16', +#> 'euc-kr', 'iso-8859-16'. Known encodings can be +#> printed with +#> perl -MEncode -e 'print join("\n", Encode->encodings(":all")), "\n"' +#> --hide-rate Do not show line and file processing rates in the +#> output header. This makes output deterministic. +#> --json Write the results as JavaScript Object Notation +#> (JSON) formatted output. +#> --md Write the results as Markdown-formatted text. +#> --out=<file> Synonym for --report-file=<file>. +#> --progress-rate=<n> Show progress update after every <n> files are +#> processed (default <n>=100). Set <n> to 0 to +#> suppress progress output (useful when redirecting +#> output to STDOUT). +#> --quiet Suppress all information messages except for +#> the final report. +#> --report-file=<file> Write the results to <file> instead of STDOUT. +#> --sql=<file> Write results as SQL create and insert statements +#> which can be read by a database program such as +#> SQLite. If <file> is -, output is sent to STDOUT. +#> --sql-append Append SQL insert statements to the file specified +#> by --sql and do not generate table creation +#> statements. Only valid with the --sql option. +#> --sql-project=<name> Use <name> as the project identifier for the +#> current run. Only valid with the --sql option. +#> --sql-style=<style> Write SQL statements in the given style instead +#> of the default SQLite format. Styles include +#> 'Oracle' and 'Named_Columns'. +#> --sum-one For plain text reports, show the SUM: output line +#> even if only one input file is processed. +#> --xml Write the results in XML. +#> --xsl=<file> Reference <file> as an XSL stylesheet within +#> the XML output. If <file> is 1 (numeric one), +#> writes a default stylesheet, cloc.xsl (or +#> cloc-diff.xsl if --diff is also given). +#> This switch forces --xml on. +#> --yaml Write the results in YAML. +#>
    +# or use the helper version of the above +cloc_help()
    #> +#> Usage: cloc.pl [options] <file(s)/dir(s)/git hash(es)> | <set 1> <set 2> | <report files> +#> +#> Count, or compute differences of, physical lines of source code in the +#> given files (may be archives such as compressed tarballs or zip files, +#> or git commit hashes or branch names) and/or recursively below the +#> given directories. +#> +#> Input Options +#> --extract-with=<cmd> This option is only needed if cloc is unable +#> to figure out how to extract the contents of +#> the input file(s) by itself. +#> Use <cmd> to extract binary archive files (e.g.: +#> .tar.gz, .zip, .Z). Use the literal '>FILE<' as +#> a stand-in for the actual file(s) to be +#> extracted. For example, to count lines of code +#> in the input files +#> gcc-4.2.tar.gz perl-5.8.8.tar.gz +#> on Unix use +#> --extract-with='gzip -dc >FILE< | tar xf -' +#> or, if you have GNU tar, +#> --extract-with='tar zxf >FILE<' +#> and on Windows use, for example: +#> --extract-with="\"c:\Program Files\WinZip\WinZip32.exe\" -e -o >FILE< ." +#> (if WinZip is installed there). +#> --list-file=<file> Take the list of file and/or directory names to +#> process from <file>, which has one file/directory +#> name per line. Only exact matches are counted; +#> relative path names will be resolved starting from +#> the directory where cloc is invoked. +#> See also --exclude-list-file. +#> --vcs=<VCS> Invoke a system call to <VCS> to obtain a list of +#> files to work on. If <VCS> is 'git', then will +#> invoke 'git ls-files' to get a file list and +#> 'git submodule status' to get a list of submodules +#> whose contents will be ignored. See also --git +#> which accepts git commit hashes and branch names. +#> If <VCS> is 'svn' then will invoke 'svn list -R'. +#> The primary benefit is that cloc will then skip +#> files explicitly excluded by the versioning tool +#> in question, ie, those in .gitignore or have the +#> svn:ignore property. +#> Alternatively <VCS> may be any system command +#> that generates a list of files. +#> Note: cloc must be in a directory which can read +#> the files as they are returned by <VCS>. cloc will +#> not download files from remote repositories. +#> 'svn list -R' may refer to a remote repository +#> to obtain file names (and therefore may require +#> authentication to the remote repository), but +#> the files themselves must be local. +#> --unicode Check binary files to see if they contain Unicode +#> expanded ASCII text. This causes performance to +#> drop noticeably. +#> +#> Processing Options +#> --autoconf Count .in files (as processed by GNU autoconf) of +#> recognized languages. See also --no-autogen. +#> --by-file Report results for every source file encountered. +#> --by-file-by-lang Report results for every source file encountered +#> in addition to reporting by language. +#> --config <file> Read command line switches from <file> instead of +#> the default location of /Users/bob/.config/cloc/options.txt. +#> The file should contain one switch, along with +#> arguments (if any), per line. Blank lines and lines +#> beginning with '#' are skipped. Options given on +#> the command line take priority over entries read from +#> the file. +#> --count-and-diff <set1> <set2> +#> First perform direct code counts of source file(s) +#> of <set1> and <set2> separately, then perform a diff +#> of these. Inputs may be pairs of files, directories, +#> or archives. If --out or --report-file is given, +#> three output files will be created, one for each +#> of the two counts and one for the diff. See also +#> --diff, --diff-alignment, --diff-timeout, +#> --ignore-case, --ignore-whitespace. +#> --diff <set1> <set2> Compute differences in code and comments between +#> source file(s) of <set1> and <set2>. The inputs +#> may be any mix of files, directories, archives, +#> or git commit hashes. Use --diff-alignment to +#> generate a list showing which file pairs where +#> compared. See also --count-and-diff, --diff-alignment, +#> --diff-timeout, --ignore-case, --ignore-whitespace. +#> --diff-timeout <N> Ignore files which take more than <N> seconds +#> to process. Default is 10 seconds. Setting <N> +#> to 0 allows unlimited time. (Large files with many +#> repeated lines can cause Algorithm::Diff::sdiff() +#> to take hours.) +#> --follow-links [Unix only] Follow symbolic links to directories +#> (sym links to files are always followed). +#> --force-lang=<lang>[,<ext>] +#> Process all files that have a <ext> extension +#> with the counter for language <lang>. For +#> example, to count all .f files with the +#> Fortran 90 counter (which expects files to +#> end with .f90) instead of the default Fortran 77 +#> counter, use +#> --force-lang="Fortran 90",f +#> If <ext> is omitted, every file will be counted +#> with the <lang> counter. This option can be +#> specified multiple times (but that is only +#> useful when <ext> is given each time). +#> See also --script-lang, --lang-no-ext. +#> --force-lang-def=<file> Load language processing filters from <file>, +#> then use these filters instead of the built-in +#> filters. Note: languages which map to the same +#> file extension (for example: +#> MATLAB/Mathematica/Objective C/MUMPS/Mercury; +#> Pascal/PHP; Lisp/OpenCL; Lisp/Julia; Perl/Prolog) +#> will be ignored as these require additional +#> processing that is not expressed in language +#> definition files. Use --read-lang-def to define +#> new language filters without replacing built-in +#> filters (see also --write-lang-def, +#> --write-lang-def-incl-dup). +#> --git Forces the inputs to be interpreted as git targets +#> (commit hashes, branch names, et cetera) if these +#> are not first identified as file or directory +#> names. This option overrides the --vcs=git logic +#> if this is given; in other words, --git gets its +#> list of files to work on directly from git using +#> the hash or branch name rather than from +#> 'git ls-files'. This option can be used with +#> --diff to perform line count diffs between git +#> commits, or between a git commit and a file, +#> directory, or archive. Use -v/--verbose to see +#> the git system commands cloc issues. +#> --ignore-whitespace Ignore horizontal white space when comparing files +#> with --diff. See also --ignore-case. +#> --ignore-case Ignore changes in case; consider upper- and lower- +#> case letters equivalent when comparing files with +#> --diff. See also --ignore-whitespace. +#> --lang-no-ext=<lang> Count files without extensions using the <lang> +#> counter. This option overrides internal logic +#> for files without extensions (where such files +#> are checked against known scripting languages +#> by examining the first line for #!). See also +#> --force-lang, --script-lang. +#> --max-file-size=<MB> Skip files larger than <MB> megabytes when +#> traversing directories. By default, <MB>=100. +#> cloc's memory requirement is roughly twenty times +#> larger than the largest file so running with +#> files larger than 100 MB on a computer with less +#> than 2 GB of memory will cause problems. +#> Note: this check does not apply to files +#> explicitly passed as command line arguments. +#> --no-autogen[=list] Ignore files generated by code-production systems +#> such as GNU autoconf. To see a list of these files +#> (then exit), run with --no-autogen list +#> See also --autoconf. +#> --original-dir [Only effective in combination with +#> --strip-comments] Write the stripped files +#> to the same directory as the original files. +#> --read-binary-files Process binary files in addition to text files. +#> This is usually a bad idea and should only be +#> attempted with text files that have embedded +#> binary data. +#> --read-lang-def=<file> Load new language processing filters from <file> +#> and merge them with those already known to cloc. +#> If <file> defines a language cloc already knows +#> about, cloc's definition will take precedence. +#> Use --force-lang-def to over-ride cloc's +#> definitions (see also --write-lang-def, +#> --write-lang-def-incl-dup). +#> --script-lang=<lang>,<s> Process all files that invoke <s> as a #! +#> scripting language with the counter for language +#> <lang>. For example, files that begin with +#> #!/usr/local/bin/perl5.8.8 +#> will be counted with the Perl counter by using +#> --script-lang=Perl,perl5.8.8 +#> The language name is case insensitive but the +#> name of the script language executable, <s>, +#> must have the right case. This option can be +#> specified multiple times. See also --force-lang, +#> --lang-no-ext. +#> --sdir=<dir> Use <dir> as the scratch directory instead of +#> letting File::Temp chose the location. Files +#> written to this location are not removed at +#> the end of the run (as they are with File::Temp). +#> --skip-uniqueness Skip the file uniqueness check. This will give +#> a performance boost at the expense of counting +#> files with identical contents multiple times +#> (if such duplicates exist). +#> --stdin-name=<file> Give a file name to use to determine the language +#> for standard input. (Use - as the input name to +#> receive source code via STDIN.) +#> --strip-comments=<ext> For each file processed, write to the current +#> directory a version of the file which has blank +#> and commented lines removed (in-line comments +#> persist). The name of each stripped file is the +#> original file name with .<ext> appended to it. +#> It is written to the current directory unless +#> --original-dir is on. +#> --strip-str-comments Replace comment markers embedded in strings with +#> 'xx'. This attempts to work around a limitation +#> in Regexp::Common::Comment where comment markers +#> embedded in strings are seen as actual comment +#> markers and not strings, often resulting in a +#> 'Complex regular subexpression recursion limit' +#> warning and incorrect counts. There are two +#> disadvantages to using this switch: 1/code count +#> performance drops, and 2/code generated with +#> --strip-comments will contain different strings +#> where ever embedded comments are found. +#> --sum-reports Input arguments are report files previously +#> created with the --report-file option. Makes +#> a cumulative set of results containing the +#> sum of data from the individual report files. +#> --processes=NUM [Available only on systems with a recent version +#> of the Parallel::ForkManager module. Not +#> available on Windows.] Sets the maximum number of +#> cores that cloc uses. The default value of 0 +#> disables multiprocessing. +#> --unix Override the operating system autodetection +#> logic and run in UNIX mode. See also +#> --windows, --show-os. +#> --use-sloccount If SLOCCount is installed, use its compiled +#> executables c_count, java_count, pascal_count, +#> php_count, and xml_count instead of cloc's +#> counters. SLOCCount's compiled counters are +#> substantially faster than cloc's and may give +#> a performance improvement when counting projects +#> with large files. However, these cloc-specific +#> features will not be available: --diff, +#> --count-and-diff, --strip-comments, --unicode. +#> --windows Override the operating system autodetection +#> logic and run in Microsoft Windows mode. +#> See also --unix, --show-os. +#> +#> Filter Options +#> --exclude-dir=<D1>[,D2,] Exclude the given comma separated directories +#> D1, D2, D3, et cetera, from being scanned. For +#> example --exclude-dir=.cache,test will skip +#> all files and subdirectories that have /.cache/ +#> or /test/ as their parent directory. +#> Directories named .bzr, .cvs, .hg, .git, .svn, +#> and .snapshot are always excluded. +#> This option only works with individual directory +#> names so including file path separators is not +#> allowed. Use --fullpath and --not-match-d=<regex> +#> to supply a regex matching multiple subdirectories. +#> --exclude-ext=<ext1>[,<ext2>[...]] +#> Do not count files having the given file name +#> extensions. +#> --exclude-lang=<L1>[,L2[...]] +#> Exclude the given comma separated languages +#> L1, L2, L3, et cetera, from being counted. +#> --exclude-list-file=<file> Ignore files and/or directories whose names +#> appear in <file>. <file> should have one file +#> name per line. Only exact matches are ignored; +#> relative path names will be resolved starting from +#> the directory where cloc is invoked. +#> See also --list-file. +#> --fullpath Modifies the behavior of --match-f, --not-match-f, +#> and --not-match-d to include the file's path +#> in the regex, not just the file's basename. +#> (This does not expand each file to include its +#> absolute path, instead it uses as much of +#> the path as is passed in to cloc.) +#> Note: --match-d always looks at the full +#> path and therefore is unaffected by --fullpath. +#> --include-ext=<ext1>[,ext2[...]] +#> Count only languages having the given comma +#> separated file extensions. Use --show-ext to +#> see the recognized extensions. +#> --include-lang=<L1>[,L2[...]] +#> Count only the given comma separated languages +#> L1, L2, L3, et cetera. Use --show-lang to see +#> the list of recognized languages. +#> --match-d=<regex> Only count files in directories matching the Perl +#> regex. For example +#> --match-d='/(src|include)/' +#> only counts files in directories containing +#> /src/ or /include/. Unlike --not-match-d, +#> --match-f, and --not-match-f, --match-d always +#> compares the fully qualified path against the +#> regex. +#> --not-match-d=<regex> Count all files except those in directories +#> matching the Perl regex. Only the trailing +#> directory name is compared, for example, when +#> counting in /usr/local/lib, only 'lib' is +#> compared to the regex. +#> Add --fullpath to compare parent directories to +#> the regex. +#> Do not include file path separators at the +#> beginning or end of the regex. +#> --match-f=<regex> Only count files whose basenames match the Perl +#> regex. For example +#> --match-f='^[Ww]idget' +#> only counts files that start with Widget or widget. +#> Add --fullpath to include parent directories +#> in the regex instead of just the basename. +#> --not-match-f=<regex> Count all files except those whose basenames +#> match the Perl regex. Add --fullpath to include +#> parent directories in the regex instead of just +#> the basename. +#> --skip-archive=<regex> Ignore files that end with the given Perl regular +#> expression. For example, if given +#> --skip-archive='(zip|tar(.(gz|Z|bz2|xz|7z))?)' +#> the code will skip files that end with .zip, +#> .tar, .tar.gz, .tar.Z, .tar.bz2, .tar.xz, and +#> .tar.7z. +#> --skip-win-hidden On Windows, ignore hidden files. +#> +#> Debug Options +#> --categorized=<file> Save names of categorized files to <file>. +#> --counted=<file> Save names of processed source files to <file>. +#> --diff-alignment=<file> Write to <file> a list of files and file pairs +#> showing which files were added, removed, and/or +#> compared during a run with --diff. This switch +#> forces the --diff mode on. +#> --explain=<lang> Print the filters used to remove comments for +#> language <lang> and exit. In some cases the +#> filters refer to Perl subroutines rather than +#> regular expressions. An examination of the +#> source code may be needed for further explanation. +#> --help Print this usage information and exit. +#> --found=<file> Save names of every file found to <file>. +#> --ignored=<file> Save names of ignored files and the reason they +#> were ignored to <file>. +#> --print-filter-stages Print processed source code before and after +#> each filter is applied. +#> --show-ext[=<ext>] Print information about all known (or just the +#> given) file extensions and exit. +#> --show-lang[=<lang>] Print information about all known (or just the +#> given) languages and exit. +#> --show-os Print the value of the operating system mode +#> and exit. See also --unix, --windows. +#> -v[=<n>] Verbose switch (optional numeric value). +#> -verbose[=<n>] Long form of -v. +#> --version Print the version of this program and exit. +#> --write-lang-def=<file> Writes to <file> the language processing filters +#> then exits. Useful as a first step to creating +#> custom language definitions. Note: languages which +#> map to the same file extension will be excluded. +#> (See also --force-lang-def, --read-lang-def). +#> --write-lang-def-incl-dup=<file> +#> Same as --write-lang-def, but includes duplicated +#> extensions. This generates a problematic language +#> definition file because cloc will refuse to use +#> it until duplicates are removed. +#> +#> Output Options +#> --3 Print third-generation language output. +#> (This option can cause report summation to fail +#> if some reports were produced with this option +#> while others were produced without it.) +#> --by-percent X Instead of comment and blank line counts, show +#> these values as percentages based on the value +#> of X in the denominator: +#> X = 'c' -> # lines of code +#> X = 'cm' -> # lines of code + comments +#> X = 'cb' -> # lines of code + blanks +#> X = 'cmb' -> # lines of code + comments + blanks +#> For example, if using method 'c' and your code +#> has twice as many lines of comments as lines +#> of code, the value in the comment column will +#> be 200%. The code column remains a line count. +#> --csv Write the results as comma separated values. +#> --csv-delimiter=<C> Use the character <C> as the delimiter for comma +#> separated files instead of ,. This switch forces +#> --file-encoding=<E> Write output files using the <E> encoding instead of +#> the default ASCII (<E> = 'UTF-7'). Examples: 'UTF-16', +#> 'euc-kr', 'iso-8859-16'. Known encodings can be +#> printed with +#> perl -MEncode -e 'print join("\n", Encode->encodings(":all")), "\n"' +#> --hide-rate Do not show line and file processing rates in the +#> output header. This makes output deterministic. +#> --json Write the results as JavaScript Object Notation +#> (JSON) formatted output. +#> --md Write the results as Markdown-formatted text. +#> --out=<file> Synonym for --report-file=<file>. +#> --progress-rate=<n> Show progress update after every <n> files are +#> processed (default <n>=100). Set <n> to 0 to +#> suppress progress output (useful when redirecting +#> output to STDOUT). +#> --quiet Suppress all information messages except for +#> the final report. +#> --report-file=<file> Write the results to <file> instead of STDOUT. +#> --sql=<file> Write results as SQL create and insert statements +#> which can be read by a database program such as +#> SQLite. If <file> is -, output is sent to STDOUT. +#> --sql-append Append SQL insert statements to the file specified +#> by --sql and do not generate table creation +#> statements. Only valid with the --sql option. +#> --sql-project=<name> Use <name> as the project identifier for the +#> current run. Only valid with the --sql option. +#> --sql-style=<style> Write SQL statements in the given style instead +#> of the default SQLite format. Styles include +#> 'Oracle' and 'Named_Columns'. +#> --sum-one For plain text reports, show the SUM: output line +#> even if only one input file is processed. +#> --xml Write the results in XML. +#> --xsl=<file> Reference <file> as an XSL stylesheet within +#> the XML output. If <file> is 1 (numeric one), +#> writes a default stylesheet, cloc.xsl (or +#> cloc-diff.xsl if --diff is also given). +#> This switch forces --xml on. +#> --yaml Write the results in YAML. +#>
    +# show the OS type +cloc_call("--show-os")
    #> UNIX
    +# shortcut equivalent +cloc_os()
    #> [1] "UNIX"
    +# retrieve the OS type +trimws(cloc_call("--show-os")$stdout)
    #> UNIX
    #> [1] "UNIX"
    +# shortcut of the above with no echo and only returning trimmed stdout +cloc_os()
    #> [1] "UNIX"
    +# get version of cloc.pl script provided with the package +cloc_version()
    #> [1] "1.80"
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/cloc_cran.html b/docs/reference/cloc_cran.html new file mode 100644 index 0000000..fab1087 --- /dev/null +++ b/docs/reference/cloc_cran.html @@ -0,0 +1,180 @@ + + + + + + + + +Count lines of code (etc) from source packages on CRAN — cloc_cran • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Count lines of code (etc) from source packages on CRAN

    + +
    + +
    cloc_cran(pkgs, repos = getOption("repos"),
    +  contrib_url = utils::contrib.url(repos, "source"),
    +  .progress = interactive())
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + +
    pkgs

    names of packages

    repos

    character vector, the base URL(s) of the repositories to use, +i.e., the URL of the CRAN master such as "https://cran.r-project.org" +or its Statlib mirror, "http://lib.stat.cmu.edu/R/CRAN".

    contrib_url

    URL(s) of the contrib sections of the repositories. Use +this argument only if your repository mirror is incomplete, e.g., +because you burned only the ‘contrib’ section on a CD. Overrides +argument repos.

    .progress

    show a progress bar? Default: TRUE if running interactively.

    + +

    Value

    + +

    data frame (tibble)

    + + +

    Examples

    +
    # requires a network connection therefore is set for you to run it manually +
    # NOT RUN { +cloc_cran(c("archdata", "hrbrthemes", "iptools", "dplyr")) +# }
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/cloc_git.html b/docs/reference/cloc_git.html new file mode 100644 index 0000000..ca727bb --- /dev/null +++ b/docs/reference/cloc_git.html @@ -0,0 +1,173 @@ + + + + + + + + +Count lines of code, comments and whitespace in a git tree — cloc_git • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Count lines of code, comments and whitespace in a git tree

    + +
    + +
    cloc_git(repo, commit = ".", branch = NULL, credentials = NULL,
    +  progress = FALSE)
    + +

    Arguments

    + + + + + + + + + + + + + + +
    repo

    path to git repo; if repo is a URL like git://, it will be fetched into +a temporary directory

    commit

    "." for the current source tree or the commit identifier for a specific commit

    branch, credentials, progress

    passed on to git2r::clone().

    + +

    Value

    + +

    data frame (tibble)

    + + +

    Examples

    +
    # NOT RUN {
    +cloc_git("~/packages/cloc", "3643cd09d4b951b1b35d32dffe35985dfe7756c4")
    +
    +# from remote git
    +cloc_git("git://github.com/hrbrmstr/cloc.git")
    +# }
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/cloc_pkg.html b/docs/reference/cloc_pkg.html new file mode 100644 index 0000000..5531089 --- /dev/null +++ b/docs/reference/cloc_pkg.html @@ -0,0 +1,185 @@ + + + + + + + + +Count lines of code, comments and whitespace in a package — cloc_pkg • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Think of this as cloc() with saner defaults for packages. Skips common +IDE tempdirs, .git, inst, man.

    + +
    + +
    cloc_pkg(source = ".", extract_with = NULL)
    + +

    Arguments

    + + + + + + + + + + +
    source

    file, directory or archive to read from (can be a valid URL)

    extract_with

    passed into cloc command line. This option is only +needed if cloc is unable to figure out how to extract the contents of +the input file(s) by itself.

    + +

    Value

    + +

    data frame (tibble)

    + + +

    Examples

    +
    # by dir +cloc(system.file("extdata", package="cloc"))
    #> # A tibble: 2 x 10 +#> source language file_count file_count_pct loc loc_pct blank_lines +#> <chr> <chr> <int> <dbl> <int> <dbl> <int> +#> 1 extda… C++ 1 0.5 142 0.507 41 +#> 2 extda… R 1 0.5 138 0.493 24 +#> # … with 3 more variables: blank_line_pct <dbl>, comment_lines <int>, +#> # comment_line_pct <dbl>
    +# by file +cloc(system.file("extdata", "qrencoder.cpp", package="cloc"))
    #> # A tibble: 1 x 10 +#> source language file_count file_count_pct loc loc_pct blank_lines +#> <chr> <chr> <int> <dbl> <int> <dbl> <int> +#> 1 qrenc… C++ 1 1 142 1 41 +#> # … with 3 more variables: blank_line_pct <dbl>, comment_lines <int>, +#> # comment_line_pct <dbl>
    +# requires a network connection therefore is set for you to run it manually +
    # NOT RUN { +# from a url +cloc("https://rud.is/dl/cloc-1.74.tar.gz") +# }
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/cloc_pkg_md.html b/docs/reference/cloc_pkg_md.html new file mode 100644 index 0000000..707c5a6 --- /dev/null +++ b/docs/reference/cloc_pkg_md.html @@ -0,0 +1,144 @@ + + + + + + + + +Run <code><a href='cloc_pkg.html'>cloc_pkg()</a></code> on active package and format it as a markdown table for knitting into reports — cloc_pkg_md • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Run cloc_pkg() on active package and format it as a markdown table for knitting into reports

    + +
    + +
    cloc_pkg_md()
    + +

    Note

    + +

    Target application is output to Rmd files

    + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/cloc_recognized_languages.html b/docs/reference/cloc_recognized_languages.html new file mode 100644 index 0000000..dd138ad --- /dev/null +++ b/docs/reference/cloc_recognized_languages.html @@ -0,0 +1,185 @@ + + + + + + + + +Return a data frame of <code>cloc</code> recognized languages and associated extensions — cloc_recognized_languages • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Some file extensions map to multiple languages:

    + +
    + +
    cloc_recognized_languages()
    + +

    Value

    + +

    tibble

    + +

    Details

    + +
      +
    • .cl files could be Lisp or OpenCL

    • +
    • .d files could be D or dtrace

    • +
    • .f or .for files could be Fortran or Forth

    • +
    • .fs files could be Forth or F#

    • +
    • .inc files could be PHP or Pascal

    • +
    • .jl files could be Lisp or Julia

    • +
    • .m files could be MATLAB, Mathematica, Mercury, MUMPS, or Objective C

    • +
    • .pl files could be Perl or Prolog

    • +
    • .pp files could be Pascal or Puppet

    • +
    • .pro files could be IDL, Prolog, or a Qt Project

    • +
    • .ts files could be TypeScript or Qt Linguist

    • +
    • .v files Coq or Verilog/SystemVerilog

    • +
    +

    cloc has subroutines that attempt to identify the correct language based +on the file's contents for these special cases. Language identification +accuracy is a function of how much code the file contains; .m files with +just one or two lines for example, seldom have enough information to +correctly distinguish between MATLAB, Mercury, MUMPS, or Objective C.

    + + +

    Examples

    +
    cloc_recognized_languages()
    #> # A tibble: 242 x 2 +#> lang extensions +#> <chr> <chr> +#> 1 ABAP abap +#> 2 ActionScript as +#> 3 Ada ada, adb, ads, pad +#> 4 ADSO/IDSM adso +#> 5 Agda agda, lagda +#> 6 AMPLE ample, dofile, startup +#> 7 Ant build.xml, build.xml +#> 8 ANTLR Grammar g, g4 +#> 9 Apex Trigger trigger +#> 10 Arduino Sketch ino, pde +#> # … with 232 more rows
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/cloc_remove_comments.html b/docs/reference/cloc_remove_comments.html new file mode 100644 index 0000000..65b609e --- /dev/null +++ b/docs/reference/cloc_remove_comments.html @@ -0,0 +1,160 @@ + + + + + + + + +Strip comments and white space from a single source file — cloc_remove_comments • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Pass in a path to a source file and retrieve a version of the source file +without comments (or white space).

    + +
    + +
    cloc_remove_comments(source_file)
    + +

    Arguments

    + + + + + + +
    source_file

    path to source file

    + +

    Value

    + +

    character vector containing only code blocks

    + + +

    Examples

    +
    cloc_remove_comments(system.file("extdata", "qrencoder.cpp", package="cloc"))
    #> [1] "#include <Rcpp.h>\n#include \"qrencode.h\"\n#include <stdio.h>\n#include <unistd.h>\n#include <string>\n#include <fstream>\n#include <streambuf>\nusing namespace Rcpp;\n#define INCHES_PER_METER (100.0/2.54)\nstatic int rle = 1;\nstatic unsigned int fg_color[4] = {0, 0, 0, 255};\nstatic unsigned int bg_color[4] = {255, 255, 255, 255};\nNumericMatrix qrencode_raw(std::string to_encode,\n int version=0,\n int level=0,\n int hint=2,\n int caseinsensitive=1) {\n QRcode *qrcode ;\n unsigned char *row;\n int x, y;\n qrcode = QRcode_encodeString(to_encode.c_str(),\n version,\n (QRecLevel)level,\n (QRencodeMode)hint, caseinsensitive);\n NumericMatrix qr(qrcode->width, qrcode->width);\n for(y=0; y <qrcode->width; y++) {\n row = qrcode->data+(y*qrcode->width);\n for(x = 0; x < qrcode->width; x++) {\n qr(x, y) = row[x]&0x1;\n }\n }\n return(qr);\n}\nstatic FILE *openFile(const char *outfile) {\n FILE *fp;\n if(outfile == NULL || (outfile[0] == '-' && outfile[1] == '\\0')) {\n fp = stdout;\n } else {\n fp = fopen(outfile, \"wb\");\n if (fp == NULL) return(NULL);\n }\n return fp;\n}\nstatic void writeSVG_writeRect(FILE *fp, int x, int y, int width, char* col, float opacity) {\n if(fg_color[3] != 255) {\n fprintf(fp, \"\\t\\t\\t<rect x=\\\"%d\\\" y=\\\"%d\\\" width=\\\"%d\\\" height=\\\"1\\\" \"\\\n \"fill=\\\"#%s\\\" fill-opacity=\\\"%f\\\" />\\n\",\n x, y, width, col, opacity );\n } else {\n fprintf(fp, \"\\t\\t\\t<rect x=\\\"%d\\\" y=\\\"%d\\\" width=\\\"%d\\\" height=\\\"1\\\" \"\\\n \"fill=\\\"#%s\\\" />\\n\",\n x, y, width, col );\n }\n}\nCharacterVector writeSVG(QRcode *qrcode, int margin, int size, int dpi) {\n FILE *fp;\n unsigned char *row, *p;\n int x, y, x0, pen;\n int symwidth, realwidth;\n float scale;\n char fg[7], bg[7];\n float fg_opacity;\n float bg_opacity;\n char fname[L_tmpnam];\n memset(fname, 0, L_tmpnam);\n strncpy(fname,\"qrencoder-XXXXXX\", 16);\n fp = openFile(mktemp(fname));\n if (fp == NULL) return(R_NilValue);\n scale = dpi * INCHES_PER_METER / 100.0;\n symwidth = qrcode->width + margin * 2;\n realwidth = symwidth * size;\n snprintf(fg, 7, \"%02x%02x%02x\", fg_color[0], fg_color[1], fg_color[2]);\n snprintf(bg, 7, \"%02x%02x%02x\", bg_color[0], bg_color[1], bg_color[2]);\n fg_opacity = (float)fg_color[3] / 255;\n bg_opacity = (float)bg_color[3] / 255;\n fputs( \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\\n\", fp );\n fprintf( fp, \"<!-- Created with qrencode %s (http:\n QRcode_APIVersionString() );\n fprintf( fp, \"<svg width=\\\"%0.2fcm\\\" height=\\\"%0.2fcm\\\" viewBox=\\\"0 0 %d %d\\\"\"\\\n \" preserveAspectRatio=\\\"none\\\" version=\\\"1.1\\\"\" \\\n \" xmlns=\\\"http:\n realwidth / scale, realwidth / scale, symwidth, symwidth\n );\n fputs( \"\\t<g id=\\\"QRcode\\\">\\n\", fp );\n if(bg_color[3] != 255) {\n fprintf(fp, \"\\t\\t<rect x=\\\"0\\\" y=\\\"0\\\" width=\\\"%d\\\" height=\\\"%d\\\" fill=\\\"#%s\\\" fill-opacity=\\\"%f\\\" />\\n\", symwidth, symwidth, bg, bg_opacity);\n } else {\n fprintf(fp, \"\\t\\t<rect x=\\\"0\\\" y=\\\"0\\\" width=\\\"%d\\\" height=\\\"%d\\\" fill=\\\"#%s\\\" />\\n\", symwidth, symwidth, bg);\n }\n fputs( \"\\t\\t<g id=\\\"Pattern\\\">\\n\", fp);\n p = qrcode->data;\n for(y=0; y<qrcode->width; y++) {\n row = (p+(y*qrcode->width));\n if( !rle ) {\n for(x=0; x<qrcode->width; x++) {\n if(*(row+x)&0x1) {\n writeSVG_writeRect(fp,\tmargin + x,\n margin + y, 1,\n fg, fg_opacity);\n }\n }\n } else {\n pen = 0;\n x0 = 0;\n for(x=0; x<qrcode->width; x++) {\n if( !pen ) {\n pen = *(row+x)&0x1;\n x0 = x;\n } else {\n if(!(*(row+x)&0x1)) {\n writeSVG_writeRect(fp, x0 + margin, y + margin, x-x0, fg, fg_opacity);\n pen = 0;\n }\n }\n }\n if( pen ) {\n writeSVG_writeRect(fp, x0 + margin, y + margin, qrcode->width - x0, fg, fg_opacity);\n }\n }\n }\n fputs( \"\\t\\t</g>\\n\", fp );\n fputs( \"\\t</g>\\n\", fp );\n fputs( \"</svg>\\n\", fp );\n fclose( fp );\n std::ifstream t(fname);\n std::string str((std::istreambuf_iterator<char>(t)),\n std::istreambuf_iterator<char>());\n t.close();\n unlink(fname);\n return(Rcpp::wrap(str));\n}\nCharacterVector qrencode_svg(\n std::string to_encode,\n int version=0, int level=0, int hint=2,\n int caseinsensitive=1, int margin = 0, int size = 3, int dpi = 72) {\n QRcode *qrcode ;\n qrcode = QRcode_encodeString(to_encode.c_str(),\n version,\n (QRecLevel)level,\n (QRencodeMode)hint, caseinsensitive);\n return(writeSVG(qrcode, margin, size, dpi));\n}"
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/index.html b/docs/reference/index.html new file mode 100644 index 0000000..1f0b31b --- /dev/null +++ b/docs/reference/index.html @@ -0,0 +1,203 @@ + + + + + + + + +Function reference • cloc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    All functions

    +

    +
    +

    cloc-package

    +

    Count Lines of Code, Comments and Whitespace in Source Files and Archives

    +

    cloc()

    +

    Count lines of code, comments and whitespace in source files/archives

    +

    cloc_by_file()

    +

    Count lines of code, comments and whitespace in source files/archives by file

    +

    cloc_call() cloc_help() cloc_version() cloc_os()

    +

    Call cloc.pl directly with granular control over options

    +

    cloc_cran()

    +

    Count lines of code (etc) from source packages on CRAN

    +

    cloc_git()

    +

    Count lines of code, comments and whitespace in a git tree

    +

    cloc_pkg()

    +

    Count lines of code, comments and whitespace in a package

    +

    cloc_pkg_md()

    +

    Run cloc_pkg() on active package and format it as a markdown table for knitting into reports

    +

    cloc_recognized_languages()

    +

    Return a data frame of cloc recognized languages and associated extensions

    +

    cloc_remove_comments()

    +

    Strip comments and white space from a single source file

    +
    + + +
    + + +
    + + + + + +