Skip to content

Commit 9e2817a

Browse files
committed
docs: It adds conditions to run the examples to replace \dontrun
It solves #208.
1 parent f33ffb2 commit 9e2817a

31 files changed

+158
-139
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ Suggests:
5757
readr,
5858
rmarkdown,
5959
testthat (>= 3.1.5),
60-
withr
60+
withr,
61+
curl
6162
VignetteBuilder:
6263
knitr
6364
Remotes:

R/endpoints.R

Lines changed: 69 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ NULL
4747
#' @description
4848
#' API docs: <https://cmu-delphi.github.io/delphi-epidata/api/cdc.html>
4949
#'
50-
#' @examples
51-
#' \dontrun{
50+
#' @examplesIf curl::has_internet() && Sys.getenv("SECRET_API_AUTH_CDC") != ""
5251
#' pvt_cdc(
5352
#' auth = Sys.getenv("SECRET_API_AUTH_CDC"),
5453
#' locations = "fl,ca",
5554
#' epirange(201501, 201601)
5655
#' )
57-
#' }
5856
#'
5957
#' @inheritParams .epidatr_shared_params
6058
#' @return [`tibble::tibble`]
@@ -111,11 +109,11 @@ pvt_cdc <- function(
111109
#' @details Only one location argument needs to be specified.
112110
#' Combinations of the arguments are not currently supported.
113111
#'
114-
#' @examples
115-
#' \dontrun{
112+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
113+
#'
116114
#' pub_covid_hosp_facility_lookup(state = "fl")
117115
#' pub_covid_hosp_facility_lookup(city = "southlake")
118-
#' }
116+
#'
119117
#' @inheritParams .epidatr_shared_params
120118
#' @param state string. A two-letter character state abbreviation.
121119
#' @param ccn string. A facility CMS certification number.
@@ -196,8 +194,8 @@ pub_covid_hosp_facility_lookup <- function(
196194
#' @details Starting October 1, 2022, some facilities are only required to
197195
#' report annually.
198196
#'
199-
#' @examples
200-
#' \dontrun{
197+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
198+
#'
201199
#' pub_covid_hosp_facility(
202200
#' hospital_pks = "100075",
203201
#' collection_weeks = epirange(20200101, 20200501)
@@ -207,7 +205,7 @@ pub_covid_hosp_facility_lookup <- function(
207205
#' hospital_pks = "050063",
208206
#' collection_weeks = epirange(20240101, 20240301)
209207
#' )
210-
#' }
208+
#'
211209
#' @inheritParams .epidatr_shared_params
212210
#' @param hospital_pks character. Facility identifiers.
213211
#' @param collection_weeks [`timeset`]. Dates (corresponding to epiweeks) to
@@ -584,13 +582,13 @@ pub_covid_hosp_facility <- function(
584582
#' @details Starting October 1, 2022, some facilities are only required to
585583
#' report annually.
586584
#'
587-
#' @examples
588-
#' \dontrun{
585+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
586+
#'
589587
#' pub_covid_hosp_state_timeseries(
590588
#' states = "fl",
591589
#' dates = epirange(20200101, 20200501)
592590
#' )
593-
#' }
591+
#'
594592
#'
595593
#' @inheritParams .epidatr_shared_params
596594
#'
@@ -920,10 +918,9 @@ pub_covid_hosp_state_timeseries <- function(
920918
#'
921919
#' @return [`tibble::tibble`]
922920
#'
923-
#' @examples
924-
#' \dontrun{
921+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
922+
#'
925923
#' pub_covidcast_meta()
926-
#' }
927924
#'
928925
#' @seealso [pub_covidcast()],[covidcast_epidata()]
929926
#' @keywords endpoint
@@ -969,8 +966,8 @@ pub_covidcast_meta <- function(fetch_args = fetch_args_list()) {
969966
#' link above for more. Delphi's [COVIDcast public
970967
#' dashboard](https://delphi.cmu.edu/covidcast/) is powered by this endpoint.
971968
#'
972-
#' @examples
973-
#' \dontrun{
969+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
970+
#'
974971
#' pub_covidcast(
975972
#' source = "jhu-csse",
976973
#' signals = "confirmed_7dav_incidence_prop",
@@ -987,7 +984,6 @@ pub_covidcast_meta <- function(fetch_args = fetch_args_list()) {
987984
#' geo_values = "*",
988985
#' time_values = epirange(20200601, 20200801)
989986
#' )
990-
#' }
991987
#'
992988
#' @inheritParams .epidatr_shared_params
993989
#' @param source string. The data source to query (see:
@@ -1147,13 +1143,13 @@ pub_delphi <- function(
11471143
#' @description
11481144
#' API docs: <https://cmu-delphi.github.io/delphi-epidata/api/dengue_nowcast.html>
11491145
#'
1150-
#' @examples
1151-
#' \dontrun{
1146+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1147+
#'
11521148
#' pub_dengue_nowcast(
11531149
#' locations = "pr",
11541150
#' epiweeks = epirange(201401, 202301)
11551151
#' )
1156-
#' }
1152+
#'
11571153
#' @inheritParams .epidatr_shared_params
11581154
#' @return [`tibble::tibble`]
11591155
#' @keywords endpoint
@@ -1185,15 +1181,15 @@ pub_dengue_nowcast <- function(
11851181
#' @description
11861182
#' API docs: <https://cmu-delphi.github.io/delphi-epidata/api/dengue_sensors.html>
11871183
#'
1188-
#' @examples
1189-
#' \dontrun{
1184+
#' @examplesIf curl::has_internet() && Sys.getenv("SECRET_API_AUTH_SENSORS") != ""
1185+
#'
11901186
#' pvt_dengue_sensors(
11911187
#' auth = Sys.getenv("SECRET_API_AUTH_SENSORS"),
11921188
#' names = "ght",
11931189
#' locations = "ag",
11941190
#' epiweeks = epirange(201501, 202001)
11951191
#' )
1196-
#' }
1192+
#'
11971193
#' @inheritParams .epidatr_shared_params
11981194
#' @return [`tibble::tibble`]
11991195
#' @keywords endpoint
@@ -1241,10 +1237,10 @@ pvt_dengue_sensors <- function(
12411237
#' @details The list of location argument can be found in
12421238
#' <https://github.com/cmu-delphi/delphi-epidata/blob/main/labels/ecdc_regions.txt>.
12431239
#'
1244-
#' @examples
1245-
#' \dontrun{
1240+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1241+
#'
12461242
#' pub_ecdc_ili(regions = "austria", epiweeks = epirange(201901, 202001))
1247-
#' }
1243+
#'
12481244
#' @inheritParams .epidatr_shared_params
12491245
#' @return [`tibble::tibble`]
12501246
#'
@@ -1366,10 +1362,10 @@ pub_flusurv <- function(
13661362
#' @description
13671363
#' API docs: <https://cmu-delphi.github.io/delphi-epidata/api/fluview_clinical.html>
13681364
#'
1369-
#' @examples
1370-
#' \dontrun{
1371-
#' pub_fluview_clinical(regions = "nat", epiweeks = epirange(201601, 201701))
1372-
#' }
1365+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1366+
#'
1367+
#' pub_fluview_clinical(regions = "nat", epiweeks = epirange(201601, 201701))
1368+
#'
13731369
#' @inheritParams .epidatr_shared_params
13741370
#' @param regions character. Locations to fetch. Can be any string IDs in
13751371
#' national, HHS region, census division, most states and territories, and so
@@ -1430,10 +1426,10 @@ pub_fluview_clinical <- function(
14301426
#' @description
14311427
#' API docs: <https://cmu-delphi.github.io/delphi-epidata/api/fluview_meta.html>
14321428
#'
1433-
#' @examples
1434-
#' \dontrun{
1429+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1430+
#'
14351431
#' pub_fluview_meta()
1436-
#' }
1432+
#'
14371433
#'
14381434
#' @inheritParams .epidatr_shared_params
14391435
#'
@@ -1467,10 +1463,10 @@ pub_fluview_meta <- function(fetch_args = fetch_args_list()) {
14671463
#' @details The full list of location inputs can be accessed at
14681464
#' <https://github.com/cmu-delphi/delphi-epidata/blob/main/src/acquisition/fluview/fluview_locations.py>.
14691465
#'
1470-
#' @examples
1471-
#' \dontrun{
1466+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1467+
#'
14721468
#' pub_fluview(regions = "nat", epiweeks = epirange(201201, 202005))
1473-
#' }
1469+
#'
14741470
#' @inheritParams .epidatr_shared_params
14751471
#' @inheritParams pub_fluview_clinical
14761472
#' @return [`tibble::tibble`]
@@ -1549,10 +1545,10 @@ pub_fluview <- function(
15491545
#' and
15501546
#' <https://github.com/cmu-delphi/delphi-epidata/blob/main/labels/cities.txt>.
15511547
#'
1552-
#' @examples
1553-
#' \dontrun{
1548+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1549+
#'
15541550
#' pub_gft(locations = "hhs1", epiweeks = epirange(201201, 202001))
1555-
#' }
1551+
#'
15561552
#' @inheritParams .epidatr_shared_params
15571553
#'
15581554
#' @return [`tibble::tibble`]
@@ -1587,15 +1583,15 @@ pub_gft <- function(
15871583
#'
15881584
#' Estimate of influenza activity based on volume of certain search queries. …
15891585
#'
1590-
#' @examples
1591-
#' \dontrun{
1586+
#' @examplesIf curl::has_internet() && Sys.getenv("SECRET_API_AUTH_GHT") != ""
1587+
#'
15921588
#' pvt_ght(
15931589
#' auth = Sys.getenv("SECRET_API_AUTH_GHT"),
15941590
#' locations = "ma",
15951591
#' epiweeks = epirange(199301, 202304),
15961592
#' query = "how to get over the flu"
15971593
#' )
1598-
#' }
1594+
#'
15991595
#' @inheritParams .epidatr_shared_params
16001596
#' @param query string. The query to be fetched.
16011597
#' @return [`tibble::tibble`]
@@ -1636,10 +1632,10 @@ pvt_ght <- function(
16361632
#' @description
16371633
#' API docs: <https://cmu-delphi.github.io/delphi-epidata/api/kcdc_ili.html>
16381634
#'
1639-
#' @examples
1640-
#' \dontrun{
1635+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1636+
#'
16411637
#' pub_kcdc_ili(regions = "ROK", epiweeks = 200436)
1642-
#' }
1638+
#'
16431639
#' @inheritParams .epidatr_shared_params
16441640
#' @return [`tibble::tibble`]
16451641
#'
@@ -1737,10 +1733,10 @@ pub_meta <- function(fetch_args = fetch_args_list()) {
17371733
#' and
17381734
#' <https://github.com/cmu-delphi/delphi-epidata/blob/main/labels/nidss_locations.txt>.
17391735
#'
1740-
#' @examples
1741-
#' \dontrun{
1736+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1737+
#'
17421738
#' pub_nidss_dengue(locations = "taipei", epiweeks = epirange(201201, 201301))
1743-
#' }
1739+
#'
17441740
#' @inheritParams .epidatr_shared_params
17451741
#'
17461742
#' @return [`tibble::tibble`]
@@ -1776,10 +1772,10 @@ pub_nidss_dengue <- function(
17761772
#' Infectious Disease Statistical System.
17771773
#'
17781774
#'
1779-
#' @examples
1780-
#' \dontrun{
1775+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1776+
#'
17811777
#' pub_nidss_flu(regions = "taipei", epiweeks = epirange(201501, 201601))
1782-
#' }
1778+
#'
17831779
#' @inheritParams .epidatr_shared_params
17841780
#' @return [`tibble::tibble`]
17851781
#'
@@ -1840,14 +1836,14 @@ pub_nidss_flu <- function(
18401836
#' This is the documentation of the API for accessing the NoroSTAT endpoint of
18411837
#' the Delphi’s epidemiological data.
18421838
#'
1843-
#' @examples
1844-
#' \dontrun{
1839+
#' @examplesIf curl::has_internet() && Sys.getenv("SECRET_API_AUTH_NOROSTAT") != ""
1840+
#'
18451841
#' pvt_norostat(
18461842
#' auth = Sys.getenv("SECRET_API_AUTH_NOROSTAT"),
18471843
#' locations = "Minnesota, Ohio, Oregon, Tennessee, and Wisconsin",
18481844
#' epiweeks = 201233
18491845
#' )
1850-
#' }
1846+
#'
18511847
#' @inheritParams .epidatr_shared_params
18521848
#' @param locations character. Locations to fetch. Only a specific list of
18531849
#' full state names are permitted. See the `locations` column in the
@@ -1892,10 +1888,10 @@ pvt_norostat <- function(
18921888
#' @details The full list of location inputs can be accessed at
18931889
#' <https://github.com/cmu-delphi/delphi-epidata/blob/main/src/acquisition/fluview/fluview_locations.py>.
18941890
#'
1895-
#' @examples
1896-
#' \dontrun{
1891+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1892+
#'
18971893
#' pub_nowcast(locations = "ca", epiweeks = epirange(201201, 201301))
1898-
#' }
1894+
#'
18991895
#' @inheritParams .epidatr_shared_params
19001896
#' @return [`tibble::tibble`]
19011897
#' @keywords endpoint
@@ -1927,10 +1923,10 @@ pub_nowcast <- function(
19271923
#' @description
19281924
#' API docs: <https://cmu-delphi.github.io/delphi-epidata/api/paho_dengue.html>
19291925
#'
1930-
#' @examples
1931-
#' \dontrun{
1926+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
1927+
#'
19321928
#' pub_paho_dengue(regions = "ca", epiweeks = epirange(201401, 201501))
1933-
#' }
1929+
#'
19341930
#' @inheritParams .epidatr_shared_params
19351931
#' @return [`tibble::tibble`]
19361932
#'
@@ -1987,14 +1983,14 @@ pub_paho_dengue <- function(
19871983
#'
19881984
#' Data provided by Quidel Corp., which contains flu lab test results.
19891985
#'
1990-
#' @examples
1991-
#' \dontrun{
1986+
#' @examplesIf curl::has_internet() && Sys.getenv("SECRET_API_AUTH_QUIDEL") != ""
1987+
#'
19921988
#' pvt_quidel(
19931989
#' auth = Sys.getenv("SECRET_API_AUTH_QUIDEL"),
19941990
#' epiweeks = epirange(201201, 202001),
19951991
#' locations = "hhs1"
19961992
#' )
1997-
#' }
1993+
#'
19981994
#' @inheritParams .epidatr_shared_params
19991995
#' @return [`tibble::tibble`]
20001996
#' @keywords endpoint
@@ -2042,15 +2038,15 @@ pvt_quidel <- function(
20422038
#' these were designed to track ILI as driven by seasonal influenza, and were
20432039
#' NOT designed to track ILI during the COVID-19 pandemic.
20442040
#'
2045-
#' @examples
2046-
#' \dontrun{
2041+
#' @examplesIf curl::has_internet() && Sys.getenv("SECRET_API_AUTH_SENSORS") != ""
2042+
#'
20472043
#' pvt_sensors(
20482044
#' auth = Sys.getenv("SECRET_API_AUTH_SENSORS"),
20492045
#' names = "sar3",
20502046
#' locations = "nat",
20512047
#' epiweeks = epirange(201501, 202001)
20522048
#' )
2053-
#' }
2049+
#'
20542050
#' @inheritParams .epidatr_shared_params
20552051
#' @return [`tibble::tibble`]
20562052
#' @keywords endpoint
@@ -2095,15 +2091,15 @@ pvt_sensors <- function(
20952091
#' Delphi’s epidemiological data. Sourced from
20962092
#' [Healthtweets](http://www.healthtweets.org/)
20972093
#'
2098-
#' @examples
2099-
#' \dontrun{
2094+
#' @examplesIf curl::has_internet() && Sys.getenv("SECRET_API_AUTH_TWITTER") != ""
2095+
#'
21002096
#' pvt_twitter(
21012097
#' auth = Sys.getenv("SECRET_API_AUTH_TWITTER"),
21022098
#' locations = "CA",
21032099
#' time_type = "week",
21042100
#' time_values = epirange(201501, 202001)
21052101
#' )
2106-
#' }
2102+
#'
21072103
#' @inheritParams .epidatr_shared_params
21082104
#' @return [`tibble::tibble`]
21092105
#' @keywords endpoint
@@ -2173,14 +2169,14 @@ pvt_twitter <- function(
21732169
#' * Other resolution: By article (54)
21742170
#' * Open access
21752171
#'
2176-
#' @examples
2177-
#' \dontrun{
2172+
#' @examplesIf curl::has_internet() && Sys.getenv("DELPHI_EPIDATA_KEY") != ""
2173+
#'
21782174
#' pub_wiki(
21792175
#' articles = "avian_influenza",
21802176
#' time_type = "week",
21812177
#' time_values = epirange(201501, 201601)
21822178
#' )
2183-
#' }
2179+
#'
21842180
#' @inheritParams .epidatr_shared_params
21852181
#' @param articles character. Articles to fetch.
21862182
#' @param language string. Language to fetch.

0 commit comments

Comments
 (0)