Skip to content

Commit

Permalink
add examples, package docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonocarroll committed Nov 4, 2024
1 parent 073e29e commit 5f1d6ef
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 0 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
^data-raw$
^\.github$
^cran-comments\.md$
^CRAN-SUBMISSION$
6 changes: 6 additions & 0 deletions R/ntfy-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL
23 changes: 23 additions & 0 deletions R/ntfy.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ get_image_path <- function(image) {
#' @param password password with access to a protected topic.
#'
#' @return a [httr2::response()] object
#'
#' @examplesIf interactive()
#' # send a message to the default topic ('mytopic')
#' ntfy_send("test from R!")
#'
#' # can use tags (emoji)
#' ntfy_send(message = "sending with tags!",
#' tags = c(tags$cat, tags$dog)
#' )
#'
#' @export
ntfy_send <- function(message = "test",
title = NULL,
Expand Down Expand Up @@ -106,6 +116,10 @@ ntfy_send <- function(message = "test",
#'
#' @seealso \url{https://ntfy.sh/docs/subscribe/api/#json-message-format}
#'
#' @examplesIf interactive()
#' # get the last hour of notifications
#' ntfy_history(since = "1h")
#'
#' @export
ntfy_history <- function(since = "all",
topic = ntfy_topic(),
Expand Down Expand Up @@ -156,6 +170,11 @@ ntfy_history <- function(since = "all",
#' @param ... other arguments passed to [ntfy::ntfy_send()]
#'
#' @return the input x (for further piping) plus a notification will be sent
#'
#' @examplesIf interactive()
#' # report that a process has completed
#' Sys.sleep(3) |> ntfy_done("Woke up")
#'
#' @export
ntfy_done <- function(x,
message = paste0("Process completed at ", Sys.time()),
Expand Down Expand Up @@ -183,6 +202,10 @@ ntfy_done <- function(x,
#'
#' @return the result of evaluating x (for further piping) plus a notification will be sent
#'
#' @examplesIf interactive()
#' # report that a process has completed, and how long it took
#' Sys.sleep(3) |> ntfy_done_with_timing()
#'
#' @export
ntfy_done_with_timing <- function(x,
message = paste0("Process completed in ", time_result, "s"),
Expand Down
5 changes: 5 additions & 0 deletions R/tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
#' name is not found in `aliases`.
#'
#' @return nothing, just prints the emoji if one or more are found
#'
#' @examples
#' show_emoji("dog")
#' show_emoji("party")
#'
#' @export
show_emoji <- function(name = NULL, search = FALSE) {
if (is.null(name)) stop("`name` must be provided")
Expand Down
30 changes: 30 additions & 0 deletions man/ntfy-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/ntfy_done.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/ntfy_done_with_timing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/ntfy_history.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions man/ntfy_send.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions man/show_emoji.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5f1d6ef

Please sign in to comment.