Skip to content

Commit 326d75a

Browse files
Merge pull request #43 from lorenzwalthert/update_readme
tidy up README
2 parents 952942d + d1edeab commit 326d75a

File tree

3 files changed

+29
-514
lines changed

3 files changed

+29
-514
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ Suggests:
2121
knitr,
2222
rmarkdown,
2323
rstudioapi,
24-
testthat
24+
testthat,
25+
pkgload
2526
Remotes:
2627
r-lib/pkgload,
2728
krlmlr/utf8

README.Rmd

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,62 +18,40 @@ knitr::opts_chunk$set(
1818
# styler
1919

2020
[![Build Status](https://travis-ci.org/krlmlr/styler.svg?branch=master)](https://travis-ci.org/krlmlr/styler)
21-
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/krlmlr/styler?branch=master&svg=true)](https://ci.appveyor.com/project/lorenzwalthert/styler)
21+
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/krlmlr/styler?branch=master&svg=true)](https://ci.appveyor.com/project/krlmlr/styler)
2222
[![Project Status: WIP - Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](http://www.repostatus.org/badges/latest/wip.svg)](http://www.repostatus.org/#wip)
2323

2424
The goal of styler is to provide non-invasive pretty-printing of R source code
2525
while adhering to the [tidyverse](https://github.com/tidyverse/style) formatting
2626
rules. Support for custom style guides is planned.
2727

28-
You can style a simple character vector of code with `style_text()`, a directory
29-
with `style_dir()`or a whole R package with `style_pkg()`.
28+
You can style a simple character vector of code with `style_text()`:
3029
```{r echo=FALSE, message=FALSE}
31-
devtools::load_all()
30+
pkgload::load_all()
31+
library("magrittr")
3232
#knitr::opts_chunk$set(comment = NA)
3333
```
3434

3535

3636
```{r}
3737
ugly_code <- "a<-function( x){1+1} "
38-
style_text(ugly_code)
38+
style_text(ugly_code) %>%
39+
cat(sep = "\n")
3940
4041
```
4142

42-
You can find more information on the wiki of [Google Summer of Code 2017](https://github.com/rstats-gsoc/gsoc2017/wiki/Noninvasive-source-code-formatting)
43-
or check out the [pkgdown](https://krlmlr.github.io/styler/) page.
44-
45-
In the following, we present a dirty file and how it is styled with styler.
46-
The file can either be tidied, which is a less strict form of styling with an
47-
emphasis on preserving the programmer's intentions - or cleaned, which means to
48-
strictly apply the style guide at hand.
49-
50-
## Dirty source file
43+
There are a few variants of `style_text()`:
5144

52-
```{r}
53-
print_code <- function(x) {
54-
knitr::asis_output(
55-
paste(
56-
c("```r", "", "", "# ------", x, "# ------", "```"),
57-
collapse = "\n"))
58-
}
59-
60-
dirty <- readLines(here::here("tests/testthat/example/in.R"))
45+
* `style_file()` styles a single .R file.
46+
* `style_dir()` styles all .R files in a directory.
47+
* `style_pkg()` styles the source files of an R package.
48+
* An RStudio Addin that styles the active file .R file
6149

62-
print_code(dirty)
50+
```{r, out.width = "650px", echo = FALSE}
51+
knitr::include_graphics("https://raw.githubusercontent.com/lorenzwalthert/some_raw_data/master/styler_0.1.gif")
6352
```
6453

65-
## Tidied file
6654

67-
```{r}
68-
tidy <- style_text(dirty, get_transformers(strict = FALSE))
6955

70-
print_code(tidy)
71-
```
72-
73-
## Cleaned file
74-
75-
```{r}
76-
clean <- styler::style_text(dirty)
77-
78-
print_code(clean)
79-
```
56+
You can find more information on the wiki of [Google Summer of Code 2017](https://github.com/rstats-gsoc/gsoc2017/wiki/Noninvasive-source-code-formatting)
57+
or check out the [pkgdown](https://krlmlr.github.io/styler/) page.

0 commit comments

Comments
 (0)