Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's about roxygen2 type of documentation for DescTools? #56

Open
GegznaV opened this issue Jul 18, 2020 · 12 comments
Open

What's about roxygen2 type of documentation for DescTools? #56

GegznaV opened this issue Jul 18, 2020 · 12 comments

Comments

@GegznaV
Copy link
Contributor

GegznaV commented Jul 18, 2020

@AndriSignorell, did you consider going from Rd documentation to markdown flavored roxygen2 documentation (which automatically generates Rd files)? It could be written in markdown so it is easier to read for developers (and spot typos and other discrepancies), the documentation is above the function so it is easier to understand what function does when you read .R files, some fields such as Usage are auto-generated so it is easier to maintain the documentation. There are specialized packages (e.g., Rd2roxygen and roxygen2md), that alleviate transitioning from the manually written Rd files to roxygen2 documentation. And we can use GitHub Actions to build documentation every time the package is uploaded to GitHub (so it is not required to do it locally).

roxygen2 can help to maintain the NAMESPACE file too.

@GegznaV
Copy link
Contributor Author

GegznaV commented Sep 29, 2020

Any ideas?

@AndriSignorell
Copy link
Owner

Well, ehhh... hmm, not sure about that...
give me some more time to consider. ;-)

@GegznaV
Copy link
Contributor Author

GegznaV commented Sep 29, 2020

There are automatic tools that may help. But the package is big, so I'd suggest a gradual transition.

@AndriSignorell
Copy link
Owner

I aggree that it would be a good idea to transfer the documentation to roxygen2. So we could start with Desc which has insufficient documentation anyway. The documentation has grown historically and is undoubtedly chaotic in character.
However it would be better from my point of view to separate the helpfiles for

  • {Desc.numeric, Desc.integer},
  • {Desc.factor, Desc.ordered, Desc.labelled},
  • Desc.logical,
  • {Desc.table, Desc.matrix},
  • {Desc.date, Desc.ts}
  • {Desc.data.frame, Desc.list}
  • Desc.formula
  • some generic information about {Desc, Desc.default}

as the calculations and the plots are extremely different. As a first step, I would split the Desc routines into specific files of their own in order to gain a better overview.

@GegznaV
Copy link
Contributor Author

GegznaV commented Feb 25, 2024

To create separate documentation files, @name and @rdname tags can be used. This post describes how to reuse documentation from similar functions. Yet, in the long run, I would like to have the interfaces of the same name functions (different methods) to be more unified than they are now as this gives more consistency.

@AndriSignorell
Copy link
Owner

Could you be more specific about the required interface changes? Maybe this would be the moment to revise the functions and their interfaces (including the docu) ...

@GegznaV
Copy link
Contributor Author

GegznaV commented Feb 25, 2024

E.g., in generic function main, plotit go as non positional arguments, and in the methods – as positional:

image

In the next example, the same color shows the same argument and the numbers show their position:

image

Usually, a good practice is to have all common arguments as positional ones before ..., and method-specific ones should go after .... Of course, it is not necessary to follow this recommendation 100%, but I constantly got confused about different data types and had to look up the documentation (or method definitions).

An exception is the formula method which is always different.

So maybe it is a good time to consider which arguments could always be in the same positions at the beginning.

Similar consistency principles could be applied to print and plot methods. For plot, the first 4 arguments could be x, xlab, ylab, and main.

@AndriSignorell
Copy link
Owner

Good point, I will put things together ...

@AndriSignorell
Copy link
Owner

AndriSignorell commented Feb 27, 2024

Here we go:

GetArgs <- function(FUN) {
  a <- formals(getAnywhere(FUN)$objs[[1]])
  arg.labels <- names(a)
  arg.values <- as.character(a)
  char <- sapply(a, is.character)
  arg.values[char] <- paste("\"", arg.values[char], "\"", sep="")
  c(fname=FUN, args=paste(StrTrim(gsub("= $", "", paste(arg.labels, arg.values, sep=" = "))), collapse=", "))
}

fcts <- grep("plot.Desc", unclass(lsf.str(envir = asNamespace("DescTools"), all.names = T)), v=T)
fargs <- t(unname(sapply(fcts, GetArgs)))

image

actually not really worked out...

@GegznaV
Copy link
Contributor Author

GegznaV commented Feb 28, 2024

It is brilliant! Task automation helps to spot things more easily.

@GegznaV
Copy link
Contributor Author

GegznaV commented Feb 28, 2024

A few more questions/remarks:

  1. For consistency with other methods, could we have col instead of col1?
  2. And for me, it would be more intuitive to have add_n instead of add_ni. It is not a crucial thing, but just an idea to consider.

@AndriSignorell
Copy link
Owner

Well, I think the situation needs an even more fundamental revision...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants