|
| 1 | +## R package development |
| 2 | + |
| 3 | +### Key commands |
| 4 | + |
| 5 | +``` |
| 6 | +# To run code |
| 7 | +Rscript -e "devtools::load_all(); code" |
| 8 | +
|
| 9 | +# To run all tests |
| 10 | +Rscript -e "devtools::test()" |
| 11 | +
|
| 12 | +# To run tests for R/{name.R} |
| 13 | +Rscript -e "devtools::test(filter = '{name}', reporter = 'llm')" |
| 14 | +
|
| 15 | +# To document the package |
| 16 | +Rscript -e "devtools::document()" |
| 17 | +
|
| 18 | +# To check pkgdown documentation |
| 19 | +Rscript -e "pkgdown::check_pkgdown()" |
| 20 | +
|
| 21 | +# To format code |
| 22 | +air format . |
| 23 | +``` |
| 24 | + |
| 25 | +### Coding |
| 26 | + |
| 27 | +* Always run `air format .` after generating code |
| 28 | +* Use the base pipe operator (`|>`) not the magrittr pipe (`%>%`) |
| 29 | +* Don't use `_$x` or `_$[["x"]]` since dbplyr must work on R 4.1. |
| 30 | +* Use `\() ...` for single-line anonymous functions. For all other cases, use `function() {...}` |
| 31 | + |
| 32 | +### Testing |
| 33 | + |
| 34 | +- Tests for `R/{name}.R` go in `tests/testthat/test-{name}.R`. |
| 35 | +- All new code should have an accompanying test. |
| 36 | +- If there are existing tests, place new tests next to similar existing tests. |
| 37 | +- Strive to keep your tests minimal with few comments. |
| 38 | + |
| 39 | +### Documentation |
| 40 | + |
| 41 | +- Every user-facing function should be exported and have roxygen2 documentation. |
| 42 | +- Wrap roxygen comments at 80 characters. |
| 43 | +- Internal functions should not have roxygen documentation. |
| 44 | +- Whenever you add a new documentation topic, also add the topic to `_pkgdown.yml`. |
| 45 | +- Use `pkgdown::check_pkgdown()` to check that all topics are included in the reference index. |
| 46 | + |
| 47 | +### Writing |
| 48 | + |
| 49 | +- Use sentence case for headings. |
| 50 | + |
| 51 | +### Proofreading |
| 52 | + |
| 53 | +If the user asks you to proofread a file, act as an expert proofreader and editor with a deep understanding of clear, engaging, and well-structured writing. |
| 54 | + |
| 55 | +Work paragraph by paragraph, always starting by making a TODO list that includes individual items for each top-level heading. |
| 56 | + |
| 57 | +Fix spelling, grammar, and other minor problems without asking the user. Label any unclear, confusing, or ambiguous sentences with a FIXME comment. |
| 58 | + |
| 59 | +Only report what you have changed. |
0 commit comments