~hrbrmstr/cloc

cloc/README.Rmd -rw-r--r-- 3.7 KiB
0350958fhrbrmstr Working on #10 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
---
output: rmarkdown::github_document
editor_options: 
  chunk_output_type: console
---
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
```

```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```

```{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```

## What's Inside The Tin

The following functions are implemented:

```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```

## Installation

```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```

## Usage

```{r lib-ex}
library(cloc)
library(tibble) # for printing

# current version
packageVersion("cloc")

```

Basic usage

```{r message=FALSE, warning=FALSE, error=FALSE}
# by dir
cloc(system.file("extdata", package="cloc"))

# by file
cloc(system.file("extdata", "qrencoder.cpp", package="cloc"))

# from a url
cloc("https://rud.is/dl/cloc-1.74.tar.gz")
```

Custom CRAN package counter:

```{r message=FALSE, warning=FALSE, error=FALSE}
cloc_cran(c("archdata", "hrbrthemes", "iptools", "dplyr"))
```

git tree 

```{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, 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

```{r message=FALSE, warning=FALSE, error=FALSE}
cloc_git("git://github.com/maelle/convertagd.git")
```

Detailed results by file

```{r message=FALSE, warning=FALSE, error=FALSE}
# whole dir
str(cloc_by_file(system.file("extdata", package="cloc")))

# single file
str(cloc_by_file(system.file("extdata", "qrencoder.cpp", package="cloc")))
```

Recognized languages

```{r message=FALSE, warning=FALSE, error=FALSE}
cloc_recognized_languages()
```

Strip comments and whitespace from individual source files

```{r message=FALSE, warning=FALSE, error=FALSE}
cat(
  cloc_remove_comments("https://raw.githubusercontent.com/maelle/convertagd/master/README.Rmd")
)
```

## cloc Metrics

```{r echo=FALSE}
cloc_pkg_md()
```

## 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.