diff --git a/DESCRIPTION b/DESCRIPTION index 0ca8a8b..abf67cb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: altdoc Title: Package Documentation Websites with 'Quarto', 'Docsify', 'Docute', or 'MkDocs' -Version: 0.5.0 +Version: 0.5.0.9000 Authors@R: c(person(given = "Etienne", family = "Bacher", diff --git a/R/import_readme.R b/R/import_readme.R index f604df5..8496981 100644 --- a/R/import_readme.R +++ b/R/import_readme.R @@ -53,7 +53,11 @@ } } - tar_file <- fs::path_join(c(tar_dir, "README.md")) + if (tool == "quarto_website") { + tar_file <- fs::path_join(c(tar_dir, "index.md")) + } else { + tar_file <- fs::path_join(c(tar_dir, "README.md")) + } src_file <- fs::path_join(c(src_dir, "README.md")) fs::file_copy(src_file, tar_file, overwrite = TRUE) .check_md_structure(tar_file) diff --git a/R/utils.R b/R/utils.R index 74ad9ed..298d7e2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -44,7 +44,7 @@ ) if (length(.gh_urls) == 0) { - return("") + return(NULL) } .gh_url <- .gh_urls[grep("github.com", .gh_urls)] @@ -58,7 +58,6 @@ .gh_url <- gsub("#.*", "", .gh_url) .gh_url <- unique(.gh_url) - if (length(.gh_url) == 0) .gh_url <- "" return(.gh_url) } diff --git a/tests/testthat/examples/testpkg.altdoc.noURL/DESCRIPTION b/tests/testthat/examples/testpkg.altdoc.noURL/DESCRIPTION new file mode 100644 index 0000000..7b1ab3c --- /dev/null +++ b/tests/testthat/examples/testpkg.altdoc.noURL/DESCRIPTION @@ -0,0 +1,15 @@ +Package: testpkg.altdoc.noURL +Type: Package +Title: What the Package Does (Title Case) +Version: 0.1.0 +Author: Who wrote it +Maintainer: The package maintainer +Description: More about what it does (maybe more than one line) + Use four spaces when indenting paragraphs within the Description. +License: What license is it under? +Encoding: UTF-8 +LazyData: true +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.3.1 +Imports: + R6 diff --git a/tests/testthat/examples/testpkg.altdoc.noURL/NAMESPACE b/tests/testthat/examples/testpkg.altdoc.noURL/NAMESPACE new file mode 100644 index 0000000..916be47 --- /dev/null +++ b/tests/testthat/examples/testpkg.altdoc.noURL/NAMESPACE @@ -0,0 +1,7 @@ +# Generated by roxygen2: do not edit by hand + +export(examplesIf_false) +export(examplesIf_true) +export(hello_base) +export(hello_r6) +importFrom(R6,R6Class) diff --git a/tests/testthat/examples/testpkg.altdoc.noURL/NEWS.md b/tests/testthat/examples/testpkg.altdoc.noURL/NEWS.md new file mode 100644 index 0000000..e99f4a9 --- /dev/null +++ b/tests/testthat/examples/testpkg.altdoc.noURL/NEWS.md @@ -0,0 +1,9 @@ +# foobar 1.1.0 + +* thanks @foo-bar for their contribution (#111) + +* thanks @foo2- for their contribution (#11) + +* thanks @JohnDoe, @JaneDoe + +* this should not be linked: foo.bar@email.com diff --git a/tests/testthat/examples/testpkg.altdoc.noURL/R/examplesIf_false.R b/tests/testthat/examples/testpkg.altdoc.noURL/R/examplesIf_false.R new file mode 100644 index 0000000..5dbadb0 --- /dev/null +++ b/tests/testthat/examples/testpkg.altdoc.noURL/R/examplesIf_false.R @@ -0,0 +1,12 @@ +#' Examples If FALSE +#' +#' @param x A parameter +#' +#' @return Some value +#' @export +#' +#' @examplesIf 2 + 2 == 5 +#' examplesIf_false() +examplesIf_false <- function() { + print("Hello, world!") +} diff --git a/tests/testthat/examples/testpkg.altdoc.noURL/R/examplesIf_true.R b/tests/testthat/examples/testpkg.altdoc.noURL/R/examplesIf_true.R new file mode 100644 index 0000000..aa3e937 --- /dev/null +++ b/tests/testthat/examples/testpkg.altdoc.noURL/R/examplesIf_true.R @@ -0,0 +1,12 @@ +#' Examples If TRUE +#' +#' @param x A parameter +#' +#' @return Some value +#' @export +#' +#' @examplesIf 2 + 2 == 4 +#' examplesIf_true() +examplesIf_true <- function() { + print("Hello, world!") +} diff --git a/tests/testthat/examples/testpkg.altdoc.noURL/R/hello_base.R b/tests/testthat/examples/testpkg.altdoc.noURL/R/hello_base.R new file mode 100644 index 0000000..38ee770 --- /dev/null +++ b/tests/testthat/examples/testpkg.altdoc.noURL/R/hello_base.R @@ -0,0 +1,28 @@ +#' Base function +#' +#' @param x A parameter +#' +#' @details +#' Some code with weird symbols: `pl$when(condition)` and `pl$then(output)` +#' +#' Some equations: \eqn{\partial Y / \partial X = a + \varepsilon/2} +#' +#' +#' @return Some value +#' @export +#' +#' @seealso \code{\link[base]{print}}, \code{\link{hello_r6}} +#' +#' @references Ihaka R, Gentleman R (1996). +#' R: A Language for Data Analysis and Graphics. +#' \emph{Journal of Computational and Graphical Statistics}. \bold{5}(3), 299--314. +#' \doi{10.2307/139080} +#' +#' @examples +#' hello_base() +#' +#' mtcars$drat <- mtcars$drat + 1 +#' head(mtcars[["drat"]], 2) +hello_base <- function(x = 2) { + print("Hello, world!") +} diff --git a/tests/testthat/examples/testpkg.altdoc.noURL/R/hello_r6.R b/tests/testthat/examples/testpkg.altdoc.noURL/R/hello_r6.R new file mode 100644 index 0000000..f0cd608 --- /dev/null +++ b/tests/testthat/examples/testpkg.altdoc.noURL/R/hello_r6.R @@ -0,0 +1,32 @@ +#' Create a "conductor" tour +#' +#' blah blah blah +#' @importFrom R6 R6Class +#' @export +hello_r6 <- R6::R6Class( + "Conductor", + private = list(x = 1), + + public = list( + #' @details + #' Initialise `Conductor`. + initialize = function() { + }, + + #' @param session A valid Shiny session. If `NULL` (default), the function + #' attempts to get the session with `shiny::getDefaultReactiveDomain()`. + #' + #' @details + #' Initialise `Conductor`. + init = function(session = NULL) { + }, + + #' @param title Title of the popover. + #' + #' @details + #' Add a step in a `Conductor` tour. + + step = function(title = NULL) { + } + ) +) diff --git a/tests/testthat/examples/testpkg.altdoc.noURL/README.Rmd b/tests/testthat/examples/testpkg.altdoc.noURL/README.Rmd new file mode 100644 index 0000000..2fc3f4a --- /dev/null +++ b/tests/testthat/examples/testpkg.altdoc.noURL/README.Rmd @@ -0,0 +1,41 @@ +--- +output: github_document +default-image-extension: "" +--- + + + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-", + out.width = "100%" +) +``` + +# testpkg.altdoc + + +[![R-universe status badge](https://grantmcdermott.r-universe.dev/badges/plot2)](https://grantmcdermott.r-universe.dev) + + +The goal of testpkg.altdoc is to ... + +## Installation + +You can install the development version of testpkg.altdoc like so: + +``` r +# FILL THIS IN! HOW CAN PEOPLE INSTALL YOUR DEV PACKAGE? +``` + +## Example + +This is a basic example which shows you how to solve a common problem: + +```{r example} +library(testpkg.altdoc) +summary(cars) +``` + diff --git a/tests/testthat/examples/testpkg.altdoc.noURL/README.md b/tests/testthat/examples/testpkg.altdoc.noURL/README.md new file mode 100644 index 0000000..8c81433 --- /dev/null +++ b/tests/testthat/examples/testpkg.altdoc.noURL/README.md @@ -0,0 +1,36 @@ + + + +# testpkg.altdoc + + + +[![R-universe status +badge](https://grantmcdermott.r-universe.dev/badges/plot2)](https://grantmcdermott.r-universe.dev) + + +The goal of testpkg.altdoc is to … + +## Installation + +You can install the development version of testpkg.altdoc like so: + +``` r +# FILL THIS IN! HOW CAN PEOPLE INSTALL YOUR DEV PACKAGE? +``` + +## Example + +This is a basic example which shows you how to solve a common problem: + +``` r +library(testpkg.altdoc) +summary(cars) +#> speed dist +#> Min. : 4.0 Min. : 2.00 +#> 1st Qu.:12.0 1st Qu.: 26.00 +#> Median :15.0 Median : 36.00 +#> Mean :15.4 Mean : 42.98 +#> 3rd Qu.:19.0 3rd Qu.: 56.00 +#> Max. :25.0 Max. :120.00 +``` diff --git a/tests/testthat/test-render_docs.R b/tests/testthat/test-render_docs.R index 0a9cc5e..b06ee6c 100644 --- a/tests/testthat/test-render_docs.R +++ b/tests/testthat/test-render_docs.R @@ -135,7 +135,6 @@ test_that("quarto: no error for basic workflow", { ### generate docs install.packages(".", repos = NULL, type = "source") - fs::file_move("README.Rmd", "README.qmd") # special thing quarto setup_docs("quarto_website") expect_no_error(render_docs(verbose = .on_ci())) @@ -150,6 +149,29 @@ test_that("quarto: no error for basic workflow", { # expect_snapshot(.readlines("docs/vignettes/test.html")) }) +# https://github.com/etiennebacher/altdoc/issues/307 +test_that("quarto: no error for basic workflow, no Github URL", { + skip_on_cran() + skip_if(.is_windows() && .on_ci(), "Windows on CI") + + ### setup: create a temp package using the structure of testpkg.altdoc.noURL + path_to_example_pkg <- fs::path_abs( + test_path("examples/testpkg.altdoc.noURL") + ) + create_local_project() + fs::dir_delete("R") + fs::dir_copy(path_to_example_pkg, ".") + all_files <- list.files("testpkg.altdoc.noURL", full.names = TRUE) + for (i in all_files) { + fs::file_move(i, ".") + } + fs::dir_delete("testpkg.altdoc.noURL") + + install.packages(".", repos = NULL, type = "source") + setup_docs("quarto_website") + expect_no_error(render_docs(verbose = .on_ci())) +}) + test_that("quarto: autolink", { skip_on_cran() skip_if(.is_windows() && .on_ci(), "Windows on CI") @@ -167,7 +189,6 @@ test_that("quarto: autolink", { ### generate docs install.packages(".", repos = NULL, type = "source") - fs::file_move("README.Rmd", "README.qmd") # special thing quarto setup_docs("quarto_website") expect_no_error(render_docs(verbose = .on_ci()))