简体   繁体   English

R包/函数-为函数参数添加黄色注释框

[英]R package/function - adding yellow comment boxes for function arguments

I am dabbling around writing my first R-package, and was wondering how one can add those yellow comment boxes that pop up when you hover over the function argument (when you've hit tab in the function). 我正在尝试编写第一个R-package,并且想知道如何将鼠标悬停在函数参数上(当您在函数中单击tab时)弹出的黄色注释框。 See here: 看这里:

例

This is my code: 这是我的代码:

#' A web function
#'
#' This function allows you to call a website.
#' @param url put in a url
#' @keywords web
#' @export
#' @examples
#' webpage("google")

webpage <- function(url){
    if(!is.character(url)){
       url <- as.character(url)
} else{
     utils::browseURL(paste0("https://www.", url, ".com", collapse = ","))
  }
}

I use devtools with roxygen2 to document and build the package - all the files are there, and the package/function works once installed and loaded. 我将devtools与roxygen2一起使用来记录和构建软件包-所有文件都在那里,并且一旦安装和加载软件包/功能就可以使用。 The only thing is that the comment, #' @param url put in a url , I wrote does not show up as a yellow box. 唯一的事情是,我写#' @param url put in a url中的注释#' @param url put in a url不会显示为黄色框。

Any idea(s) what the problem might be? 任何想法可能是什么问题?

The issue resolved itself...apparently, when you have a function with several arguments, you get a list of said arguments, as in the picture above. 问题已经解决了……显然,当您有一个带有多个参数的函数时,您会得到一个上述参数的列表,如上图所示。 When there is only one argument, then you have to start typing the argument and use code completion to bring up the list. 如果只有一个参数,则必须开始键入该参数并使用代码完成功能来显示该列表。 Then, when you hover over the 'url' argument, it shows the yellow description box... 然后,当您将鼠标悬停在'url'参数上时,它将显示黄色的说明框...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM