Skip to contents

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.

Usage

dot_internals()

Value

Changed .R and .Rmd files with all instances of internal functions replaced with their new "dotted" versions.

Details

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.

Examples

if (FALSE) {
  # Assuming you are in the package root directory
  dot_internals()
}