Skip to content

Commit

Permalink
docs: replace references with source and some minor lints
Browse files Browse the repository at this point in the history
  • Loading branch information
m-muecke committed Jun 27, 2024
1 parent b5ad337 commit 69d2dc6
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: worldbank
Title: Modern World Bank API Wrapper
Title: Client for the World Bank API
Version: 0.0.1
Authors@R:
person("Maximilian", "Muecke", , "muecke.maximilian@gmail.com", role = c("aut", "cre"),
Expand Down
26 changes: 13 additions & 13 deletions R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' \item{code}{The language code.}
#' \item{name}{The language name.}
#' \item{native_form}{The native form of the language name.}
#' @references <http://api.worldbank.org/v2/languages>
#' @source <http://api.worldbank.org/v2/languages>
#' @export
#' @examples
#' wb_language()
Expand All @@ -33,12 +33,12 @@ wb_language <- function() {
#' \item{id}{The lending type ID.}
#' \item{iso2code}{The ISO 2 code of the lending type.}
#' \item{value}{The lending type value.}
#' @references <http://api.worldbank.org/v2/lendingTypes>
#' @source <http://api.worldbank.org/v2/lendingTypes>
#' @export
#' @examples
#' wb_lending_type()
wb_lending_type <- function(type = NULL, lang = "en") {
stopifnot(is_character_or_null(type), all(nchar(type) == 3L))
stopifnot(is_character_or_null(type), nchar(type) == 3L)
type <- format_param(type)

resource <- sprintf("lendingType/%s", type)
Expand All @@ -63,12 +63,12 @@ wb_lending_type <- function(type = NULL, lang = "en") {
#' \item{id}{The income level ID.}
#' \item{iso2code}{The ISO 2 code of the income level.}
#' \item{value}{The income level value.}
#' @references <http://api.worldbank.org/v2/incomeLevels>
#' @source <http://api.worldbank.org/v2/incomeLevels>
#' @export
#' @examples
#' wb_income_level()
wb_income_level <- function(income = NULL, lang = "en") {
stopifnot(is_character_or_null(income), all(nchar(income) == 3L))
stopifnot(is_character_or_null(income), nchar(income) == 3L)
income <- format_param(income)

resource <- sprintf("incomeLevel/%s", income)
Expand Down Expand Up @@ -99,7 +99,7 @@ wb_income_level <- function(income = NULL, lang = "en") {
#' \item{data_availability}{Whether the source has data available.}
#' \item{metadata_availability}{Whether the source has metadata available.}
#' \item{concepts}{The concepts associated with the source.}
#' @references <http://api.worldbank.org/v2/sources>
#' @source <http://api.worldbank.org/v2/sources>
#' @export
#' @examples
#' wb_source()
Expand Down Expand Up @@ -136,7 +136,7 @@ wb_source <- function(source = NULL, lang = "en") {
#' \item{id}{The topic ID.}
#' \item{value}{The topic value.}
#' \item{source_note}{The source note.}
#' @references <http://api.worldbank.org/v2/topics>
#' @source <http://api.worldbank.org/v2/topics>
#' @export
#' @examples
#' wb_topic()
Expand Down Expand Up @@ -167,7 +167,7 @@ wb_topic <- function(topic = NULL, lang = "en") {
#' \item{code}{The region code.}
#' \item{iso2code}{The ISO 2 code of the region.}
#' \item{name}{The region name.}
#' @references <http://api.worldbank.org/v2/region>
#' @source <http://api.worldbank.org/v2/region>
#' @export
#' @examples
#' wb_region()
Expand Down Expand Up @@ -216,13 +216,13 @@ wb_region <- function(region = NULL, lang = "en") {
#' \item{capital_city}{The capital city.}
#' \item{longitude}{The longitude.}
#' \item{latitude}{The latitude.}
#' @references <http://api.worldbank.org/v2/country>
#' @source <http://api.worldbank.org/v2/country>
#' @export
#' @examples
#' wb_country()
wb_country <- function(country = NULL, lang = "en") {
stopifnot(
is_character_or_null(country), all(nchar(country) %in% 2:3),
is_character_or_null(country), nchar(country) %in% 2:3,
is_string(lang), nchar(lang) == 2L
)
country <- tolower(format_param(country))
Expand Down Expand Up @@ -276,7 +276,7 @@ wb_country <- function(country = NULL, lang = "en") {
#' \item{source_organization}{The source organization.}
#' \item{topic_id}{The topic ID.}
#' \item{topic_value}{The topic value.}
#' @references <http://api.worldbank.org/v2/indicator>
#' @source <http://api.worldbank.org/v2/indicator>
#' @export
#' @examples
#' wb_indicator("NY.GDP.MKTP.CD")
Expand Down Expand Up @@ -336,7 +336,7 @@ wb_indicator <- function(indicator = NULL, lang = "en") {
#' \item{unit}{The indicator unit.}
#' \item{obs_status}{The observation status.}
#' \item{decimal}{The decimal.}
#' @references <http://api.worldbank.org/v2/country/{country}/indicator/{indicator}>
#' @source <http://api.worldbank.org/v2/country/{country}/indicator/{indicator}>
#' @export
#' @examples
#' wb_country_indicator("NY.GDP.MKTP.CD", "US")
Expand All @@ -347,7 +347,7 @@ wb_country_indicator <- function(indicator = "NY.GDP.MKTP.CD",
end_year = NULL) {
stopifnot(
is_string(indicator),
is_character_or_null(country), all(nchar(country) %in% 2:3)
is_character_or_null(country), nchar(country) %in% 2:3
)
has_start_year <- !is.null(start_year)
has_end_year <- !is.null(end_year)
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ as_tibble <- function(x) {
}

na_if_empty <- function(x) {
replace(x, x == "", NA_character_)
replace(x, !nzchar(x), NA_character_)
}

to_logical <- function(x) {
ifelse(x == "Y", TRUE, FALSE)
x == "Y"
}

map <- function(.x, .f, ...) {
Expand Down
6 changes: 3 additions & 3 deletions man/wb_country.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/wb_country_indicator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/wb_income_level.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/wb_indicator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/wb_language.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/wb_lending_type.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/wb_region.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/wb_source.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/wb_topic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/worldbank-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions tests/testthat/test-wb.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that("wb_lending_type input validation works", {
# type should be a three letter code or NULL
expect_error(wb_lending_type(character(0)))
expect_error(wb_lending_type(character()))
expect_error(wb_lending_type(""))
expect_error(wb_lending_type("ab"))
expect_error(wb_lending_type("abcd"))
Expand All @@ -18,7 +18,7 @@ test_that("wb_lending_type input validation works", {

test_that("wb_income_level input validation works", {
# income should be a three letter code or NULL
expect_error(wb_income_level(character(0)))
expect_error(wb_income_level(character()))
expect_error(wb_income_level(""))
expect_error(wb_income_level("ab"))
expect_error(wb_income_level("abcd"))
Expand All @@ -36,7 +36,7 @@ test_that("wb_income_level input validation works", {

test_that("wb_source input validation works", {
# source should be a character vector or NULL
expect_error(wb_source(character(0)))
expect_error(wb_source(character()))
expect_error(wb_source(NA))
expect_error(wb_source(1L))
expect_error(wb_source(TRUE))
Expand All @@ -50,7 +50,7 @@ test_that("wb_source input validation works", {

test_that("wb_topic input validation works", {
# topic should be a character vector or NULL
expect_error(wb_topic(character(0)))
expect_error(wb_topic(character()))
expect_error(wb_topic(NA))
expect_error(wb_topic(1L))
expect_error(wb_topic(TRUE))
Expand All @@ -64,7 +64,7 @@ test_that("wb_topic input validation works", {

test_that("wb_region input validation works", {
# region should be a character vector or NULL
expect_error(wb_region(character(0)))
expect_error(wb_region(character()))
expect_error(wb_region(NA))
expect_error(wb_region(1L))
expect_error(wb_region(TRUE))
Expand All @@ -81,7 +81,7 @@ test_that("wb_country input validation works", {
expect_error(wb_country("a"))
expect_error(wb_country("abcd"))
expect_error(wb_country(c("ab", "abcd")))
expect_error(wb_country(character(0)))
expect_error(wb_country(character()))
expect_error(wb_country(NA))
expect_error(wb_country(1L))
expect_error(wb_country(TRUE))
Expand All @@ -98,7 +98,7 @@ test_that("wb_indicator input validation works", {
expect_error(wb_indicator("a"))
expect_error(wb_indicator("abcd"))
expect_error(wb_indicator(c("ab", "abcd")))
expect_error(wb_indicator(character(0)))
expect_error(wb_indicator(character()))
expect_error(wb_indicator(NA))
expect_error(wb_indicator(1L))
expect_error(wb_indicator(TRUE))
Expand All @@ -120,7 +120,7 @@ test_that("wb_country_indicator input validation works", {
expect_error(wb_country_indicator(country = "a"))
expect_error(wb_country_indicator(country = "abcd"))
expect_error(wb_country_indicator(country = c("ab", "abcd")))
expect_error(wb_country_indicator(country = character(0)))
expect_error(wb_country_indicator(country = character()))
expect_error(wb_country_indicator(country = NA))
expect_error(wb_country_indicator(country = 1L))
expect_error(wb_country_indicator(country = TRUE))
Expand Down

0 comments on commit 69d2dc6

Please sign in to comment.