Skip to content

Commit 5b87b00

Browse files
author
Os Keyes
committed
fix for CRAN
1 parent b425eef commit 5b87b00

28 files changed

+280
-70
lines changed

DESCRIPTION

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Package: WikipediR
22
Type: Package
33
Title: A MediaWiki API Wrapper
4-
Version: 1.6.0
5-
Date: 2017-11-06
6-
Author: Oliver Keyes [aut, cre], Brock Tilbert [ctb], Clemens Schmid [aut]
7-
Maintainer: Oliver Keyes <ironholds@gmail.com>
4+
Version: 1.7.1
5+
Date: 2024-04-05
6+
Author: Os Keyes [aut, cre], Brock Tilbert [ctb], Clemens Schmid [aut]
7+
Maintainer: Os Keyes <ironholds@gmail.com>
88
Description: A wrapper for the MediaWiki API, aimed particularly at the
99
Wikimedia 'production' wikis, such as Wikipedia. It can be used to retrieve
1010
page text, information about users or the history of pages, and elements of
@@ -22,4 +22,5 @@ Suggests:
2222
BugReports: https://github.com/Ironholds/WikipediR/issues
2323
URL: https://github.com/Ironholds/WikipediR/
2424
VignetteBuilder: knitr
25-
RoxygenNote: 6.0.1
25+
RoxygenNote: 7.3.1
26+
Encoding: UTF-8

NAMESPACE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(parse_response,actiontoken)
4+
S3method(parse_response,blink)
5+
S3method(parse_response,catpages)
6+
S3method(parse_response,createpage)
7+
S3method(parse_response,elink)
8+
S3method(parse_response,login)
9+
S3method(parse_response,pagecats)
10+
S3method(parse_response,pageinfo)
11+
S3method(parse_response,pcontent)
12+
S3method(parse_response,plink)
13+
S3method(parse_response,prelogintoken)
14+
S3method(parse_response,rchanges)
15+
S3method(parse_response,rcontent)
16+
S3method(parse_response,rdiff)
17+
S3method(parse_response,ucontribs)
18+
S3method(parse_response,uinfo)
319
export(categories_in_page)
420
export(create_pages)
521
export(login)
@@ -9,6 +25,7 @@ export(page_external_links)
925
export(page_info)
1026
export(page_links)
1127
export(pages_in_category)
28+
export(parse_response)
1229
export(query)
1330
export(random_page)
1431
export(recent_changes)

R/WikipediR.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
#' \href{https://CRAN.R-project.org/package=WikipediR/vignettes/WikipediR.html}{vignette}.
66
#'
77
#' @seealso The \href{https://CRAN.R-project.org/package=WikipediR/vignettes/WikipediR.html}{package vignette}.
8-
#' @docType package
98
#' @importFrom httr GET user_agent stop_for_status
109
#' @importFrom utils URLencode
1110
#' @aliases WikipediR WikipediR-package
12-
NULL
11+
"_PACKAGE"

R/categories.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@
3636
#'@seealso \code{\link{pages_in_category}} for pages in a specified category.
3737
#'
3838
#'@examples
39-
#'
39+
#'\dontrun{
4040
#'#Retrieve the categories for the "New Age" article on en.wiki
4141
#'cats <- categories_in_page("en", "wikipedia", pages = "New Age")
4242
#'
4343
#'#Retrieve the categories for the "New Age" article on rationalwiki.
4444
#'rw_cats <- categories_in_page(domain = "rationalwiki.org", pages = "New Age")
45+
#'}
4546
#'@export
4647
categories_in_page <- function(language = NULL, project = NULL, domain = NULL,
4748
pages, properties = c("sortkey","timestamp","hidden"),
@@ -122,12 +123,13 @@ categories_in_page <- function(language = NULL, project = NULL, domain = NULL,
122123
#'@seealso \code{\link{categories_in_page}} for finding categories that a specified page is a member of.
123124
#'
124125
#'@examples
125-
#'
126+
#'\dontrun{
126127
#'#Retrieve the pages in the "New Age" category on en.wiki
127128
#'cats <- pages_in_category("en", "wikipedia", categories = "New Age")
128129
#'
129130
#'#Retrieve the pages in the "New Age" category on rationalwiki.
130131
#'rw_cats <- pages_in_category(domain = "rationalwiki.org", categories = "New Age")
132+
#'}
131133
#'@export
132134
pages_in_category <- function(language = NULL, project = NULL, domain = NULL, categories,
133135
properties = c("title","ids","sortkey","sortkeyprefix","type","timestamp"),

R/content.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ invalid_revs <- function(parsed_response){
4242
#'\code{\link{revision_content}} for retrieving the text of specified revisions.
4343
#'
4444
#'@examples
45+
#'\dontrun{
4546
#'#A page from Wikipedia
4647
#'wp_content <- random_page("en","wikipedia")
4748
#'
4849
#'#A page from the mainspace on Wikipedia
4950
#'wp_article_content <- random_page("en","wikipedia", namespaces = 0)
51+
#'}
5052
#'@export
5153
random_page <- function(language = NULL, project = NULL, domain = NULL,
5254
namespaces = NULL, as_wikitext = FALSE, limit = 1,
@@ -109,6 +111,7 @@ random_page <- function(language = NULL, project = NULL, domain = NULL,
109111
#'\code{\link{revision_content}} for retrieving the text of specified revisions.
110112
#'
111113
#'@examples
114+
#'\dontrun{
112115
#'#Content from a Wikimedia project
113116
#'wp_content <- page_content("en","wikipedia", page_name = "Aaron Halfaker")
114117
#'
@@ -117,6 +120,7 @@ random_page <- function(language = NULL, project = NULL, domain = NULL,
117120
#'
118121
#'#Content from a non-Wikimedia project
119122
#'rw_content <- page_content(domain = "rationalwiki.org", page_name = "New Age")
123+
#'}
120124
#'@export
121125
page_content <- function(language = NULL, project = NULL, domain = NULL,
122126
page_name, page_id = NULL, as_wikitext = FALSE, clean_response = FALSE, ...){
@@ -184,12 +188,13 @@ page_content <- function(language = NULL, project = NULL, domain = NULL,
184188
#'and \code{\link{page_content}} for the content a specific page currently has.
185189
#'
186190
#'@examples
187-
#'
191+
#'\dontrun{
188192
#'#Revision content from a Wikimedia project
189193
#'wp_content <- revision_content("en","wikipedia", revisions = 552373187)
190194
#'
191195
#'#Revision content from a non-Wikimedia project
192196
#'rw_content <- revision_content(domain = "rationalwiki.org", revisions = 88616)
197+
#'}
193198
#'@export
194199
revision_content <- function(language = NULL, project = NULL, domain = NULL,
195200
revisions, properties = c("content","ids","flags","timestamp",
@@ -272,12 +277,13 @@ revision_content <- function(language = NULL, project = NULL, domain = NULL,
272277
#'\code{\link{revision_content}} for retrieving the text of specific revisions.
273278
#'
274279
#'@examples
275-
#'
280+
#'\dontrun{
276281
#'#Wikimedia diff
277282
#'wp_diff <- revision_diff("en","wikipedia", revisions = 552373187, direction = "next")
278283
#'
279284
#'#Non-Wikimedia diff
280285
#'rw_diff <- revision_diff(domain = "rationalwiki.org", revisions = 88616, direction = "next")
286+
#'}
281287
#'@export
282288
revision_diff <- function(language = NULL, project = NULL, domain = NULL,
283289
revisions, properties = c("ids","flags","timestamp","user","userid","size",

R/metadata.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
#'any indication of an error.
3737
#'
3838
#'@examples
39+
#'\dontrun{
3940
#'#Backlink
4041
#'all_bls <- page_backlinks("en","wikipedia", page = "Aaron Halfaker")
4142
#'
4243
#'#Namespace-specific backlinks
4344
#'mainspace_bls <- page_backlinks("en","wikipedia", page = "Aaron Halfaker", namespaces = 0)
45+
#'}
4446
#'@export
4547
page_backlinks <- function(language = NULL, project = NULL, domain = NULL,
4648
page, limit = 50, direction = "ascending", namespaces = NULL,
@@ -96,11 +98,13 @@ page_backlinks <- function(language = NULL, project = NULL, domain = NULL,
9698
#'@param ... further arguments to pass to httr's GET.
9799
#'
98100
#'@examples
101+
#'\dontrun{
99102
#'#Links
100103
#'links <- page_links("en","wikipedia", page = "Aaron Halfaker")
101104
#'
102105
#'#Namespace-specific links
103106
#'mainspace_links <- page_links("en","wikipedia", page = "Aaron Halfaker", namespaces = 0)
107+
#'}
104108
#'@export
105109
page_links <- function(language = NULL, project = NULL, domain = NULL,
106110
page, limit = 50, direction = "ascending", namespaces = NULL,
@@ -150,12 +154,14 @@ page_links <- function(language = NULL, project = NULL, domain = NULL,
150154
#'@param ... further arguments to pass to httr's GET.
151155
#'
152156
#'@examples
157+
#'\dontrun{
153158
#'#Links
154159
#'external_links <- page_external_links("en","wikipedia", page = "Aaron Halfaker")
155160
#'
156161
#'#Protocol-specific links
157162
#'external_http_links <- page_external_links("en","wikipedia",
158163
#' page = "Aaron Halfaker", protocol = "http")
164+
#'}
159165
#'@export
160166
page_external_links <- function(language = NULL, project = NULL, domain = NULL,
161167
page, protocol = NULL, clean_response = FALSE,
@@ -203,9 +209,10 @@ page_external_links <- function(language = NULL, project = NULL, domain = NULL,
203209
#'@param ... further arguments to pass to httr's GET.
204210
#'
205211
#'@examples
212+
#'\dontrun{
206213
#'#Metadata
207214
#'page_metadata <- page_info("en","wikipedia", page = "Aaron Halfaker")
208-
#'
215+
#'}
209216
#'@export
210217
page_info <- function(language = NULL, project = NULL, domain = NULL,
211218
page, properties = c("protection","talkid","url", "displaytitle"),

R/parse.R

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,47 @@
1+
#' Response parser
2+
#'
3+
#' Should not be externally used
4+
#'
5+
#' @title parse_response: Parse WikipediR responses internally
6+
#' @param x result from a WikipediR query
7+
#' @export
18
parse_response <- function(x){
29
UseMethod("parse_response", x)
310
}
411

12+
#' @export
513
parse_response.rchanges <- function(x){
614
x <- x$query$recentchanges
715
return(x)
816
}
917

18+
#' @export
1019
parse_response.rcontent <- function(x){
1120
x <- x$query$pages
1221
names(x) <- NULL
1322
return(x)
1423
}
1524

25+
#' @export
1626
parse_response.pcontent <- function(x){
1727
x <- x$parse
1828
return(x)
1929
}
2030

31+
#' @export
2132
parse_response.rdiff <- function(x){
2233
x <- x$query$pages
2334
names(x) <- NULL
2435
return(x)
2536
}
2637

38+
#' @export
2739
parse_response.uinfo <- function(x){
2840
x <- x$query$users
2941
return(x)
3042
}
3143

44+
#' @export
3245
parse_response.ucontribs <- function(x){
3346
x <- x$query$usercontribs
3447
results <- unlist(x)
@@ -37,6 +50,8 @@ parse_response.ucontribs <- function(x){
3750
names(results) <- names(x[[1]])
3851
return(results)
3952
}
53+
54+
#' @export
4055
parse_response.catpages <- function(x){
4156
x <- x$query$categorymembers
4257
results <- unlist(x)
@@ -45,6 +60,8 @@ parse_response.catpages <- function(x){
4560
names(results) <- names(x[[1]])
4661
return(results)
4762
}
63+
64+
#' @export
4865
parse_response.pagecats <- function(x){
4966
x <- x$query$pages
5067
names(x) <- NULL
@@ -58,11 +75,15 @@ parse_response.pagecats <- function(x){
5875
})
5976
return(results)
6077
}
78+
79+
#' @export
6180
parse_response.blink <- function(x){
6281
x <- x$query$backlinks
6382
results <- lapply(x,unlist)
6483
return(results)
6584
}
85+
86+
#' @export
6687
parse_response.plink <- function(x){
6788
x <- x$query$pages
6889
names(x) <- NULL
@@ -72,6 +93,8 @@ parse_response.plink <- function(x){
7293
})
7394
return(results)
7495
}
96+
97+
#' @export
7598
parse_response.elink <- function(x){
7699
x <- x$query$pages
77100
names(x) <- NULL
@@ -82,6 +105,8 @@ parse_response.elink <- function(x){
82105
})
83106
return(results)
84107
}
108+
109+
#' @export
85110
parse_response.pageinfo <- function(x){
86111
x <- x$query$pages
87112
names(x) <- NULL
@@ -92,21 +117,25 @@ parse_response.pageinfo <- function(x){
92117
return(results)
93118
}
94119

120+
#' @export
95121
parse_response.prelogintoken <- function(x){
96122
x <- x$login$token
97123
return(x)
98124
}
99125

126+
#' @export
100127
parse_response.login <- function(x){
101128
x <- x$clientlogin$status == "PASS"
102129
return(x)
103130
}
104131

132+
#' @export
105133
parse_response.actiontoken <- function(x){
106134
x <- x$query$tokens$csrftoken
107135
return(x)
108136
}
109137

138+
#' @export
110139
parse_response.createpage <- function(x){
111140
x <- x$edit$result == "Success"
112141
return(x)

R/user_info.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ missing_users <- function(parsed_response){
5252
#'and \code{recent_changes} for non-user-specific recent actions.
5353
#'
5454
#'@examples
55-
#'
55+
#'\dontrun{
5656
#'#Retrieve the timestamps of a user's recent contributions to the English-language Wikipedia
5757
#'contribs <- user_contributions("en", "wikipedia", username = "Ironholds",
5858
#' properties = "timestamp")
5959
#'
6060
#'#Retrieve the timestamps of a user's recent contributions to a non-Wikimedia wiki.
6161
#'rw_contribs <- user_contributions(domain = "rationalwiki.org", username = "David Gerard",
6262
#' properties = "ids", limit = 1)
63-
#'
63+
#'}
6464
#'@export
6565
user_contributions <- function(language = NULL, project = NULL, domain = NULL,
6666
username, properties = c("ids", "title", "timestamp",
@@ -149,13 +149,15 @@ user_contributions <- function(language = NULL, project = NULL, domain = NULL,
149149
#'a particular user.
150150
#'
151151
#'@examples
152+
#'\dontrun{
152153
#'#Retrieving information from a Wikimedia project
153154
#'user_info <- user_information("en", "wikipedia", user_names = "David Gerard",
154155
#' properties = "registration")
155156
#'
156157
#'#Non-Wikimedia projects
157158
#'user_info <- user_information(domain = "rationalwiki.org", user_names = "David Gerard",
158159
#' properties = "registration")
160+
#'}
159161
#'@export
160162
user_information <- function(language = NULL, project = NULL, domain = NULL,
161163
user_names, properties = c("blockinfo","groups","implicitgroups",

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ WikipediR
33

44
An R API wrapper for MediaWiki, optimised for the Wikimedia Foundation MediaWiki instances, such as Wikipedia.
55

6-
__Author:__ Oliver Keyes<br/>
7-
__License:__ [MIT](http://opensource.org/licenses/MIT)<br/>
6+
__Author:__ Os Keyes<br/>
7+
__License:__ [MIT](https://opensource.org/licenses/MIT)<br/>
88
__Status:__ Stable
99

10-
![downloads](http://cranlogs.r-pkg.org/badges/grand-total/WikipediR)
10+
![downloads](https://cranlogs.r-pkg.org/badges/grand-total/WikipediR)
1111

1212
Description
1313
======
1414
_WikipediR_ is a wrapper around the MediaWiki API, optimised for the Wikimedia Foundation's production sites, such as Wikipedia. It is written in and for R, a statistical environment and associated programming language in heavy use by HCI researchers that, somehow, escaped having an API wrapper until now.
1515

16-
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
17-
1816
Installation
1917
======
2018

man/WikipediR.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)