addins.R 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #' RStudio Addin: Containerize R Markdown Document
  2. #'
  3. #' RStudio addin for containerizing the current document.
  4. #'
  5. #' @importFrom rstudioapi getActiveDocumentContext
  6. #'
  7. #' @keywords internal
  8. addin_lift = function() {
  9. context = rstudioapi::getActiveDocumentContext()
  10. path = normalizePath(context$'path')
  11. lift(path)
  12. }
  13. #' RStudio Addin: Containerize and Render R Markdown Document with Docker
  14. #'
  15. #' RStudio addin for containerizing and rendering the current document.
  16. #'
  17. #' @importFrom rstudioapi getActiveDocumentContext
  18. #'
  19. #' @keywords internal
  20. addin_lift_render_docker = function() {
  21. context = rstudioapi::getActiveDocumentContext()
  22. path = normalizePath(context$'path')
  23. lift(path)
  24. render_docker(path)
  25. }
  26. #' RStudio Addin: Remove Dangling Container + Image
  27. #'
  28. #' RStudio addin for removing any dangling Docker
  29. #' containers and images automatically.
  30. #'
  31. #' @importFrom rstudioapi getActiveDocumentContext
  32. #'
  33. #' @keywords internal
  34. addin_prune_dangling = function() {
  35. prune_container_auto()
  36. prune_image_auto()
  37. }
  38. #' RStudio Addin: Remove the Built Docker Image
  39. #'
  40. #' RStudio addin for removing the Docker images used for
  41. #' rendering the current document.
  42. #'
  43. #' @importFrom rstudioapi getActiveDocumentContext
  44. #'
  45. #' @keywords internal
  46. addin_prune_image = function() {
  47. context = rstudioapi::getActiveDocumentContext()
  48. path = normalizePath(context$'path')
  49. path = paste0(file_dir(path), '/', file_name_sans(path), '.docker.yml')
  50. prune_image(path)
  51. }