r-lib / roxygen2

Generate R package documentation from inline R comments
https://roxygen2.r-lib.org
Other
590 stars 232 forks source link

roxygen produces lines longer than 90 characters #929

Closed Bisaloo closed 4 years ago

Bisaloo commented 4 years ago

I might be missing something but:

roc_proc_text(rd_roclet(), "
  #' Title
  #' @param space
  #'
  #' @export
  foo <- function(space = c('auto', 'di', 'tri', 'tcs', 'hexagon', 'coc', 'categorical', 'ciexyz', 'cielab', 'cielch', 'segment')) {}"
)

produces

$foo.Rd
% Generated by roxygen2: do not edit by hand
% Please edit documentation in ./<text>
\name{foo}
\alias{foo}
\title{Title}
\usage{
foo(
  space = c("auto", "di", "tri", "tcs", "hexagon", "coc", "categorical", "ciexyz", "cielab",
    "cielch", "segment")
)
}
\arguments{
\item{space}{}
}
\description{
Title
}

which is longer than 90 characters wide and produces a NOTE

Rd file 'colspace.Rd': \usage lines wider than 90 characters: space = c("auto", "di", "tri", "tcs", "hexagon", "coc", "categorical", "ciexyz", "cielab",

roxygen2 6.1.99.9001

This does not happen with the current CRAN version of roxygen2.

hadley commented 4 years ago

I think this was just a typo/thinko. Let me know if the fix doesn't work.

hongyuanjia commented 4 years ago

@hadley I encountered the same problem using roxygen2 v7.0.2.

roxygen2::roc_proc_text(roxygen2::rd_roclet(), "
  #' Title
  #' @param space
  #'
  #' @export
  foo <- function (
       source = c('AWI-CM-1-1-MR', 'BCC-CSM2-MR', 'CESM2', 'CESM2-WACCM',
                  'EC-Earth3', 'EC-Earth3-Veg', 'GFDL-ESM4', 'INM-CM4-8',
                  'INM-CM5-0', 'MPI-ESM1-2-HR', 'MRI-ESM2-0'),
       limit = 10000L
  ){}
  "
)

produces:

# $foo.Rd
# % Generated by roxygen2: do not edit by hand
# % Please edit documentation in ./<text>
# \name{foo}
# \alias{foo}
# \title{Title}
# \usage{
# foo(
#   source = c("AWI-CM-1-1-MR", "BCC-CSM2-MR", "CESM2", "CESM2-WACCM", "EC-Earth3",
#     "EC-Earth3-Veg", "GFDL-ESM4", "INM-CM4-8", "INM-CM5-0", "MPI-ESM1-2-HR", "MRI-ESM2-0"),
#   limit = 10000L
# )
# }
# \arguments{
# \item{space}{}
# }
# \description{
# Title
# }
# 

which is longer than 90 characters wide and produces a NOTE

❯ checking Rd line widths ... NOTE
  Rd file 'foo.Rd':
    \usage lines wider than 90 characters:
           "EC-Earth3-Veg", "GFDL-ESM4", "INM-CM4-8", "INM-CM5-0", "MPI-ES
M1-2-HR", "MRI-ESM2-0"),

  These lines will be truncated in the PDF manual.
hadley commented 4 years ago
out <- roxygen2::roc_proc_text(roxygen2::rd_roclet(), "
  #' Title
  #' @param space
  #'
  #' @export
  foo <- function (
       source = c('AWI-CM-1-1-MR', 'BCC-CSM2-MR', 'CESM2', 'CESM2-WACCM',
                  'EC-Earth3', 'EC-Earth3-Veg', 'GFDL-ESM4', 'INM-CM4-8',
                  'INM-CM5-0', 'MPI-ESM1-2-HR', 'MRI-ESM2-0'),
       limit = 10000L
  ){}
  "
)

usage <- format(out[[1]]$get_section("usage"))
nchar(strsplit(usage, "\n")[[1]])
#> [1]  7  4 81 91 16  1  1

Created on 2020-03-09 by the reprex package (v0.3.0)

So the widest line is 91 characters which suggests an off-by-one error somewhere