| Title: | Summarize Package Repositories And Their Relationships |
|---|---|
| Description: | Helps understand github-based R packages and their relationships. Includes tools to summarize package status, issues, pull requests, as well as download complete backups of Github Issues and Pull Requests. |
| Authors: | Collin Edwards [aut, cre] (ORCID: <https://orcid.org/0000-0002-4937-5159>) |
| Maintainer: | Collin Edwards <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9000 |
| Built: | 2026-10-03 02:29:16 UTC |
| Source: | https://github.com/cbedwards-dfw/codeInspectr |
To provide a backup on github failure, this function streamlines downloading all github Issues and Pull Requests of all repositories of a focal user or organization into local jsons.
backup_github_info(name, save_location, entity_type = c("user", "org"))backup_github_info(name, save_location, entity_type = c("user", "org"))
name |
Name of github user or organization (e.g., "cbedwards-dfw", "FRAMverse"). Character atomic. |
save_location |
Filepath for directory to save issue and pulls to. |
entity_type |
Either "user" or "org" to identify if |
Invisibly returns a tibble with:
$repo_name = name of repository
$full_name = full github name ({user or org}/{repo name})
$issues_path = filepath to the json of issues
$pulls_path = filepath to the json of pulls
$issues_status, $pulls_status = Did the backup work? "success" or "error"
$issues_error_msg, $pulls_error_msg = error messages on attempting to back up (NA if there was no error.)
## Not run: ## backing up all issues and PRs for repos hosted by `cbedwards-dfw` out <- backup_github_info("cbedwards-dfw", "user", save_location = "C:/Repos/cbe_github_backups") ## End(Not run)## Not run: ## backing up all issues and PRs for repos hosted by `cbedwards-dfw` out <- backup_github_info("cbedwards-dfw", "user", save_location = "C:/Repos/cbe_github_backups") ## End(Not run)
For an R package stored on Github, compile a pdf reference manual and optionally build any vignettes. Requires LaTeX to run. Under the hood, downloads temporary copy of github repo, compiles document(s), then deletes repository.
build_package_manual( repo_address, output_path, build_vignettes = FALSE, verbose = TRUE )build_package_manual( repo_address, output_path, build_vignettes = FALSE, verbose = TRUE )
repo_address |
Github repository "full name" of form |
output_path |
Filepath for a directory into which to save manuals. Character atomic. |
build_vignettes |
Attempt to build vignettes for any package that has them? Logical,
defaults to |
verbose |
Print progress statements? Logical, defaults to |
Nothing
## Not run: build_package_manual(repo = "FRAMverse/framrsquared", output_path = "C:/Repos/test_manuals", build_vignettes = TRUE) ## End(Not run)## Not run: build_package_manual(repo = "FRAMverse/framrsquared", output_path = "C:/Repos/test_manuals", build_vignettes = TRUE) ## End(Not run)
Build edges of all function dependencies in package
build_package_network(package_name, include = "package only")build_package_network(package_name, include = "package only")
package_name |
package name as character string |
include |
Should only package functions be returned ("package only"), or all functions except for base R operators ("no operators"), or all functions ("all")? |
dataframe of dependency edges, with $from and $to
build_package_network("codeInspectr")build_package_network("codeInspectr")
Build dataframe of edges of recursive dependencies
build_recursive_edges( package_name, fun, pattern_ignore = NULL, pattern_dont_recurse = NULL )build_recursive_edges( package_name, fun, pattern_ignore = NULL, pattern_dont_recurse = NULL )
package_name |
Name of pattern. Character vector, length 1 |
fun |
Name of function. Character vector, length 1 |
pattern_ignore |
NULL or character vector of regex patterns. If present, recursive_deps will ignore any functions that match the pattern(s) character vector. Can take multiple patterns. |
pattern_dont_recurse |
NULL or character vector of regex patterns. If present, recursive_deps will list functions that match the pattern(s), but will not recurse into those functions.. Can take multiple patterns. |
dataframe, with $from and $to representing the "from" and "to" nodes of every edge
build_recursive_edges("purrr", "map")build_recursive_edges("purrr", "map")
Creates PDF manuals for all R packages of a given user or organization. Manuals are created with
devtools::build_manual. This requires a version of LaTeX installed. If you don't have a version
installed, you can install it with tinytex::install_tinytex(). Optionally can also build
vignettes for each package. Successfully building vignettes may require additional packages be
installed (whatever packages the vignettes depend on).
compile_package_manuals( output_path, name, entity_type = c("user", "org"), build_vignettes = FALSE, repo_type = c("all", "public", "private", "forks"), verbose = TRUE )compile_package_manuals( output_path, name, entity_type = c("user", "org"), build_vignettes = FALSE, repo_type = c("all", "public", "private", "forks"), verbose = TRUE )
output_path |
Filepath for a directory into which to save manuals. Character atomic. |
name |
Name of user or organization (e.g., "FRAMverse" or "cbedwards-dfw"). Character atomic. |
entity_type |
Is this a Github User ("user") or organization ("org")? Character atomic, defaults to "user". |
build_vignettes |
Attempt to build vignettes for any package that has them? Logical,
defaults to |
repo_type |
List "all" repos, "public" repos, "private" repos, or only "fork" repos? Character atomic, defaults to "all". Private repos will only be provided if you have access to the private repos of that user or org. |
verbose |
Print progress statements? Logical, defaults to |
Nothing
## Not run: # build manuals and vignettes for all R packages in the FRAMverse organization. compile_package_manuals(output_path = "C:/Repos/manuals", name = "FRAMverse", entity_type = "org", build_vignettes = TRUE) ## End(Not run)## Not run: # build manuals and vignettes for all R packages in the FRAMverse organization. compile_package_manuals(output_path = "C:/Repos/manuals", name = "FRAMverse", entity_type = "org", build_vignettes = TRUE) ## End(Not run)
If the git repository for an R package contains vignettes, builds them and saves them in output_path,
with prefix matching the package name.
compile_vignettes(repo_address, repo_dir, output_path, verbose)compile_vignettes(repo_address, repo_dir, output_path, verbose)
repo_address |
Github repository "full name" of form |
repo_dir |
Temporary filepath for cloned github repository |
output_path |
Filepath for a directory into which to save manuals. Character atomic. |
verbose |
Print progress statements? Logical, defaults to |
Character vector of vignette filepaths (if successful and vignettes exist) or empty character string
Returns a character vector of all functions in package package_name that depend on function fun.
find_function_dependencies(package_name, fun, include = "package only")find_function_dependencies(package_name, fun, include = "package only")
package_name |
package name as character string |
fun |
function name as character string |
include |
Should only package functions be returned ("package only"), or all functions except for base R operators ("no operators"), or all functions ("all")? |
character vector of function names
find_function_dependencies("codeInspectr", "find_recursive_dependencies") body(codeInspectr::find_recursive_dependencies)find_function_dependencies("codeInspectr", "find_recursive_dependencies") body(codeInspectr::find_recursive_dependencies)
Recursively walk downwards through function calls. Two options to reduce traversal of functions that may not be of interest (e.g., "validate_.*" functions): pattern_ignore will completely ignore functions matching a
find_recursive_dependencies( package_name, fun, pattern_ignore = NULL, pattern_dont_recurse = NULL )find_recursive_dependencies( package_name, fun, pattern_ignore = NULL, pattern_dont_recurse = NULL )
package_name |
Name of pattern. Character vector, length 1 |
fun |
Name of function. Character vector, length 1 |
pattern_ignore |
NULL or character vector of regex patterns. If present, recursive_deps will ignore any functions that match the pattern(s) character vector. Can take multiple patterns. |
pattern_dont_recurse |
NULL or character vector of regex patterns. If present, recursive_deps will list functions that match the pattern(s), but will not recurse into those functions.. Can take multiple patterns. |
character vector
find_recursive_dependencies("purrr", "map")find_recursive_dependencies("purrr", "map")
To search for functions that are dependent on a non-package function (e.g.,
tracking down potential issues if a function from another package changes),
set include to "all".
find_reverse_dependencies(package_name, fun, include = "package only")find_reverse_dependencies(package_name, fun, include = "package only")
package_name |
package name as character string |
fun |
function name as character string |
include |
Should only package functions be returned ("package only"), or all functions except for base R operators ("no operators"), or all functions ("all")? |
character vector
find_reverse_dependencies("codeInspectr", "package_functions")find_reverse_dependencies("codeInspectr", "package_functions")
Summarizes recent activity on a remote github repository, listing active branches and their most recent updates. #' Will only process the first 100 branches of a repository. Repository does not need to be an R package, or even contain R code. Will not list activity for "gh-pages", which is the branch used for pkgdown.
get_branch_activity(repo_address)get_branch_activity(repo_address)
repo_address |
Github repository address, of the form "user/repository",
as in |
Dataframe with $branch (branch name) and $most_recent_update (date of most recent commit)
get_branch_activity("FRAMverse/framrsquared") get_branch_activity("tidyverse/dplyr")get_branch_activity("FRAMverse/framrsquared") get_branch_activity("tidyverse/dplyr")
Searches all repositories owned by a Github user or organization for issues closed, pull requests opened, and pull requests merged within a date window. Github search returns at most 1,000 results per query; when a window holds more than that, it is split into smaller windows automatically.
get_github_activity(owner, since, until = Sys.Date(), author = NULL)get_github_activity(owner, since, until = Sys.Date(), author = NULL)
owner |
Github user or organization, e.g. "FRAMverse". Character atomic. |
since |
Start of the reporting window (inclusive). Date, or character in "YYYY-MM-DD" form. |
until |
End of the reporting window (inclusive). Date, or character in "YYYY-MM-DD" form. Optional, Defaults to today. |
author |
Optional Github username. If provided, pull request counts are
restricted to pull requests authored by this person. Use |
Tibble with one row per issue or pull request, with columns
$owner: the user or organization searched
$repo: repository address, e.g. "FRAMverse/framrsquared"
$activity: "issues_closed", "prs_opened", or "prs_merged". A pull request
opened and merged in the window appears once under each.
$number, $title, $author: issue or pull request number, title, and
author's Github username
$state_reason: for issues, "completed", "not_planned", or NA
$created, $closed, $merged: dates
$link: web address
## Not run: get_github_activity("FRAMverse", since = "2026-01-01") ## End(Not run)## Not run: get_github_activity("FRAMverse", since = "2026-01-01") ## End(Not run)
Return summary of open Github Issues
get_issues(repo_address, max_char = 97)get_issues(repo_address, max_char = 97)
repo_address |
Github repository address, of the form "user/repository",
as in |
max_char |
Maximum number of characters to return in the "body" column. |
dataframe with $title, $body, and $date of open issues.
get_issues("FRAMverse/framrsquared") get_issues("tidyverse/dplyr")get_issues("FRAMverse/framrsquared") get_issues("tidyverse/dplyr")
Unlike list_repos(), this includes your own private repositories, since it
uses the Github search API (which returns any repository your token can see).
get_new_repos(owner, since, until = Sys.Date(), include_forks = TRUE)get_new_repos(owner, since, until = Sys.Date(), include_forks = TRUE)
owner |
Github user or organization, e.g. "FRAMverse". Character atomic. |
since |
Start of the reporting window (inclusive). Date, or character in "YYYY-MM-DD" form. |
until |
End of the reporting window (inclusive). Date, or character in "YYYY-MM-DD" form. Optional, Defaults to today. |
include_forks |
Should forks count as new repos? Logical, defaults to TRUE. |
Tibble with $owner, $repo (e.g. "FRAMverse/framrsquared"),
$description, $private, $fork, $created (date), and $link.
## Not run: get_new_repos("FRAMverse", since = "2026-01-01") ## End(Not run)## Not run: get_new_repos("FRAMverse", since = "2026-01-01") ## End(Not run)
Including title, initial text of body, and date
get_pull_requests(repo_address, max_char = 97)get_pull_requests(repo_address, max_char = 97)
repo_address |
Github repository address, of the form "user/repository",
as in |
max_char |
Maximum number of characters to return in the "body" column. |
dataframe with $title, $body, and $date of open pull requests.
get_pull_requests("FRAMverse/framrsquared") get_pull_requests("tidyverse/dplyr")get_pull_requests("FRAMverse/framrsquared") get_pull_requests("tidyverse/dplyr")
Returns github issues as a list. Github issues themselves are structured as jsons.
get_raw_issues(repo_address = NULL, entity_name = NULL, repo_name = NULL)get_raw_issues(repo_address = NULL, entity_name = NULL, repo_name = NULL)
repo_address |
Github identifier in the form of {name}/{repository}, as in "FRAMverse/codeInspectr".
Can also be in the form of full URL (e.g. "https://github.com/FRAMverse/framrsquared/").
Character string, defaults to NULL. If not provided, users must instead provide the same information in |
entity_name |
Only needed if |
repo_name |
Only needed if |
A list of class gh_response containing all issues from a repository.
temp <- get_raw_issues("cbedwards-dfw/codeInspectr")temp <- get_raw_issues("cbedwards-dfw/codeInspectr")
Returns github issues as a list. Github issues themselves are structured as jsons.
get_raw_pulls(repo_address = NULL, entity_name = NULL, repo_name = NULL)get_raw_pulls(repo_address = NULL, entity_name = NULL, repo_name = NULL)
repo_address |
Github identifier in the form of {name}/{repository}, as in "FRAMverse/codeInspectr".
Can also be in the form of full URL (e.g. "https://github.com/FRAMverse/framrsquared/").
Character string, defaults to NULL. If not provided, users must instead provide the same information in |
entity_name |
Only needed if |
repo_name |
Only needed if |
A list of class gh_response containing all pull requests from a repository.
# temp <- get_raw_pulls("cbedwards-dfw/codeInspectr")# temp <- get_raw_pulls("cbedwards-dfw/codeInspectr")
Uses the existence of a DESCRIPTION file and the first line being "Package:..." to decide if
the provided repository is an R package. Accesses first few lines of DESCRIPTION in raw.githubusercontent.com/
for speed.
is_r_package(repo_address, default_branch = "main")is_r_package(repo_address, default_branch = "main")
repo_address |
Repository name including user or organization prefix, e.g., "FRAMverse/framrsquared". Character atomic |
default_branch |
Name of the default/primary repository. Character atomic, defaults to "main". Older repositories often use "master" as the default repo name. |
Logical: TRUE if the repo is an R package, FALSE if it is not.
# framrsquared is an R package is_r_package("FRAMverse/framrsquared") # the snippets repository is not. is_r_package("FRAMverse/snippets")# framrsquared is an R package is_r_package("FRAMverse/framrsquared") # the snippets repository is not. is_r_package("FRAMverse/snippets")
Creates a dataframe of repositories and associated info for the user or organization specified
list_repos( name, entity_type = c("user", "org"), repo_type = c("all", "public", "private", "forks"), r_package_status = FALSE )list_repos( name, entity_type = c("user", "org"), repo_type = c("all", "public", "private", "forks"), r_package_status = FALSE )
name |
Name of user or organization (e.g., "FRAMverse" or "cbedwards-dfw"). Character atomic. |
entity_type |
Is this a Github User ("user") or organization ("org")? Character atomic, defaults to "user". |
repo_type |
List "all" repos, "public" repos, "private" repos, or only "fork" repos? Character atomic, defaults to "all". Private repos will only be provided if you have access to the private repos of that user or org. |
r_package_status |
Check if each repository is an R package. Increases runtime considerably (e.g., ~1 sec per repo). Logical, defaults to FALSE |
Data frame of repositories with columns
$name: repository name, e.g., "codeInspectr"
$full_name: {user/org}/{repository name}, e.g., "FRAMverse/codeInspectr"
$html_url: web address of repository
$description: description listed for the repository.
$stars: number of followers of the repository
$language: programming language(s) of the repository.
$default_branch: the name of the default branch (e.g., "main").
$r_package: is the repository an R package? Logical, only present for optional argument r_package_status = TRUE.
list_repos("FRAMverse", entity_type = "org", repo_type = "public")list_repos("FRAMverse", entity_type = "org", repo_type = "public")
List the functions of a package
package_functions(package_name)package_functions(package_name)
package_name |
Name of package as character string |
character vector of function names
package_functions("codeInspectr")package_functions("codeInspectr")
Helper function to combine repo names if needed
parse_name( repo_address = NULL, entity_name = NULL, repo_name = NULL, call = rlang::caller_env() )parse_name( repo_address = NULL, entity_name = NULL, repo_name = NULL, call = rlang::caller_env() )
repo_address |
Github identifier in the form of {name}/{repository}, as in "FRAMverse/codeInspectr".
Can also be in the form of full URL (e.g. "https://github.com/FRAMverse/framrsquared/").
Character string, defaults to NULL. If not provided, users must instead provide the same information in |
entity_name |
Only needed if |
repo_name |
Only needed if |
call |
Ensure error messages mention the calling function. |
A full github name, as in "FRAMverse/codeInspectr"
Plot dependency map of a function
plot_function_dependencies( package_name, fun, pattern_ignore = NULL, pattern_dont_recurse = NULL )plot_function_dependencies( package_name, fun, pattern_ignore = NULL, pattern_dont_recurse = NULL )
package_name |
Name of pattern. Character vector, length 1 |
fun |
Name of function. Character vector, length 1 |
pattern_ignore |
NULL or character vector of regex patterns. If present, recursive_deps will ignore any functions that match the pattern(s) character vector. Can take multiple patterns. |
pattern_dont_recurse |
NULL or character vector of regex patterns. If present, recursive_deps will list functions that match the pattern(s), but will not recurse into those functions.. Can take multiple patterns. |
visNetwork plot
plot_function_dependencies("purrr", "map") plot_function_dependencies("purrr", "map_df")plot_function_dependencies("purrr", "map") plot_function_dependencies("purrr", "map_df")
Intended for use in purr workflow in backup_github_info().
process_repo(repo_name, repo_address, save_location)process_repo(repo_name, repo_address, save_location)
repo_name |
Name of repository (e.g. "codeInspectr") |
repo_address |
Full github name (e.g., "FRAMverse/codeInspectr") |
save_location |
Filepath for directory to save issue and pulls to. |
Tibble with filepaths and success/failure info.
Useful for deleting temporary Github clones.
safe_dir_delete(path, attempts = 5, wait_seconds = 0.3)safe_dir_delete(path, attempts = 5, wait_seconds = 0.3)
path |
Directory to delete. |
attempts |
Number of attempts before giving up. |
wait_seconds |
Delay between attempts (grows each retry). |
TRUE if deletion succeeded, FALSE otherwise (invisibly attempted).
Counts issues closed, pull requests opened, pull requests merged, and new
repositories created since a given date, across every repository owned by
the users and/or organizations in owners. Uses the Github search API, so
private repositories are included whenever your Github token can see them.
summarize_github_activity( owners, since, until = Sys.Date(), author = NULL, include_forks = TRUE, verbose = TRUE )summarize_github_activity( owners, since, until = Sys.Date(), author = NULL, include_forks = TRUE, verbose = TRUE )
owners |
Github users and/or organizations whose repositories should be
summarized, e.g. |
since |
Start of the reporting window (inclusive). Date, or character in "YYYY-MM-DD" form. |
until |
End of the reporting window (inclusive). Date, or character in "YYYY-MM-DD" form. Optional, Defaults to today. |
author |
Optional Github username. If provided, pull request counts are
restricted to pull requests authored by this person. Use |
include_forks |
Count newly created forks as new repositories? Logical,
defaults to |
verbose |
Print a summary to the console? Logical, defaults to |
A list with
$totals: one row per owner (plus a "TOTAL" row) with columns
$issues_closed, $prs_opened, $prs_merged, and $repos_created.
$by_repo: the same issue and pull request counts for each repository
with any activity in the window.
$items: one row per issue or pull request counted, with links (see
get_github_activity()). Issues closed as "not planned" can be dropped
with dplyr::filter(items, state_reason != "not_planned").
$new_repos: repositories created in the window (see get_new_repos()).
$since, $until: the reporting window.
get_github_activity(), get_new_repos(), list_repos()
## Not run: activity <- summarize_github_activity(c("cbedwards-dfw", "FRAMverse"), since = "2026-01-01") activity$totals ## only count pull requests you wrote yourself summarize_github_activity("FRAMverse", since = "2026-01-01", author = "@me") ## End(Not run)## Not run: activity <- summarize_github_activity(c("cbedwards-dfw", "FRAMverse"), since = "2026-01-01") activity$totals ## only count pull requests you wrote yourself summarize_github_activity("FRAMverse", since = "2026-01-01", author = "@me") ## End(Not run)
Primarily designed to pull information from R packages, but also works for other repositories.
summarize_repository(repo_address, max_char = 70)summarize_repository(repo_address, max_char = 70)
repo_address |
Github repository address for an R package, of the form "user/repository",
as in |
max_char |
Maximum number of characters to return in the "body" column. |
List summarizing github repository information.
get_issues(), get_pull_requests(), get_branch_activity()
summarize_repository("FRAMverse/framrsquared") summarize_repository("cbedwards-dfw/xldiff")summarize_repository("FRAMverse/framrsquared") summarize_repository("cbedwards-dfw/xldiff")