The goal of dotInternals is to set apart names of internal functions from the ones exported by adding a dot (.
) in front of their name. The package automates this task in a scalable manner, and can be a nifty tool for large legacy projects with tons of internal functions.
Having a separate naming pattern for exported versus non-exported functions brings clarity to both users and developers about the public API of the package.
Here is how functions will be renamed depending on whether they are exported or not:
- For exported functions, names will not be changed:
# before ---> after
extract_value() ---> extract_value()
.draw_graph() ---> .draw_graph()
- For non-exported functions, names will be prepended with a
.
, but only if it isn’t already named that way:
# before ---> after
extract_value() ---> .extract_value()
.draw_graph() ---> .draw_graph()
There is an exception to this rule: S3
/S4
methods will not be renamed, even if it is not exported.
# before ---> after
str.my_class() ---> str.my_class()
A few important things to keep in mind:
You need to run this function in the package root directory.
The package needs to be installed, rather than just sourced.
If you have run
dot_internals()
once and wish to run it again, you need to build the package before doing so.The function will not work if you have run
devtools::load_all()
/pkgload::load_all()
.There is also RStudio addin that you can use.
Installation
You can install the development version of dotInternals from GitHub with:
# install.packages("remotes")
remotes::install_github("IndrajeetPatil/dotInternals")
Acknowledgments
Hex sticker font is Lato, and the free clip-art image is taken from http://clipart-library.com.
Code of Conduct
Please note that the dotInternals project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.