Skip to content

Commit

Permalink
unwrapping examples for exported functions for testing them using exa…
Browse files Browse the repository at this point in the history
…mples path and tempdir() for outputs
  • Loading branch information
plecharpent committed Jul 4, 2023
1 parent 3bbe969 commit c6b302f
Show file tree
Hide file tree
Showing 32 changed files with 144 additions and 125 deletions.
3 changes: 2 additions & 1 deletion R/convert_xml2txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
#' @return None
#'
#' @examples
#'
#' \donttest{
#' xml_path <- "/path/to/corn_plt.xml"
#' javastics_path <- "/path/to/JavaSTICS/folder"
#' convert_xml2txt(xml_file = xml_path, java_dir = javastics_path)
#' convert_xml2txt(file = xml_path, javastics = javastics_path)
#' }
#'
#' @export
Expand Down
3 changes: 1 addition & 2 deletions R/download_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#' @export
#'
#' @examples
#' \dontrun{
#'
#' # Getting all data
#' download_data()
Expand All @@ -28,7 +27,7 @@
#'
#' # Getting data for a given example : study_case_1 and a given version
#' download_data(example_dirs = "study_case_1", stics_version = "V9.0")
#' }
#'
download_data <- function(out_dir = tempdir(), example_dirs = NULL,
stics_version = "latest",
dir = lifecycle::deprecated(),
Expand Down
9 changes: 3 additions & 6 deletions R/gen_ini_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,18 @@
#' @return an invisible xml_document object or a list of
#'
#' @examples
#' \dontrun{
#' library(readxl)
#'
#' xl_path <- "inputs_stics_example.xlsx"
#' download_usm_xl(file = xl_path)
#' xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
#'
#' ini_param_df <- read_excel(xl_path, sheet = "Ini")
#' gen_ini_xml(
#' out_dir = "/path/to/dest/dir",
#' out_dir = tempdir(),
#' param_table = ini_param_df
#' )
#' }
#'
#' @export
#'
# TODO: refactor with gen_sta_file, gen_tec_file : same code
gen_ini_xml <- function(param_df = NULL,
file = NULL,
out_dir = getwd(),
Expand Down
2 changes: 0 additions & 2 deletions R/gen_sols_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@
#' @return an invisible xml_document object
#'
#' @examples
#' \dontrun{
#'
#' xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
#' sols_param_df <- read_params_table(file = xl_path, sheet_name = "Soils")
#' gen_sols_xml(file = "sols.xml", param_df = sols_param_df)
#' }
#'
#' @export
#'
Expand Down
3 changes: 2 additions & 1 deletion R/gen_usms_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
#' @examples
#' xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
#' usms_param_df <- read_params_table(file = xl_path, sheet_name = "USMs")
#' gen_usms_xml(usms_out_file = "usms.xml", usms_param = usms_param_df)
#' gen_usms_xml(file = file.path(tempdir(), "usms.xml"),
#' param_df = usms_param_df)
#'
#' @export
#'
Expand Down
4 changes: 2 additions & 2 deletions R/gen_varmod.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#' @return None
#'
#' @examples
#' gen_varmod(".", c("lai(n)", "hauteur"))
#' gen_varmod(tempdir(), c("lai(n)", "hauteur"))
#' # Add a variable to the others:
#' gen_varmod(".", "masec(n)", append = TRUE)
#' gen_varmod(tempdir(), "masec(n)", append = TRUE)
#' # NB: var.mod will have "lai(n)","hauteur" and "masec(n)"
#'
#'
Expand Down
4 changes: 1 addition & 3 deletions R/get_lai_forcing.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
#' for each usm
#'
#' @examples
#' \dontrun{
#'
#' # Xml case
#' xml_usms <- file.path(get_examples_path(file_type = "xml"), "usms.xml")
#' get_lai_forcing(xml_usms)
#' get_lai_forcing(xml_usms, "wheat")
#' get_lai_forcing(xml_usms, c("wheat", "intercrop_pea_barley"))
#' }
#'
#'
#' @export
#'
Expand Down
4 changes: 2 additions & 2 deletions R/get_param_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' @return A list of parameter values for each xml_file (a list of list)
#'
#' @examples
#' \dontrun{
#'
#' # Soil file
#' file <- file.path(get_examples_path(file_type = "xml"), "sols.xml")
#'
Expand Down Expand Up @@ -55,7 +55,7 @@
#'
#' # Getting all parameters for a given formalism: "irrigation"
#' get_param_xml(file, select = "formalisme", select_value = "irrigation")
#' }
#'
#' @export
get_param_xml <- function(file,
param = NULL,
Expand Down
12 changes: 7 additions & 5 deletions R/upgrade_ini_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
#' @details See SticsRFiles::get_stics_versions_compat() for listing versions
#'
#' @examples
#' \dontrun{
#'
#' dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
#'
#' upgrade_ini_xml(
#' file = "/path/to/_ini.xml",
#' out_dir = "/path/to/directory",
#' param_gen_file = "/path/to/param_gen.xml"
#' file = file.path(dir_path,"file_ini.xml"),
#' out_dir = tempdir(),
#' param_gen_file = file.path(dir_path, "param_gen.xml")
#' )
#' }
#'
upgrade_ini_xml <- function(file,
out_dir,
param_gen_file,
Expand Down
11 changes: 6 additions & 5 deletions R/upgrade_param_gen_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
#'
#' @export
#'
#' @details See SticsRFiles::get_stics_versions_compat() for listing versions
#' @details See get_stics_versions_compat() for listing versions
#'
#' @examples
#' \dontrun{
#' dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
#'
#' upgrade_param_gen_xml(
#' file = "/path/to/param_gen.xml",
#' out_dir = "/path/to/directory"
#' file = file.path(dir_path, "param_gen.xml"),
#' out_dir = tempdir()
#' )
#' }

upgrade_param_gen_xml <- function(file,
out_dir,
stics_version = "V9.2",
Expand Down
13 changes: 8 additions & 5 deletions R/upgrade_param_newform_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
#' @details See SticsRFiles::get_stics_versions_compat() for listing versions
#'
#' @examples
#' \donttest{

#' dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
#'
#' upgrade_param_newform_xml(
#' file = "/path/to/param_newform.xml",
#' out_dir = "/path/to/directory",
#' param_gen_file = "/path/to/param_gen.xml"
#' file = file.path(dir_path,"param_newform.xml"),
#' out_dir = tempdir(),
#' param_gen_file = file.path(dir_path, "param_gen.xml")
#' )
#' }
#'
#'
upgrade_param_newform_xml <- function(file,
out_dir,
param_gen_file,
Expand Down
14 changes: 8 additions & 6 deletions R/upgrade_plt_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
#' @details See get_stics_versions_compat() for listing versions
#'
#' @examples
#' \donttest{
#'
#' dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
#'
#' upgrade_plt_xml(
#' file = "/path/to/_plt.xml",
#' param_gen_file = "/path/to/param_gen.xml",
#' param_newform_file = "/path/to/param_newform.xml",
#' out_dir = "/path/to/directory"
#' file = file.path(dir_path,"file_plt.xml"),
#' out_dir = tempdir(),
#' param_newform_file = file.path(dir_path, "param_newform.xml"),
#' param_gen_file = file.path(dir_path, "param_gen.xml")
#' )
#' }
#'
upgrade_plt_xml <- function(file,
out_dir,
param_newform_file,
Expand Down
12 changes: 7 additions & 5 deletions R/upgrade_sols_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
#' @details See SticsRFiles::get_stics_versions_compat() for listing versions
#'
#' @examples
#' \dontrun{
#'
#' dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
#'
#' upgrade_sols_xml(
#' file = "/path/to/sols.xml",
#' param_gen_file = "/path/to/param_gen.xml",
#' out_dir = "/path/to/an/output/directory"
#' file = file.path(dir_path,"sols.xml" ),
#' out_dir = tempdir(),
#' param_gen_file = file.path(dir_path, "param_gen.xml")
#' )
#' }
#'
upgrade_sols_xml <- function(file,
out_dir,
param_gen_file,
Expand Down
12 changes: 7 additions & 5 deletions R/upgrade_sta_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
#' @details See SticsRFiles::get_stics_versions_compat() for listing versions
#'
#' @examples
#' \donttest{
#'
#' dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
#'
#' upgrade_sta_xml(
#' file = "/path/to/_sta.xml",
#' out_dir = "/path/to/directory",
#' param_gen_file = "/path/to/param_gen.xml"
#' file = file.path(dir_path,"file_sta.xml" ),
#' out_dir = tempdir(),
#' param_gen_file = file.path(dir_path, "param_gen.xml")
#' )
#' }
#'
upgrade_sta_xml <- function(file,
out_dir,
param_gen_file,
Expand Down
17 changes: 10 additions & 7 deletions R/upgrade_tec_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@
#'
#' @export
#'
#' @details See SticsRFiles::get_stics_versions_compat() for listing versions
#' @details See get_stics_versions_compat() for listing versions
#'
#' @examples
#' \dontrun{
#'
#' dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
#'
#' upgrade_tec_xml(
#' file = "/path/to/_tec.xml",
#' out_dir = "/path/to/directory",
#' param_newform_file = "/path/to/param_newform.xml",
#' param_gen_file = "/path/to/param_gen.xml"
#' file = file.path(dir_path,"file_tec.xml"),
#' out_dir = tempdir(),
#' param_newform_file = file.path(dir_path, "param_newform.xml"),
#' param_gen_file = file.path(dir_path, "param_gen.xml")
#' )
#' }
#'
#'
upgrade_tec_xml <- function(file,
out_dir,
param_newform_file,
Expand Down
13 changes: 7 additions & 6 deletions R/upgrade_usms_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
#' @details See get_stics_versions_compat() for listing versions
#'
#' @examples
#' \donttest{
#'
#' dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
#'
#' upgrade_usms_xml(
#' file = "/path/to/usms.xml",
#' out_dir = "/path/to/directory",
#' param_gen_file = "/path/to/param_gen.xml",
#' obs_dir = "/path/to/obs/directory"
#' file = file.path(dir_path,"usms.xml"),
#' out_dir = tempdir(),
#' param_gen_file = file.path(dir_path, "param_gen.xml")
#' )
#' }
#'
upgrade_usms_xml <- function(file,
out_dir,
param_gen_file,
Expand Down
3 changes: 2 additions & 1 deletion man/convert_xml2txt.Rd

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

3 changes: 1 addition & 2 deletions man/download_data.Rd

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

8 changes: 3 additions & 5 deletions man/gen_ini_xml.Rd

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

2 changes: 0 additions & 2 deletions man/gen_sols_xml.Rd

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

3 changes: 2 additions & 1 deletion man/gen_usms_xml.Rd

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

4 changes: 2 additions & 2 deletions man/gen_varmod.Rd

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

4 changes: 1 addition & 3 deletions man/get_lai_forcing.Rd

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

Loading

0 comments on commit c6b302f

Please sign in to comment.