Skip to contents

Get URL, or just owner/reponame, for the package code, datasets, or documentation website as specified in the DESCRIPTION file or by redirects from aliases

Usage

url_package(
  type = c("code", "data", "docs", "api")[1],
  get_full_url = FALSE,
  desc_or_alias = c("desc", "alias")[1],
  docs_version = NULL,
  domain = NULL
)

Arguments

type

Which type of URL is needed? Can be "data", "code", "docs", or "api".

  • "code" is for the github.com repository of R package code

  • "data" is for the github.com repository of datasets

  • "docs" is for the documentation website

  • "api" is for the EJAM REST API base URL (DESCRIPTION field ejam_api_url, falling back to the built-in production API base if that field is missing). Always a full URL. This is the single source of the API endpoint: all functions that call or build EJAM API URLs read it from here, so the endpoint can be changed in one place (edit ejam_api_url in DESCRIPTION). A friendlier branded alias, https://api.ejanalysis.com (also https://ejamapi.ejanalysis.com), proxies the same API via Cloudflare and may be used as ejam_api_url. (The ejam_api_repo field names the API source-code repo and is informational only – it is not the API endpoint.)

get_full_url

logical, whether to return full URL or just the owner/reponame info. Ignored if type = "docs" or "api", where a full URL is always returned.

desc_or_alias

must be "desc" or "alias" to use info from DESCRIPTION file or the URL based on a redirect from the aliases at

  • https://ejanalysis.org/code

  • https://ejanalysis.org/data

  • https://ejanalysis.org/docs

docs_version

optional, only used when type = "docs". A docs subpath such as "dev", "v3.2024.0", "v3.2023.0", or "v3.2022.0" to append to the canonical root docs URL (e.g. returns ".../EJAM/v3.2024.0"). If the environment variable EJAM_DOCS_BASE_URL is set (as the pkgdown CI workflow does while building a given version), that value overrides everything so rendered Rd/Rmd links stay within the version being built. desc_or_alias = "alias" shortcuts always point to the root docs site only.

domain

obsolete parameter - do not use

Value

a single URL or owner/repo as a character string

Details

See https://ejanalysis.com/ejam-code for a list of URLs

See also

url_ejamapi() ejamapi() url_ejamapp() – the functions that build/call EJAM API and app URLs; url_package("api") is their single source for the API base URL.

Examples

 owner_repo <- url_package()
 reponame <- gsub(".*/", "", owner_repo)
 reponame

 url_package("docs")

 url_package("code")
 url_package("code", get_full_url = TRUE)

 url_package("data")
 url_package("data", get_full_url = TRUE)

 url_package("api")

 url_package("docs", desc_or_alias="alias")
 url_package("code", desc_or_alias="alias")
 url_package("data", desc_or_alias="alias")