@@ -44,6 +44,37 @@ help <- function(topic, package = NULL) {
44
44
# found.
45
45
# ' @export
46
46
.ps.help.showHelpTopic <- function (topic ) {
47
+ help_handler <- tryCatch(
48
+ {
49
+ # Before we do anything to find the help page, we evaluate the topic expression
50
+ # to see if the object can be found in the current environment and if it has a
51
+ # custom help handler (eg. reticulate objects).
52
+ object <- eval(
53
+ parse(text = topic ),
54
+ envir = new.env(parent = globalenv())
55
+ )
56
+ # call_ark_method() returns NULL if no method is found for the object
57
+ # ark_positron_help_get_handler() must return a function that's called for
58
+ # its side effects (potentially showing documentation) and returning `TRUE`
59
+ # if it could handle the request. We could also make it
60
+ # actually show help imediatelly, but that makes it hard to separate
61
+ # non-existant methods, from methods that return `NULL` and actual errors.
62
+ # This also allows methods to skip matching objects for which they don't want
63
+ # to support, by simply returning a `NULL` handler.
64
+ call_ark_method(
65
+ " ark_positron_help_get_handler" ,
66
+ object
67
+ )
68
+ },
69
+ error = function (e ) {
70
+ NULL
71
+ }
72
+ )
73
+
74
+ if (! is.null(help_handler )) {
75
+ return (help_handler(topic ))
76
+ }
77
+
47
78
info <- split_topic(topic )
48
79
topic <- info $ topic
49
80
package <- info $ package
@@ -230,6 +261,11 @@ getHtmlHelpContentsDevImpl <- function(x) {
230
261
.ps.Call(" ps_browse_url" , as.character(url ))
231
262
}
232
263
264
+ # ' @export
265
+ .ps.help.browse_external_url <- function (url ) {
266
+ .ps.Call(" ps_help_browse_external_url" , as.character(url ))
267
+ }
268
+
233
269
# @param rd_file Path to an `.Rd` file.
234
270
# @returns The result of converting that `.Rd` to HTML and concatenating to a
235
271
# string.
0 commit comments