Skip to content

Commit

Permalink
Now the quarto extension is eliminated
Browse files Browse the repository at this point in the history
  • Loading branch information
pingfan-hu committed Aug 22, 2024
1 parent 55fe78d commit d1cd303
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 10 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export(sd_create_survey)
export(sd_database)
export(sd_display_question)
export(sd_display_value)
export(sd_filter)
export(sd_get_data)
export(sd_next)
export(sd_question)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# surveydown (development version)

# surveydown 0.1.1
- We got rid of the Quarto extension. everything is in the surveydown R package now. An extra `sd_filter()` function is needed in the beginning of the qmd file.
- Added `sd_get_data()` with a `reactive` argument to enable reactive data fetching.
- `sd_question()` now has a `reactive` argument to enable reactive questions, and `sd_question_reactive()` was removed.
- Made `sd_admin_enable()` internal, changed to `admin_enable()`.
Expand Down
25 changes: 23 additions & 2 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,36 @@ tibble_to_list_of_lists <- function(tbl) {
if (!is.data.frame(tbl)) {
stop("Input must be a data frame or tibble")
}

if (!"condition" %in% names(tbl) || !"target" %in% names(tbl)) {
stop("Input must have 'condition' and 'target' columns")
}

lapply(seq_len(nrow(tbl)), function(i) {
list(
condition = tbl$condition[[i]],
target = tbl$target[i]
)
})
}

#' Set up Surveydown Filter for Quarto
#'
#' This function sets up the Surveydown Lua filter for use in Quarto documents.
#' It finds the filter path and sets the appropriate Quarto option.
#'
#' @return Invisibly returns the path to the Surveydown Lua filter.
#' @export
#'
#' @examples
#' \dontrun{
#' sd_filter()
#' }
sd_filter <- function() {
filter_path <- system.file("filter", "surveydown.lua", package = "surveydown")
if (filter_path == "") {
stop("Surveydown Lua filter not found. Please ensure the package is installed correctly.")
}
options(quarto.filters = filter_path)
invisible(filter_path)
}
7 changes: 0 additions & 7 deletions inst/extensions/jhelvy/surveydown/_extension.yml

This file was deleted.

File renamed without changes.
20 changes: 20 additions & 0 deletions man/sd_filter.Rd

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

3 changes: 2 additions & 1 deletion pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ reference:
- subtitle: Functions for setting up and creating surveys
contents:
- sd_setup
- sd_filter
- sd_create_survey
- title: "Survey Components"
desc: "Functions for defining survey questions, navigation, and storing values"
Expand All @@ -44,4 +45,4 @@ reference:
contents:
- sd_check_versions
- sd_update_extension
- sd_update_surveydown
- sd_update_surveydown

0 comments on commit d1cd303

Please sign in to comment.