Julian Karch
Julian Karch

Reputation: 492

HTML Validation Problems in R Package Documentation

I'm in the process of submitting an R package to CRAN, but I'm encountering the following NOTE when running devtools::check(remote = TRUE, manual = TRUE):

checking HTML version of manual ... NOTE
  Found the following HTML validation problems:
  plot_interactive.html:15:44 (plot_interactive.Rd:5): Error: <main> is not recognized!
  plot_interactive.html:15:44 (plot_interactive.Rd:5): Warning: discarding unexpected <main>
  plot_interactive.html:74:1 (plot_interactive.Rd:37): Warning: discarding unexpected </main>
  plot_interactive.html:4:1 (plot_interactive.Rd:5): Warning: <link> inserting "type" attribute
  plot_interactive.html:12:1 (plot_interactive.Rd:5): Warning: <script> proprietary attribute "onload"
  plot_interactive.html:12:1 (plot_interactive.Rd:5): Warning: <script> inserting "type" attribute
  plot_interactive.html:17:1 (plot_interactive.Rd:5): Warning: <table> lacks "summary" attribute
  plot_interactive.html:38:1 (plot_interactive.Rd:10): Warning: <table> lacks "summary" attribute
  start_gui.html:15:44 (start_gui.Rd:5): Error: <main> is not recognized!
  start_gui.html:15:44 (start_gui.Rd:5): Warning: discarding unexpected <main>
  start_gui.html:75:1 (start_gui.Rd:37): Warning: discarding unexpected </main>
  start_gui.html:4:1 (start_gui.Rd:5): Warning: <link> inserting "type" attribute
  start_gui.html:12:1 (start_gui.Rd:5): Warning: <script> proprietary attribute "onload"
  start_gui.html:12:1 (start_gui.Rd:5): Warning: <script> inserting "type" attribute
  start_gui.html:17:1 (start_gui.Rd:5): Warning: <table> lacks "summary" attribute
  start_gui.html:35:1 (start_gui.Rd:10): Warning: <table> lacks "summary" attribute

I'm using roxygen2 to generate the .Rd files. This NOTE seems to be commonly caused by older versions of roxygen2 (see this GitHub repository). However, I was already using roxygen2 version 7.2.X and have since updated to roxygen2_7.3.2, and the latest R version (4.4.1) and rerun devtools::document(). Unfortunately, the issue persists.

The package in question can be found here. The R files containing the roxygen2 comments are:

The generated .Rd files are:

Any insights on resolving these HTML validation issues would be greatly appreciated.

Upvotes: 0

Views: 132

Answers (1)

St&#233;phane Laurent
St&#233;phane Laurent

Reputation: 84659

I've never seen @examplesIf and \dontshow before. I googled and here are some observations.

The R code of the example is the following one in your Rd file:

\dontshow{

if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force) (\{ 

library(lavaan)
model <- ' 
  visual  =~ x1 + loadingx2*x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
'
fit <- cfa(model, data = HolzingerSwineford1939)
plot_interactive(fit)

\dontshow{\})
}

And I can see in this old thread as well as in the official Writing R Extensions that with \dontshow, the example code is not shown to the user but this code is executed during the R CHECK.

So, @examplesIf is not what you want.

And probably the invalid HTML code spotted by the R CHECK is some code coming from the output of the plot_interactive call.

Upvotes: 1

Related Questions