From 0deace5ce3a37401dffd6fc77ec0af33a0ec2803 Mon Sep 17 00:00:00 2001 From: Saranjeet Kaur Date: Wed, 4 Dec 2024 12:38:15 +0000 Subject: [PATCH 1/2] add R coding style --- 08-lifecycle_of_a_Patch.Rmd | 2 +- 12-R_code_style.Rmd | 24 +++++++++++++++++++ ...Developers.Rmd => 13-R_Core_Developers.Rmd | 0 ...o_get_help.Rmd => 14-where_to_get_help.Rmd | 0 ...ments.Rmd => 15-news_and_announcements.Rmd | 0 ...eloper_tools.Rmd => 16-developer_tools.Rmd | 0 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 12-R_code_style.Rmd rename 12-R_Core_Developers.Rmd => 13-R_Core_Developers.Rmd (100%) rename 13-where_to_get_help.Rmd => 14-where_to_get_help.Rmd (100%) rename 14-news_and_announcements.Rmd => 15-news_and_announcements.Rmd (100%) rename 15-developer_tools.Rmd => 16-developer_tools.Rmd (100%) diff --git a/08-lifecycle_of_a_Patch.Rmd b/08-lifecycle_of_a_Patch.Rmd index b0687c5b..772fa316 100644 --- a/08-lifecycle_of_a_Patch.Rmd +++ b/08-lifecycle_of_a_Patch.Rmd @@ -8,7 +8,7 @@ R uses a workflow based on patches. A patch is the set of differences (additions There might be a situation where you come across a bug in R, which you may have an idea of how to fix. This can turn out to be an opportunity for you to submit a patch. By submitting a patch or a bug fix, you are helping to reduce the workload on the R developers in addition to yourself being a contributor to R! -When you submit a patch, you are helping the developer(s) and maintainer(s) so that they do not have to write the entire code from scratch. Instead, they can test and tweak your patch, if necessary. +When you submit a patch, you are helping the developer(s) and maintainer(s) so that they do not have to write the entire code from scratch. Instead, they can test and tweak your patch, if necessary. At this point, it might also be useful to refer to the [R coding style](#R-coding-style) to ensure that your patch is in line with the coding standards of R. ## What tools are required to submit a patch? diff --git a/12-R_code_style.Rmd b/12-R_code_style.Rmd new file mode 100644 index 00000000..f1e1f991 --- /dev/null +++ b/12-R_code_style.Rmd @@ -0,0 +1,24 @@ +# R Coding Style {#R-coding-style} + +This chapter introduces contributors to the coding style typically used by R Core, so that R Core can focus on the code and not style issues when reviewing patches. + +## General recommendations + +- Use 4 spaces for indentation in R and C code. +- Use spaces after commas and either side of operators. +- Use `<-` rather than `=` for assignment. +- Use `"`, instead of `'`, for quoting text. +- Use `TRUE` and `FALSE`, not `T` and `F`. +- Keep lines no longer than 80 characters. +- Avoid using special characters in file names (numbers, letters, `-`, and `_` are acceptable). +- Put a space after (not before) a comma. +- Put a space before and after `()` when used with `if`, `for`, or `while`. +- Place a space after `()` used for function arguments. +- Put a space before `|>` (the base R pipe operator). + +In general, try to make sure the code you write in an existing file has a style consistent with that file. + +## See also + +1. [R-internals manual](https://cran.r-project.org/doc/manuals/r-release/R-ints.html#R-coding-standards) +2. [Tidyverse style guide](https://style.tidyverse.org/) diff --git a/12-R_Core_Developers.Rmd b/13-R_Core_Developers.Rmd similarity index 100% rename from 12-R_Core_Developers.Rmd rename to 13-R_Core_Developers.Rmd diff --git a/13-where_to_get_help.Rmd b/14-where_to_get_help.Rmd similarity index 100% rename from 13-where_to_get_help.Rmd rename to 14-where_to_get_help.Rmd diff --git a/14-news_and_announcements.Rmd b/15-news_and_announcements.Rmd similarity index 100% rename from 14-news_and_announcements.Rmd rename to 15-news_and_announcements.Rmd diff --git a/15-developer_tools.Rmd b/16-developer_tools.Rmd similarity index 100% rename from 15-developer_tools.Rmd rename to 16-developer_tools.Rmd From 563281e91cafaa1e4d55f621e1526a535362a9b5 Mon Sep 17 00:00:00 2001 From: Saranjeet Kaur Date: Thu, 5 Dec 2024 17:48:22 +0000 Subject: [PATCH 2/2] add coding style chapter to _quarto.yml --- _quarto.yml | 19 ++++++++++--------- chapters/r_coding_style.qmd | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 chapters/r_coding_style.qmd diff --git a/_quarto.yml b/_quarto.yml index 0949758d..42335b80 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -21,17 +21,18 @@ book: - chapters/issue_tracking.qmd - chapters/reporting_bugs.qmd - chapters/submitting_feature_requests.qmd - - chapters/reviewing_bugs.qmd - - chapters/finding_the_source.qmd + - chapters/reviewing_bugs.qmd + - chapters/finding_the_source.qmd - chapters/lifecycle_of_a_patch.qmd - - chapters/documenting.qmd - - chapters/message_translations.qmd + - chapters/documenting.qmd + - chapters/message_translations.qmd - chapters/testing_pre_release_r_versions.qmd - - chapters/where_to_get_help.qmd - - chapters/news_and_announcements.qmd - - chapters/developer_tools.qmd - - chapters/additional_resources.qmd - - chapters/r_core_developers.qmd + - chapters/r_coding_style.qmd + - chapters/where_to_get_help.qmd + - chapters/news_and_announcements.qmd + - chapters/developer_tools.qmd + - chapters/additional_resources.qmd + - chapters/r_core_developers.qmd format: html: diff --git a/chapters/r_coding_style.qmd b/chapters/r_coding_style.qmd new file mode 100644 index 00000000..f1e1f991 --- /dev/null +++ b/chapters/r_coding_style.qmd @@ -0,0 +1,24 @@ +# R Coding Style {#R-coding-style} + +This chapter introduces contributors to the coding style typically used by R Core, so that R Core can focus on the code and not style issues when reviewing patches. + +## General recommendations + +- Use 4 spaces for indentation in R and C code. +- Use spaces after commas and either side of operators. +- Use `<-` rather than `=` for assignment. +- Use `"`, instead of `'`, for quoting text. +- Use `TRUE` and `FALSE`, not `T` and `F`. +- Keep lines no longer than 80 characters. +- Avoid using special characters in file names (numbers, letters, `-`, and `_` are acceptable). +- Put a space after (not before) a comma. +- Put a space before and after `()` when used with `if`, `for`, or `while`. +- Place a space after `()` used for function arguments. +- Put a space before `|>` (the base R pipe operator). + +In general, try to make sure the code you write in an existing file has a style consistent with that file. + +## See also + +1. [R-internals manual](https://cran.r-project.org/doc/manuals/r-release/R-ints.html#R-coding-standards) +2. [Tidyverse style guide](https://style.tidyverse.org/)