pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

FR: use more clickable hyperlinks in error messages

Open olivroy opened this issue 11 months ago • 1 comments

Sorry if this issue is not as focused.

Here is a workflow I sometimes use when working on packages to preview its reference index without rendering everything.

# on  a package without an unititalized `docs` directory.
build_reference_index()
Error in `data_deps()`:
! Run pkgdown::init_site() first.

I was wondering if pkgdown::init_site() could be a runnable hyperlink?

# I do as instructed.
pkgdown::init_site()
Error: 'path/to/pkg/docs' is non-empty and not built by pkgdown

Unfortunately, there is an error.

I think that with my first call, the docs directory is initiated, but is corrupt.. In this case, maybe suggest users to use pkgdown::clean_site() then pkgdown::init_site() in the error message? I may have gotten that part wrong.

# running without error
pkgdown::clean_site()
pkgdown::init_site()
#> Copying '../../../AppData/Local/Programs/R/R-4.2.3/library/pkgdown/BS5/assets/link.svg' to 'link.svg'
#> Copying '../../../AppData/Local/Programs/R/R-4.2.3/library/pkgdown/BS5/assets/pkgdown.js' to 'pkgdown.js'

Then build_reference_index() works.

build_reference_index()
#> Writing 'reference/index.html'

I can click on the result after all that.

Maybe my workflow is incorrect, so looking for suggestions. However, if it is something that you think is sensible, could the process be simplified a little, so that possibly build_reference_index() work on the first try, or the roadmap to success is a little less bumpy (i.e. adding runnable hyperlinks in error messages that will not error )

Thanks!

Edit: some digging

# with empty state
pkgdown:::is_non_pkgdown_site("docs")
#> FALSE
build_reference_index()
Error in `data_deps()`:
! Run pkgdown::init_site() first.
pkgdown:::is_non_pkgdown_site("docs")
#> TRUE

olivroy avatar Aug 07 '23 17:08 olivroy

Nice idea. I hit this myself all the time too, so I'll definitely take a look at when I'm next working on pkgdown.

hadley avatar Oct 30 '23 16:10 hadley

@olivroy have we resolved this issue?

hadley avatar Apr 12 '24 13:04 hadley

Opened #2439 to solve this!

olivroy avatar Apr 12 '24 13:04 olivroy