-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coding styles #151
coding styles #151
Conversation
@mpadge mentioned https://pypi.org/project/black/ could be mentioned (for Python, not R, but still interesting). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice collection of resources put together and explain.
I wrote comment in-doc as I was reading. The below could make more sense (or not) after reading those, as I have writting this after commenting in-doc.
Overall, I am thinking about this organization which is close to what you wrote:
- What is style guide ?
- set of rules for the better (clarity, collaboration, ...)
- Sometime enforce by the language (indentation in python), sometime quite loose like R (where you can add a lot of spaces) and so in the latter more own style exist
- Why does it matters ?
- Even alone, it helps easier reading and upkeep
- best for collaboration : proof ? Big organization have that for all language (ex: Google)
- General resources
- Tools are here to help
- linters are here for this (either to show you a problem, or sometime fix it for you)
- and Most IDE have or can use third-party linters .
- Usually people who code already apply a default style thanks to IDE (and this is why it is important to use IDE !)
- Coding Style for R
- As said, a lot of them can exist due to the language.
- Most known is from organization (tidyverse), but other orgs have their own (mlr)
- Users can have there own preferences (Mark, Roger, Yihui, ...)
- Tools to help styling in R
- IDE own support (like in RStudio)
- Initially, we had linter only: lintr - still useful
- If you don't mind auto-fixing: styler (most generic) formatR (opinionated)
- Can be setup for R in different tools (VSCODE plugin, EMACS, RStudio addins)
- Some tools go further with code improvement in context (pkgcheck)
- Coding R chunks in Rmd is also possible !
- Being respectful of coding style when contributing
- About etiquette and several scenarios
- One should follow the guide but sometimes maintenaire don't mind doing cosmetic change before merging
- Conclusion
This covers most of the content and my other ideas. Only Markdown styling needs to be place somewhere 😅
I am just sharing all this so that you can have materials to see how we could adapt (or not) the current content. It seemed easier for now that (re)writing some parts without discussion :)
knitr::knit_hooks$set( | ||
plot = function(x, options) { | ||
hugoopts <- options$hugoopts | ||
paste0( | ||
"{{<figure src=", | ||
'"', x, '" ', | ||
if (!is.null(hugoopts)) { | ||
glue::glue_collapse( | ||
glue::glue('{names(hugoopts)}="{hugoopts}"'), | ||
sep = " " | ||
) | ||
}, | ||
">}}\n" | ||
) | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this useful for your blog only ? Or for hugodown only ?
Otherwise, maybe a good addition in blogdown
Just writing thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think neither blogdown nor hugodown have this, or maybe one of them does now 🤔 It's for taking advantages of Hugo figure shortcode. 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I don't think they have it seems quite useful :) Maybe that worth a Feature Request or a PR in blogdown. But I'll remember and maybe I'll do it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks (almost) good to me!
A few suggested tweak for your to include (or not).
Thanks for the writing about my first comments!
|
||
For more tools helping with code improvements, refer to the [R-hub blog post "Workflow automation tools for package developers"](/2020/04/29/maintenance/) including tips on *when* to use such tools. | ||
|
||
## A special note on ( R ) Markdown styling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice way of placing Markdown and R Markdown together ! 😄
Co-authored-by: Christophe Dervieux <christophe.dervieux@gmail.com>
Co-authored-by: Christophe Dervieux <christophe.dervieux@gmail.com>
No description provided.