Dasonk / docstring

Provides docstring like functionality to R functions without requiring the need to create a package.
57 stars 6 forks source link

Docstring unable to view the comment #27

Open kartik1611 opened 4 years ago

kartik1611 commented 4 years ago

I am unable to view the comments after changing the below function name and trying to view the comments , snippet and code below for reference purpose

Initially my function name was square but then changed to another variable and then tried to view the comments but I was unable to do so image

image

### code for reference purpose ` rm(list=ls(all=T)) library(docstring) ab <- function(a){

' @title :square function

' @description : print the squares of the number

'from 1 to the input given

' @param : input number

' @output : provide the squares of the input range

for(i in 1:a){ b <- i^2 print(b) } } ?ab

`

ghost commented 3 years ago

I could not replicate this issue. Are you still affected by it?

Dasonk commented 2 years ago

I'm also unable to reproduce this error. If you have any further info let me know but I'm going to close this for the time being.

KristanRomano commented 2 years ago

I do have the same issue.

Dasonk commented 2 years ago

Interesting - I still can't reproduce but can you provide the output of sessionInfo() and Sys.info()? That might help with debugging.

KristanRomano commented 2 years ago

The above code is working now. But this one does not

library(docstring) prova<-function(x){

'@title prova

'@description blabla

'@param x blabla

'@output x-1

x-1 }

mbuerg commented 1 year ago

I had a similar problem. I fixed it by using docstring(my_function) rather than ?my_function. I got an loadNamespace(x) error regarding rstudioapi the first time, but could solve it by

install.packages("rstudioapi") library(rstudioapi)

Jiayou-Chao commented 11 months ago

Interesting - I still can't reproduce but can you provide the output of sessionInfo() and Sys.info()? That might help with debugging.

I found that we can't have two functions that both have docstrings. They have the issue most likely because they had another function with docstrings.

library(docstring)
test1 <- function(x) {
  #' This is a test function
  #' @param x a number
  x <- x + 1
  return(x)
}

test2 <- function(x) {
  #' This is a test function
  #' @param x a number
  x <- x + 1
  return(x)
}

?test1
?test2

The output shows test1 is fine but not test2:

> ?test1

> ?test2
No documentation for ‘test2’ in specified packages and libraries:
you could try ‘??test2’
Jiayou-Chao commented 11 months ago

I had a similar problem. I fixed it by using docstring(my_function) rather than ?my_function. I got an loadNamespace(x) error regarding rstudioapi the first time, but could solve it by

install.packages("rstudioapi") library(rstudioapi)

This is very helpful information. If you run docstring(my_function) once, you will be able to run ?my_function in the future.

Dasonk commented 11 months ago

Interesting. I'll investigate. Are you using RStudio? Does the problem persist if you use R outside of RStudio?

Jiayou-Chao commented 11 months ago

Interesting. I'll investigate. Are you using RStudio? Does the problem persist if you use R outside of RStudio?

Yes, I use RStudio. I tried RGUI again, and got the same error.

Jiayou-Chao commented 11 months ago

It seems there has already been a pull request to fix it. https://github.com/Dasonk/docstring/pull/29#issue-945388857