Skip to content

Commit 6f63bed

Browse files
authored
Merge pull request #531 from tidymodels/more-doc-tools
Doc tool update for adjacent packages
2 parents ba1931b + 48f8988 commit 6f63bed

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

R/aaa_models.R

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ set_model_arg <- function(model, eng, parsnip, original, func, has_submodel) {
563563
#' @rdname set_new_model
564564
#' @keywords internal
565565
#' @export
566-
set_dependency <- function(model, eng, pkg) {
566+
set_dependency <- function(model, eng, pkg= "parsnip") {
567567
check_model_exists(model)
568568
check_eng_val(eng)
569569
check_pkg_val(pkg)
@@ -969,6 +969,7 @@ get_encoding <- function(model) {
969969
#' populates the list seen in "See Also" below. See the details section.
970970
#'
971971
#' @param mod A character string for the model file (e.g. "linear_reg")
972+
#' @param pkg A character string for the package where the function is invoked.
972973
#' @return
973974
#' `make_engine_list()` returns a character string that creates a
974975
#' bulleted list of links to more specific help files.
@@ -1010,8 +1011,9 @@ get_encoding <- function(model) {
10101011
#' @examples
10111012
#' find_engine_files("linear_reg")
10121013
#' cat(make_engine_list("linear_reg"))
1013-
find_engine_files <- function(mod) {
1014+
find_engine_files <- function(mod, pkg = "parsnip") {
10141015

1016+
requireNamespace(pkg, quietly = TRUE)
10151017
# Get available topics
10161018
topic_names <- search_for_engine_docs(mod)
10171019
if (length(topic_names) == 0) {
@@ -1030,16 +1032,16 @@ find_engine_files <- function(mod) {
10301032
eng <- eng[order(eng$.order),]
10311033

10321034
# Determine and label default engine
1033-
default <- get_default_engine(mod)
1035+
default <- get_default_engine(mod, pkg)
10341036
eng$default <- ifelse(eng$engine == default, " (default)", "")
10351037

10361038
eng
10371039
}
10381040

10391041
#' @export
10401042
#' @rdname doc-tools
1041-
make_engine_list <- function(mod) {
1042-
eng <- find_engine_files(mod)
1043+
make_engine_list <- function(mod, pkg = "parsnip") {
1044+
eng <- find_engine_files(mod, pkg)
10431045

10441046
res <-
10451047
glue::glue(" \\item \\code{\\link[=|eng$topic|]{|eng$engine|} |eng$default| }",
@@ -1049,24 +1051,29 @@ make_engine_list <- function(mod) {
10491051
res
10501052
}
10511053

1052-
get_default_engine <- function(mod) {
1053-
cl <- rlang::call2(mod, .ns = "parsnip")
1054+
get_default_engine <- function(mod, pkg= "parsnip") {
1055+
cl <- rlang::call2(mod, .ns = pkg)
10541056
rlang::eval_tidy(cl)$engine
10551057
}
10561058

10571059
#' @export
10581060
#' @rdname doc-tools
1059-
make_seealso_list <- function(mod) {
1060-
eng <- find_engine_files(mod)
1061+
make_seealso_list <- function(mod, pkg= "parsnip") {
1062+
requireNamespace(pkg, quietly = TRUE)
1063+
eng <- find_engine_files(mod, pkg)
10611064

10621065
res <-
10631066
glue::glue("\\code{\\link[=|eng$topic|]{|eng$engine| engine details}}",
10641067
.open = "|", .close = "|")
10651068

1066-
main <- c("\\code{\\link[=fit.model_spec]{fit.model_spec()}}",
1067-
"\\code{\\link[=set_engine]{set_engine()}}",
1068-
"\\code{\\link[=update]{update()}}"
1069-
)
1069+
if (pkg == "parsnip") {
1070+
main <- c("\\code{\\link[=fit.model_spec]{fit.model_spec()}}",
1071+
"\\code{\\link[=set_engine]{set_engine()}}",
1072+
"\\code{\\link[=update]{update()}}"
1073+
)
1074+
} else {
1075+
main <- NULL
1076+
}
10701077
paste0(c(main, res), collapse = ", ")
10711078
}
10721079

man/doc-tools.Rd

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/extract-parsnip.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/set_new_model.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)