Skip to content

Commit

Permalink
changes: unwrapping examples for exported functions when possible, wi…
Browse files Browse the repository at this point in the history
…th minor correction when needed.
  • Loading branch information
plecharpent committed Jul 4, 2023
1 parent 07f2e6c commit 3bbe969
Show file tree
Hide file tree
Showing 59 changed files with 80 additions and 145 deletions.
9 changes: 4 additions & 5 deletions R/all_out_var.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ all_out_var <- function(stics_version = "latest") {
#'
#'
#' @examples
#' \dontrun{
#' \donttest{
#' # Find by variable name (fuzzy search):
#' SticsRFiles::get_var_info("lai")
#'
Expand Down Expand Up @@ -138,16 +138,15 @@ get_var_info <- function(var = NULL,
#' @param version `r lifecycle::badge("deprecated")` `version` is no
#' longer supported, use `stics_version` instead.
#'
#' @return A boolean vector: `TRUE` if the variable exist, `FALSE` if it doesn't
#' @return A boolean vector: `TRUE` if the variable exist, `FALSE` otherwise
#'
#' @seealso `get_var_info()` for interactive use.
#'
#' @export
#'
#' @examples
#' \dontrun{
#' is_stics_var(c("lai(n)", "masec(n)", "truc"))
#' }
#' is_stics_var(c("lai(n)", "masec(n)", "unknown"))
#'
is_stics_var <- function(var,
stics_version = "latest",
version = lifecycle::deprecated()) {
Expand Down
2 changes: 1 addition & 1 deletion R/convert_xml2txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' @return None
#'
#' @examples
#' \dontrun{
#' \donttest{
#' xml_path <- "/path/to/corn_plt.xml"
#' javastics_path <- "/path/to/JavaSTICS/folder"
#' convert_xml2txt(xml_file = xml_path, java_dir = javastics_path)
Expand Down
4 changes: 2 additions & 2 deletions R/download_usm_xl.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#' @return A vector of copied files path.
#'
#' @examples
#' \dontrun{
#' \donttest{
#' download_usm_xl()
#' download_usm_xl(out_dir = "/path/to/destination/dir")
#' }
Expand Down Expand Up @@ -155,7 +155,7 @@ download_usm_xl <- function(file = NULL,
#' @return A vector of copied files path.
#'
#' @examples
#' \dontrun{
#' \donttest{
#' download_usm_csv(out_dir = "/path/to/destination/dir")
#' }
#'
Expand Down
9 changes: 4 additions & 5 deletions R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
#' @export
#'
#' @examples
#' \dontrun{
#' library(SticsRFiles)
#' sim <- SticsRFiles::get_sim(workspace = "inst/extdata/stics_example_1")
#' sim[[1]] # returns a `cropr_simulation` list
#' }
#' path <- file.path(get_examples_path("sti"), "workspace1")
#' sim <- SticsRFiles::get_sim(workspace = path)
#' # sim returns a `cropr_simulation` list
#'
`[.cropr_simulation` <- function(x, ...) {
l <- unclass(x)[...]
attr_names <- names(attributes(x))
Expand Down
4 changes: 2 additions & 2 deletions R/force_param_values.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
#' @return A logical status TRUE if successful, FALSE otherwise
#'
#' @examples
#' \dontrun{
#' \donttest{
#' example_txt_dir <- get_examples_path(file_type = "txt")
#' force_param_values(example_txt_dir,
#' setNames(object = c(220, 330), c("stlevamf", "stamflax")),
#' javastics = "/path/to/JavaSTICS/folder"
#' javastics = tempdir()
#' )
#' }
#'
Expand Down
3 changes: 0 additions & 3 deletions R/gen_obs.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@
#' files (FALSE), TRUE when no errors.
#'
#' @examples
#' \dontrun{
#'
#' xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
#' obs_df <- read_params_table(file = xl_path, sheet_name = "Obs")
#' gen_obs(df = obs_df, out_dir = "/path/to/dest/dir")
#' }
#'
#' @export
#'
Expand Down
5 changes: 1 addition & 4 deletions R/gen_sta_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@
#' @return an invisible xml_document object or a list of
#'
#' @examples
#' \dontrun{
#'
#' xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
#' sta_param_df <- read_params_table(file = xl_path, sheet_name = "Station")
#' gen_sta_xml(out_dir = "/path/to/dest/dir", param_df = sta_param_df)
#' }
#' gen_sta_xml(out_dir = tempdir(), param_df = sta_param_df)
#'
#' @export
#'
Expand Down
5 changes: 1 addition & 4 deletions R/gen_tec_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@
#' @return an invisible xml_document object or a list of
#'
#' @examples
#' \dontrun{
#'
#' xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
#' tec_param_df <- read_params_table(file = xl_path, sheet_name = "Tec")
#' gen_tec_xml(out_dir = "/path/to/dest/dir", param_df = tec_param_df)
#' }
#' gen_tec_xml(out_dir = tempdir(), param_df = tec_param_df)
#'
#' @export
#'
Expand Down
3 changes: 0 additions & 3 deletions R/gen_usms_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@
#' @return an invisible xml_document object
#'
#' @examples
#' \dontrun{
#'
#' 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)
#' }
#'
#' @export
#'
Expand Down
2 changes: 1 addition & 1 deletion R/gen_usms_xml2txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#' have been successfully copied in usms directories
#'
#' @examples
#' \dontrun{
#' \donttest{
#' javastics <- "/path/to/JavaSTICS/folder"
#' workspace <- "/path/to/workspace"
#'
Expand Down
4 changes: 1 addition & 3 deletions R/gen_varmod.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@
#' @return None
#'
#' @examples
#' \dontrun{
#' gen_varmod(".", c("lai(n)", "hauteur"))
#' gen_varmod("/path/to/stics/workspace", c("lai(n)", "hauteur"))
#' # Add a variable to the others:
#' gen_varmod(".", "masec(n)", append = TRUE)
#' # NB: var.mod will have "lai(n)","hauteur" and "masec(n)"
#' }
#'
#'
#' @export
#'
Expand Down
2 changes: 1 addition & 1 deletion R/get_climate_txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#'
#'
#' @examples
#' library(SticsRFiles)
#' path <- get_examples_path(file_type = "txt")
#' Meteo <- get_climate_txt(path)
#'
#' @export
#'
get_climate_txt <- function(workspace = getwd(),
Expand Down
5 changes: 3 additions & 2 deletions R/get_obs.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@
#'
#'
#' @examples
#' \dontrun{
#'
#' path <- file.path(get_examples_path(file_type = "obs"), "mixed")
#'
#' # Get observations for all usms, but only banana has observations:
#' Meas <- get_obs(path)
#'
#' # Get observations only for banana:
#' Meas_banana <- get_obs(path, "banana")
#'
#'
#' \donttest{
#' # Get observations with real plant names when plant
#' # folder is not in the workspace:
#' get_obs(path, "banana", javastics = "/path/to/JavaSTICS/folder")
Expand Down
4 changes: 2 additions & 2 deletions R/get_param_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
#' @export
#'
#' @examples
#'
#' \donttest{
#' get_param_info(param = "albedo")
#' \dontrun{

#' get_param_info(param = "albedo", file = "/path/to/file.xml")
#'
#' get_param_info(param = "albedo", formalism = "special")
Expand Down
10 changes: 4 additions & 6 deletions R/get_param_txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
#'
#'
#' @examples
#' # Read the interrow distance parameter:
#' \dontrun{
#' library(SticsRFiles)
#' path <- get_examples_path(file_type = "txt")
#' get_param_txt(path, param = "interrang")
#'
#' # Getting varietal values:
#' # Getting the interrow distance parameter value
#' get_param_txt(path, param = "interrang")
#'
#' # Getting varietal parameters values
#' # Get the leaf lifespan of the variety used in the usm:
#' get_param_txt(workspace = path, param = "durvieF")
#' # Get the leaf lifespan of another variety available in the plant file:
Expand All @@ -57,7 +55,7 @@
#' get_param_txt(workspace = path, param = "durvieF", variety = varieties)
#' # Or get it from the output of the function returning all parameters:
#' get_param_txt(workspace = path)$plant$plant1$durvieF
#' }
#'
#'
#' @export
get_param_txt <- function(workspace = getwd(),
Expand Down
3 changes: 0 additions & 3 deletions R/get_plants_nb.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#' @return A named numeric vector of plants number per usm
#'
#' @examples
#' \dontrun{
#'
#' # Xml case
#' xml_usms <- file.path(get_examples_path(file_type = "xml"), "usms.xml")
#' get_plants_nb(xml_usms)
Expand All @@ -27,7 +25,6 @@
#' # Txt case
#' txt_usm <- file.path(get_examples_path(file_type = "txt"), "new_travail.usm")
#' get_plants_nb(txt_usm)
#' }
#'
#' @export
#'
Expand Down
3 changes: 1 addition & 2 deletions R/get_report_results.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#' @export
#'
#' @examples
#' \dontrun{
#' path <- get_examples_path(file_type = "sti")
#' get_report_results(workspace = path)
#'
Expand All @@ -34,7 +33,7 @@
#' get_report_results(workspace = path)
#'
#' get_report_results(workspace = path, file_name = "mod_rapportA.sti")
#' }
#'
#'
get_report_results <- function(workspace,
file_name = "mod_rapport.sti",
Expand Down
4 changes: 1 addition & 3 deletions R/get_sim.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ get_daily_results <- function(...) {
#' See Details section for more information about the "Plant" column.
#'
#' @examples
#' \dontrun{
#' path <- get_examples_path(file_type = "sti")
#' get_sim(path, "banana")
#' }
#' sim_data <- get_sim(path, "banana")
#'
#' @export
#'
Expand Down
5 changes: 0 additions & 5 deletions R/get_stics_versions_compat.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#' an existing version selected using version_index.
#'
#' @examples
#' #
#' \dontrun{
#'
#' # Getting the complete versions list
#' get_stics_versions_compat()
#'
Expand All @@ -23,8 +20,6 @@
#' # Getting the previous version of the latest one
#' get_stics_versions_compat(-1)
#'
#' #
#' }
#'
#' @export
#'
Expand Down
2 changes: 1 addition & 1 deletion R/get_usms_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#' and `get_usms_list()` to get the list of usms.
#'
#' @examples
#' \dontrun{
#' \donttest{
#'
#' get_usms_files(
#' workspace = "/path/to/workspace",
Expand Down
4 changes: 1 addition & 3 deletions R/set_param_txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
#' @export
#'
#' @examples
#' \dontrun{
#'
#' # Getting example data path
#' path <- get_examples_path(file_type = "txt")
#'
Expand All @@ -72,7 +70,7 @@
#' # in the soil file, we use set_soil_txt():
#' set_soil_txt(file = file.path(path, "param.sol"),
#' param = "cailloux", layer = 2, value = 1)
#' }
#'
#'
set_param_txt <- function(workspace = getwd(),
param,
Expand Down
2 changes: 1 addition & 1 deletion R/set_param_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#' value= list(c(1,2), c(2.3,4.5))
#'
#' @examples
#' \dontrun{
#' \donttest{
#'
#' # Soil file
#'
Expand Down
4 changes: 1 addition & 3 deletions R/stics_examples_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
#' @export
#'
#' @examples
#' \dontrun{
#'
#' get_examples_path(file_type = "csv")
#'
#' get_examples_path(file_type = c("csv", "sti"))
#'
#' get_examples_path(file_type = "csv", stics_version = "V8.5")
#' }
#'
get_examples_path <- function(file_type, stics_version = "latest",
version_name = lifecycle::deprecated()) {
if (lifecycle::is_present(version_name)) {
Expand Down
2 changes: 1 addition & 1 deletion R/upgrade_param_newform_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @details See SticsRFiles::get_stics_versions_compat() for listing versions
#'
#' @examples
#' \dontrun{
#' \donttest{
#' upgrade_param_newform_xml(
#' file = "/path/to/param_newform.xml",
#' out_dir = "/path/to/directory",
Expand Down
4 changes: 2 additions & 2 deletions R/upgrade_plt_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#'
#' @export
#'
#' @details See SticsRFiles::get_stics_versions_compat() for listing versions
#' @details See get_stics_versions_compat() for listing versions
#'
#' @examples
#' \dontrun{
#' \donttest{
#' upgrade_plt_xml(
#' file = "/path/to/_plt.xml",
#' param_gen_file = "/path/to/param_gen.xml",
Expand Down
2 changes: 1 addition & 1 deletion R/upgrade_sta_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @details See SticsRFiles::get_stics_versions_compat() for listing versions
#'
#' @examples
#' \dontrun{
#' \donttest{
#' upgrade_sta_xml(
#' file = "/path/to/_sta.xml",
#' out_dir = "/path/to/directory",
Expand Down
4 changes: 2 additions & 2 deletions R/upgrade_usms_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#'
#' @export
#'
#' @details See SticsRFiles::get_stics_versions_compat() for listing versions
#' @details See get_stics_versions_compat() for listing versions
#'
#' @examples
#' \dontrun{
#' \donttest{
#' upgrade_usms_xml(
#' file = "/path/to/usms.xml",
#' out_dir = "/path/to/directory",
Expand Down
Loading

0 comments on commit 3bbe969

Please sign in to comment.