Skip to content

Commit 4af602f

Browse files
committed
add support for remote repos
1 parent 8d77986 commit 4af602f

22 files changed

Lines changed: 1049 additions & 30 deletions

CITATION.cff

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type: software
99
license: MIT
1010
title: 'rdocdump: Dump ''R'' Package Source, Documentation, and Vignettes into One
1111
File'
12-
version: 0.1.1
12+
version: 0.2.0.9000
1313
doi: 10.32614/CRAN.package.rdocdump
1414
identifiers:
1515
- type: doi
@@ -62,7 +62,7 @@ references:
6262
given-names: Jeroen
6363
email: jeroenooms@gmail.com
6464
orcid: https://orcid.org/0000-0002-4035-0289
65-
year: '2025'
65+
year: '2026'
6666
doi: 10.32614/CRAN.package.curl
6767
- type: software
6868
title: quarto
@@ -79,8 +79,31 @@ references:
7979
given-names: Christophe
8080
email: cderv@posit.co
8181
orcid: https://orcid.org/0000-0003-4474-2498
82-
year: '2025'
82+
year: '2026'
8383
doi: 10.32614/CRAN.package.quarto
84+
- type: software
85+
title: remotes
86+
abstract: 'remotes: R Package Installation from Remote Repositories, Including ''GitHub'''
87+
notes: Suggests
88+
url: https://remotes.r-lib.org
89+
repository: https://CRAN.R-project.org/package=remotes
90+
authors:
91+
- family-names: Csárdi
92+
given-names: Gábor
93+
email: csardi.gabor@gmail.com
94+
- family-names: Hester
95+
given-names: Jim
96+
- family-names: Wickham
97+
given-names: Hadley
98+
- family-names: Chang
99+
given-names: Winston
100+
- family-names: Morgan
101+
given-names: Martin
102+
- family-names: Tenenbaum
103+
given-names: Dan
104+
year: '2026'
105+
doi: 10.32614/CRAN.package.remotes
106+
version: '>= 2.2.0'
84107
- type: software
85108
title: testthat
86109
abstract: 'testthat: Unit Testing for R'
@@ -91,7 +114,7 @@ references:
91114
- family-names: Wickham
92115
given-names: Hadley
93116
email: hadley@posit.co
94-
year: '2025'
117+
year: '2026'
95118
doi: 10.32614/CRAN.package.testthat
96119
version: '>= 3.0.0'
97120
- type: software
@@ -117,6 +140,6 @@ references:
117140
email: hadley@posit.co
118141
- family-names: Chang
119142
given-names: Winston
120-
year: '2025'
143+
year: '2026'
121144
doi: 10.32614/CRAN.package.withr
122145

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: rdocdump
22
Title: Dump 'R' Package Source, Documentation, and Vignettes into One File
3-
Version: 0.1.1.9000
3+
Version: 0.2.0.9000
44
Authors@R:
55
person("Egor", "Kotov", , "kotov.egor@gmail.com", role = c("aut", "cre", "cph"),
66
comment = c(ORCID = "0000-0001-6690-5345"))
@@ -19,6 +19,7 @@ BugReports: https://github.com/e-kotov/rdocdump/issues
1919
Suggests:
2020
curl,
2121
quarto,
22+
remotes (>= 2.2.0),
2223
testthat (>= 3.0.0),
2324
withr
2425
VignetteBuilder:
@@ -27,4 +28,4 @@ Config/testthat/edition: 3
2728
Encoding: UTF-8
2829
Language: en
2930
Roxygen: list(markdown = TRUE)
30-
RoxygenNote: 7.3.2
31+
RoxygenNote: 7.3.3

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# rdocdump (development version)
22

3+
* Added support for remote repository references (GitHub, GitLab, Bitbucket) in `rdd_to_txt()` and `rdd_extract_code()`. This includes support for specific branches/tags/commits and packages in subdirectories, as well as direct URLs (to branches and/or folders within repositories). Therefore the `remotes` package to `Suggests` to handle remote downloads.
4+
35
# rdocdump 0.1.1 (2025-08-21)
46

57
* Added `version` argument to `rdd_to_txt()` and `rdd_extract_code()` functions to specify the version of the package to download from CRAN for processing.

R/extract_code.R

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55
#'
66
#' @param pkg A `character` string specifying the package. This can be:
77
#' \itemize{
8-
#' \item an installed package name,
8+
#' \item an installed package name (e.g., `"ggplot2"`),
99
#' \item a full path to a package source directory,
10-
#' \item a full path to a package archive file (tar.gz), or
11-
#' \item a package name not installed (which will then be downloaded from CRAN).
10+
#' \item a full path to a package archive file (tar.gz),
11+
#' \item a package name not installed (which will then be downloaded from CRAN),
12+
#' \item a GitHub repository reference (e.g., `"tidyverse/ggplot2"` or
13+
#' `"github::tidyverse/ggplot2"`),
14+
#' \item a GitLab repository reference (e.g., `"gitlab::user/repo"`),
15+
#' \item a repository reference with specific branch/tag/commit
16+
#' (e.g., `"user/repo@v1.0.0"` or `"user/repo@main"`),
17+
#' \item a repository reference with subdirectory
18+
#' (e.g., `"user/repo/subdir"` for packages not at repo root),
19+
#' \item a full GitHub or GitLab web URL
20+
#' (e.g., `"https://github.com/apache/sedona-db/tree/main/r/sedonadb"` or
21+
#' `"https://github.com/ipeaGIT/r5r/tree/master/r-package"`).
1222
#' }
1323
#' @param file Optional. Save path for the output text file. If set, the function will return the path to the file instead of the combined text. Defaults to `NULL`.
1424
#' @param include_tests `logical`. If `TRUE`, for non-installed packages, the function will also include R source code from the `tests` directory. Defaults to `FALSE`.

R/to_txt.R

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55
#'
66
#' @param pkg A `character` string specifying the package. This can be:
77
#' \itemize{
8-
#' \item an installed package name,
8+
#' \item an installed package name (e.g., `"ggplot2"`),
99
#' \item a full path to a package source directory,
10-
#' \item a full path to a package archive file (tar.gz), or
11-
#' \item a package name not installed (which will then be downloaded from CRAN).
10+
#' \item a full path to a package archive file (tar.gz),
11+
#' \item a package name not installed (which will then be downloaded from CRAN),
12+
#' \item a GitHub repository reference (e.g., `"tidyverse/ggplot2"` or
13+
#' `"github::tidyverse/ggplot2"`),
14+
#' \item a GitLab repository reference (e.g., `"gitlab::user/repo"`),
15+
#' \item a repository reference with specific branch/tag/commit
16+
#' (e.g., `"user/repo@v1.0.0"` or `"user/repo@main"`),
17+
#' \item a repository reference with subdirectory
18+
#' (e.g., `"user/repo/subdir"` for packages not at repo root),
19+
#' \item a full GitHub or GitLab web URL
20+
#' (e.g., `"https://github.com/apache/sedona-db/tree/main/r/sedonadb"` or
21+
#' `"https://github.com/ipeaGIT/r5r/tree/master/r-package"`).
1222
#' }
1323
#' @param file Optional. Save path for the output text file. If set, the function will return the path to the file instead of the combined text. Defaults to `NULL`.
1424
#' @param force_fetch `logical`. If `TRUE`, the package source will be fetched from CRAN as a tar.gz archive even if the package is already installed locally. Default is `FALSE`, but when `version` is specified, it will be set to `TRUE`.
@@ -45,6 +55,17 @@
4555
#' docs <- rdd_to_txt("splines")
4656
#' cat(substr(docs, 1, 500))
4757
#'
58+
#' \dontrun{
59+
#' # Extract from GitHub repository
60+
#' docs <- rdd_to_txt("r-lib/rlang")
61+
#'
62+
#' # Extract specific version from GitHub
63+
#' docs <- rdd_to_txt("r-lib/rlang@v1.1.0")
64+
#'
65+
#' # Extract from GitLab
66+
#' docs <- rdd_to_txt("gitlab::user/repo")
67+
#' }
68+
#'
4869
#' \donttest{
4970
#' # set cache directory for `rdocdump`
5071
#' rdd_set_cache_path(paste0(tempdir(), "/rdocdump_cache"))

R/util_resolve_pkg_path.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ resolve_pkg_path <- function(
2121
stop("Argument 'pkg' must be a single character string.")
2222
}
2323

24+
# Check if it's a remote reference (GitHub, GitLab, etc.)
25+
if (is_remote_reference(pkg)) {
26+
message("Fetching package source from remote repository...")
27+
return(resolve_remote_pkg(pkg, cache_path))
28+
}
29+
2430
# Helper function to parse tarball filename into package name and version.
2531
parse_tarball_name <- function(tar_path) {
2632
base_name <- basename(tar_path) # e.g., "rJavaEnv_0.2.2.tar.gz"

0 commit comments

Comments
 (0)