From 8576788147ac5a1ceb4d1c48bcf0dfa17f0dbfe7 Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 6 Jun 2025 10:13:07 -0400 Subject: [PATCH 1/5] Use roxygen md --- DESCRIPTION | 3 ++- man/WD.globalvar.Rd | 16 ++++++++-------- man/WikidataR.Rd | 19 ++++++++++++++++++- man/as_qid.Rd | 2 +- man/as_quot.Rd | 10 +++++----- man/as_sid.Rd | 4 ++-- man/createrows.tidy.Rd | 2 +- man/disambiguate_QIDs.Rd | 8 ++++---- man/filter_qids.Rd | 2 +- man/get_example.Rd | 10 +++++----- man/get_geo_box.Rd | 16 ++++++++-------- man/get_geo_entity.Rd | 16 ++++++++-------- man/qid_from_identifier.Rd | 2 +- man/query_wikidata.Rd | 18 ++++++++++-------- man/searcher.Rd | 2 +- man/url_to_id.Rd | 2 +- man/wd_query.Rd | 2 +- man/wd_rand_query.Rd | 6 +++--- man/write_wikibase.Rd | 14 +++++++------- man/write_wikidata.Rd | 14 +++++++------- 20 files changed, 94 insertions(+), 74 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d85a330..bbf168b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,7 +42,8 @@ Suggests: knitr, pageviews, spelling -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Encoding: UTF-8 Depends: R (>= 3.5.0) Language: en-US +Roxygen: list(markdown = TRUE) diff --git a/man/WD.globalvar.Rd b/man/WD.globalvar.Rd index 2a02783..69db5aa 100644 --- a/man/WD.globalvar.Rd +++ b/man/WD.globalvar.Rd @@ -4,15 +4,15 @@ \alias{WD.globalvar} \title{Global variables for Wikidata properties} \format{ -A list of tibbles documenting key property constraints from Wikidata +A list of tibbles documenting key property constraints from Wikidata \describe{ - \item{SID.valid}{valid reference source properties} - \item{PID.datatype}{required data type for each property} - \item{PID.constraint}{expected regex match for each property} - \item{lang.abbrev}{language abbreviations} - \item{lang.abbrev.wiki}{language abbreviations for current wikis} - \item{abbrev.wiki}{Wikimedia abbreviations for current wikis} - ... +\item{SID.valid}{valid reference source properties} +\item{PID.datatype}{required data type for each property} +\item{PID.constraint}{expected regex match for each property} +\item{lang.abbrev}{language abbreviations} +\item{lang.abbrev.wiki}{language abbreviations for current wikis} +\item{abbrev.wiki}{Wikimedia abbreviations for current wikis} +... } } \description{ diff --git a/man/WikidataR.Rd b/man/WikidataR.Rd index 1b4b1d7..d01b7a7 100644 --- a/man/WikidataR.Rd +++ b/man/WikidataR.Rd @@ -7,7 +7,7 @@ \title{API client library for Wikidata} \description{ This package serves as an API client for reading and writing -to and from \href{https://www.wikidata.org/wiki/Wikidata:Main_Page}{Wikidata}, (including +to and from \href{https://www.wikidata.org/wiki/Wikidata:Main_Page}{Wikidata}, (including via the \href{https://quickstatements.toolforge.org/}{QuickStatements} format), as well as for reading from \href{https://www.wikipedia.org}{Wikipedia}. } @@ -17,3 +17,20 @@ as well as for reading from \href{https://www.wikipedia.org}{Wikipedia}. for using search functionality to pull out item or property IDs where the descriptions or aliases match a particular search term. } +\author{ +\strong{Maintainer}: Thomas Shafee \email{T.Shafee@latrobe.edu.au} (\href{https://orcid.org/0000-0002-2298-7593}{ORCID}) + +Authors: +\itemize{ + \item Os Keyes (\href{https://orcid.org/0000-0001-5196-609X}{ORCID}) + \item Serena Signorelli +} + +Other contributors: +\itemize{ + \item Alex Lum (\href{https://orcid.org/0000-0002-9295-9053}{ORCID}) [contributor] + \item Christian Graul [contributor] + \item Mikhail Popov (\href{https://orcid.org/0000-0003-0145-8948}{ORCID}) [contributor] +} + +} diff --git a/man/as_qid.Rd b/man/as_qid.Rd index 750ea51..aa0c276 100644 --- a/man/as_qid.Rd +++ b/man/as_qid.Rd @@ -15,7 +15,7 @@ If the inputted string matches an item label, return its QID. If the inputted string matches multiple labels of multiple items, return the QID of the first hit. } \description{ -Convert an input string to the most likely item +Convert an input string to the most likely item \href{https://www.wikidata.org/wiki/Q43649390}{QID}. } \examples{ diff --git a/man/as_quot.Rd b/man/as_quot.Rd index 2e7c462..11d23f9 100644 --- a/man/as_quot.Rd +++ b/man/as_quot.Rd @@ -9,17 +9,17 @@ as_quot(x, format = "tibble") \arguments{ \item{x}{a vector, data frame, or tibble of strings} -\item{format}{either "tibble" / "csv" to use plain quotation marks (default), -or "api" / "website" to use '\%22'} +\item{format}{either "tibble" / "csv" to use plain quotation marks (default), +or "api" / "website" to use '\\%22'} } \value{ A tibble of items inside of escaped quotation marks -unless they are already in escaped quotation marks, is a -\href{https://www.wikidata.org/wiki/Q43649390}{QID}, +unless they are already in escaped quotation marks, is a +\href{https://www.wikidata.org/wiki/Q43649390}{QID}, in which chase it is returned unchanged. } \description{ -Add escaped quotation marks around strings that need them ready for +Add escaped quotation marks around strings that need them ready for submission to an API. } \examples{ diff --git a/man/as_sid.Rd b/man/as_sid.Rd index fe8ed5a..6103220 100644 --- a/man/as_sid.Rd +++ b/man/as_sid.Rd @@ -7,13 +7,13 @@ as_sid(x) } \arguments{ -\item{x}{a vector, data frame, or tibble of strings representing Wikidata +\item{x}{a vector, data frame, or tibble of strings representing Wikidata source properties.} } \value{ if the inputted string is a valid SID, return the string. If the inputted string matches a property label, return its SID. -If the inputted string matches multiple labels of multiple properties, +If the inputted string matches multiple labels of multiple properties, return the SID of the first hit. } \description{ diff --git a/man/createrows.tidy.Rd b/man/createrows.tidy.Rd index a7b0336..fbf05c1 100644 --- a/man/createrows.tidy.Rd +++ b/man/createrows.tidy.Rd @@ -11,7 +11,7 @@ createrows.tidy(QS.tib) } \value{ a tibble, with items that start with "CREATE" followed by any unique text causing the -addition of a "Create" line above, being replaced with "LAST" in the QuickStatements +addition of a "Create" line above, being replaced with "LAST" in the QuickStatements format to create new QIDs. } \description{ diff --git a/man/disambiguate_QIDs.Rd b/man/disambiguate_QIDs.Rd index 518b341..415227d 100644 --- a/man/disambiguate_QIDs.Rd +++ b/man/disambiguate_QIDs.Rd @@ -40,10 +40,10 @@ Can also be a list of lists (see examples)} \value{ a vector of: \describe{ - \item{QID}{Selected QID (for when an appropriate Wikidata match exists)} - \item{CREATE}{Mark that a new Wikidata item should be created (for when no appropriate Wikidata match yet exists)} - \item{NA}{Mark that no Wikidata item is needed} - \item{STOP}{Mark that the process was halted at this point (so that output can be used as input to the function later)} +\item{QID}{Selected QID (for when an appropriate Wikidata match exists)} +\item{CREATE}{Mark that a new Wikidata item should be created (for when no appropriate Wikidata match yet exists)} +\item{NA}{Mark that no Wikidata item is needed} +\item{STOP}{Mark that the process was halted at this point (so that output can be used as input to the function later)} } } \description{ diff --git a/man/filter_qids.Rd b/man/filter_qids.Rd index a787dff..5909f22 100644 --- a/man/filter_qids.Rd +++ b/man/filter_qids.Rd @@ -30,7 +30,7 @@ For a QID or vector of QIDs, remove ones that match a particular statement (e.g. remove all that are instances of academic publications or books). } \details{ -The \href{https://www.wikidata.org/wiki/Q43649390}{Wikidata Q identifier} (QID) +The \href{https://www.wikidata.org/wiki/Q43649390}{Wikidata Q identifier} (QID) is the unique identifier (UID) used in Wikidata. } \examples{ diff --git a/man/get_example.Rd b/man/get_example.Rd index 944831b..6138525 100644 --- a/man/get_example.Rd +++ b/man/get_example.Rd @@ -8,19 +8,19 @@ get_example(example_name) } \arguments{ \item{example_name}{the names of the examples as they appear on -[this page](https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples)} +\href{https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples}{this page}} } \value{ The SPARQL query as a character vector. } \description{ Gets the specified example(s) from - [SPARQL query service examples page](https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples) - using [Wikidata's MediaWiki API](https://www.wikidata.org/w/api.php). +\href{https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples}{SPARQL query service examples page} +using \href{https://www.wikidata.org/w/api.php}{Wikidata's MediaWiki API}. } \details{ If you are planning on extracting multiple examples, please provide - all the names as a single vector for efficiency. +all the names as a single vector for efficiency. } \examples{ \dontrun{ @@ -34,5 +34,5 @@ query_wikidata(sparql_query) } } \seealso{ -[query_wikidata] +\link{query_wikidata} } diff --git a/man/get_geo_box.Rd b/man/get_geo_box.Rd index 51c85dd..7f645b2 100644 --- a/man/get_geo_box.Rd +++ b/man/get_geo_box.Rd @@ -34,14 +34,14 @@ of the item. "en" by default.} \value{ a data.frame of 5 columns: \itemize{ - \item{item}{ the Wikidata identifier of each object associated with - \code{entity}.} - \item{name}{ the name of the item, if available, in the requested language. If it - is not available, \code{NA} will be returned instead.} - \item{latitude}{ the latitude of \code{item}} - \item{longitude}{ the longitude of \code{item}} - \item{entity}{ the entity the item is associated with (necessary for multi-entity - queries).} +\item{item}{ the Wikidata identifier of each object associated with +\code{entity}.} +\item{name}{ the name of the item, if available, in the requested language. If it +is not available, \code{NA} will be returned instead.} +\item{latitude}{ the latitude of \code{item}} +\item{longitude}{ the longitude of \code{item}} +\item{entity}{ the entity the item is associated with (necessary for multi-entity +queries).} } } \description{ diff --git a/man/get_geo_entity.Rd b/man/get_geo_entity.Rd index fb93ef8..d41149e 100644 --- a/man/get_geo_entity.Rd +++ b/man/get_geo_entity.Rd @@ -24,14 +24,14 @@ to restrict the search to.} \value{ a data.frame of 5 columns: \itemize{ - \item{item}{ the Wikidata identifier of each object associated with - \code{entity}.} - \item{name}{ the name of the item, if available, in the requested language. If it - is not available, \code{NA} will be returned instead.} - \item{latitude}{ the latitude of \code{item}} - \item{longitude}{ the longitude of \code{item}} - \item{entity}{ the entity the item is associated with (necessary for multi-entity - queries).} +\item{item}{ the Wikidata identifier of each object associated with +\code{entity}.} +\item{name}{ the name of the item, if available, in the requested language. If it +is not available, \code{NA} will be returned instead.} +\item{latitude}{ the latitude of \code{item}} +\item{longitude}{ the longitude of \code{item}} +\item{entity}{ the entity the item is associated with (necessary for multi-entity +queries).} } } \description{ diff --git a/man/qid_from_identifier.Rd b/man/qid_from_identifier.Rd index 23b306c..334d491 100644 --- a/man/qid_from_identifier.Rd +++ b/man/qid_from_identifier.Rd @@ -21,7 +21,7 @@ A vector of QIDs corresponding to identifiers submitted. Convert unique identifiers to QIDs (for items in Wikidata). } \details{ -The \href{https://www.wikidata.org/wiki/Q43649390}{Wikidata Q identifier} (QID) is the unique identifier (UID) +The \href{https://www.wikidata.org/wiki/Q43649390}{Wikidata Q identifier} (QID) is the unique identifier (UID) used in Wikidata. } \examples{ diff --git a/man/query_wikidata.Rd b/man/query_wikidata.Rd index 7174440..13d7dec 100644 --- a/man/query_wikidata.Rd +++ b/man/query_wikidata.Rd @@ -9,15 +9,15 @@ query_wikidata(sparql_query, format = "tibble", ...) \arguments{ \item{sparql_query}{SPARQL query (can be a vector of queries)} -\item{format}{`tibble` (default) returns a pure character data frame, -`simple` returns a pure character vector, while -`smart` fetches JSON-formatted data and returns a tibble with datetime -columns converted to `POSIXct`.} +\item{format}{\code{tibble} (default) returns a pure character data frame, +\code{simple} returns a pure character vector, while +\code{smart} fetches JSON-formatted data and returns a tibble with datetime +columns converted to \code{POSIXct}.} \item{\\dots}{Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}.} } \value{ -A `tibble` or `vector`. Note: QID values will be returned as QIDs, rather than URLs. +A \code{tibble} or \code{vector}. Note: QID values will be returned as QIDs, rather than URLs. } \description{ Makes a POST request to Wikidata Query Service SPARQL endpoint. @@ -26,12 +26,14 @@ Makes a POST request to Wikidata Query Service SPARQL endpoint. There is a hard query deadline configured which is set to 60 seconds. There are also following limits: -- One client (user agent + IP) is allowed 60 seconds of processing time each - 60 seconds -- One client is allowed 30 error queries per minute +\itemize{ +\item One client (user agent + IP) is allowed 60 seconds of processing time each +60 seconds +\item One client is allowed 30 error queries per minute See \href{https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual#Query_limits}{query limits section} in the Wikidata Query Service User Manual for more information. } +} \examples{ # R's versions and release dates: diff --git a/man/searcher.Rd b/man/searcher.Rd index 93a15b3..dfe2d27 100644 --- a/man/searcher.Rd +++ b/man/searcher.Rd @@ -19,7 +19,7 @@ consist of an ISO language code. Set to "en" by default.} \item{type}{type of wikidata object to return (default = "item")} -\item{\\dots}{Additional parameters to supply to [httr::POST]} +\item{\\dots}{Additional parameters to supply to \link[httr:POST]{httr::POST}} } \value{ If the inputted string matches an item label, return its QID. diff --git a/man/url_to_id.Rd b/man/url_to_id.Rd index 5018343..a951869 100644 --- a/man/url_to_id.Rd +++ b/man/url_to_id.Rd @@ -24,7 +24,7 @@ Convert a URL ending in an identifier (returned by SPARQL queries) to just the plan identifier (QID or PID). } \details{ -The \href{https://www.wikidata.org/wiki/Q43649390}{Wikidata Q identifier} (QID) +The \href{https://www.wikidata.org/wiki/Q43649390}{Wikidata Q identifier} (QID) is the unique identifier (UID) used in Wikidata. } \examples{ diff --git a/man/wd_query.Rd b/man/wd_query.Rd index 5804b98..ec52e0f 100644 --- a/man/wd_query.Rd +++ b/man/wd_query.Rd @@ -12,7 +12,7 @@ wd_query(title, ...) \item{\\dots}{Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}.} } \value{ -A downloaded full wikidata object (item or property) formatted as a +A downloaded full wikidata object (item or property) formatted as a nested json list. } \description{ diff --git a/man/wd_rand_query.Rd b/man/wd_rand_query.Rd index e063f7d..fa23026 100644 --- a/man/wd_rand_query.Rd +++ b/man/wd_rand_query.Rd @@ -7,7 +7,7 @@ wd_rand_query(ns, limit, ...) } \arguments{ -\item{ns}{string indicating namespace, most commonly "Main" for QID items, "Property" +\item{ns}{string indicating namespace, most commonly "Main" for QID items, "Property" for PID properties.} \item{limit}{How many random object to return.} @@ -15,10 +15,10 @@ for PID properties.} \item{\\dots}{Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}.} } \value{ -Downloaded full wikidata objects (items or properties) formatted +Downloaded full wikidata objects (items or properties) formatted as nested json lists. } \description{ -Utility wrapper for Wikidata API to download random items. +Utility wrapper for Wikidata API to download random items. Used by \code{random_item}. } diff --git a/man/write_wikibase.Rd b/man/write_wikibase.Rd index 5821667..6bfd93f 100644 --- a/man/write_wikibase.Rd +++ b/man/write_wikibase.Rd @@ -33,7 +33,7 @@ Using the same id will add additional statements to those new items} \item{properties}{a vector of strings indicating the properties to add as statements (as PIDs or labels). Note: In contrast to \code{write_wikidata}, this function takes no labels as input, just PIDs. Four special properties can also be used: labels, aliases, descriptions and sitelinks. -See [this link](https://www.wikidata.org/wiki/Help:QuickStatements#Adding_labels,_aliases,_descriptions_and_sitelinks) for the syntax.} +See \href{https://www.wikidata.org/wiki/Help:QuickStatements#Adding_labels,_aliases,_descriptions_and_sitelinks}{this link} for the syntax.} \item{values}{a vector of strings indicating the values to add as statements (as QIDs). Note: if strings are provided, they will be treated as plain text.} @@ -55,21 +55,21 @@ be removed from the item rather than added (default = FALSE)} \item{format}{output format as a string. Options include: \describe{ - \item{tibble}{easiest format to further manipulation in R} - \item{csv}{can be copy-pasted to the Wikibase QuickStatements website (or manipulated in a spreadsheet programs). In contrast to write_wikidata function the delimiter is `tab`, because Quickstatements expect tab-separated data} - \item{api}{a url that can be copy-pasted into a web browser, or automatically submitted (see \code{api.submit} parameter)} - \item{website}{open a [QuickStatements](https://quickstatements.toolforge.org/) web browser window summarizing the edits to be made to Wikidata)} +\item{tibble}{easiest format to further manipulation in R} +\item{csv}{can be copy-pasted to the Wikibase QuickStatements website (or manipulated in a spreadsheet programs). In contrast to write_wikidata function the delimiter is \code{tab}, because Quickstatements expect tab-separated data} +\item{api}{a url that can be copy-pasted into a web browser, or automatically submitted (see \code{api.submit} parameter)} +\item{website}{open a \href{https://quickstatements.toolforge.org/}{QuickStatements} web browser window summarizing the edits to be made to Wikidata)} }} \item{format.csv.file}{path to save the csv file. If none is provided, then printed to console.} \item{api.username}{a string indicating your Wikimedia username} -\item{api.token}{a string indicating your api token (the unique identifier that you can find listed at [your user page](https://quickstatements.toolforge.org/#/user))} +\item{api.token}{a string indicating your api token (the unique identifier that you can find listed at \href{https://quickstatements.toolforge.org/#/user}{your user page})} \item{api.format}{a string indicating which version of the quickstatement format used to submit the api (default = "v1")} -\item{api.batchname}{a string create a named batch (listed at [your batch history page](https://quickstatements.toolforge.org/#/batches)) and tag in the edit summaries} +\item{api.batchname}{a string create a named batch (listed at \href{https://quickstatements.toolforge.org/#/batches}{your batch history page}) and tag in the edit summaries} \item{api.submit}{boolian indicating whether to submit instruction directly to wikidata (else returns the URL that can be copy-pasted into a web browser)} diff --git a/man/write_wikidata.Rd b/man/write_wikidata.Rd index 7c8f447..2e0cdb6 100644 --- a/man/write_wikidata.Rd +++ b/man/write_wikidata.Rd @@ -32,7 +32,7 @@ Using the same id will add additional statements to those new items} Note: if labels are provided, and multiple items match, the first matching item will be used (see \code{as_pid} function), so use with caution. Four special properties can also be used: labels, aliases, descriptions and sitelinks. -See [this link](https://www.wikidata.org/wiki/Help:QuickStatements#Adding_labels,_aliases,_descriptions_and_sitelinks) for the syntax.} +See \href{https://www.wikidata.org/wiki/Help:QuickStatements#Adding_labels,_aliases,_descriptions_and_sitelinks}{this link} for the syntax.} \item{values}{a vector of strings indicating the values to add as statements (as QIDs or strings). Note: if strings are provided, they will be treated as plain text.} @@ -56,19 +56,19 @@ be removed from the item rather than added (default = FALSE)} \item{format}{output format as a string. Options include: \describe{ - \item{tibble}{easiest format to further manipulation in R} - \item{csv}{can be copy-pasted to [the QuickStatements website](https://quickstatements.toolforge.org/) (or manipulated in a spreadsheet programs)} - \item{api}{a url that can be copy-pasted into a web browser, or automatically submitted (see \code{api.submit} parameter)} - \item{website}{open a [QuickStatements](https://quickstatements.toolforge.org/) web browser window summarizing the edits to be made to Wikidata)} +\item{tibble}{easiest format to further manipulation in R} +\item{csv}{can be copy-pasted to \href{https://quickstatements.toolforge.org/}{the QuickStatements website} (or manipulated in a spreadsheet programs)} +\item{api}{a url that can be copy-pasted into a web browser, or automatically submitted (see \code{api.submit} parameter)} +\item{website}{open a \href{https://quickstatements.toolforge.org/}{QuickStatements} web browser window summarizing the edits to be made to Wikidata)} }} \item{api.username}{a string indicating your Wikimedia username} -\item{api.token}{a string indicating your api token (the unique identifier that you can find listed at [your user page](https://quickstatements.toolforge.org/#/user))} +\item{api.token}{a string indicating your api token (the unique identifier that you can find listed at \href{https://quickstatements.toolforge.org/#/user}{your user page})} \item{api.format}{a string indicating which version of the quickstatement format used to submit the api (default = "v1")} -\item{api.batchname}{a string create a named batch (listed at [your batch history page](https://quickstatements.toolforge.org/#/batches)) and tag in the edit summaries} +\item{api.batchname}{a string create a named batch (listed at \href{https://quickstatements.toolforge.org/#/batches}{your batch history page}) and tag in the edit summaries} \item{api.submit}{boolian indicating whether to submit instruction directly to wikidata (else returns the URL that can be copy-pasted into a web browser)} } From f2bb4077c7aeadcc0ee3ffc4ec8d1d58af2bdb78 Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 6 Jun 2025 10:15:46 -0400 Subject: [PATCH 2/5] clean-up deprecation warning --- R/{WikidataR.R => WikidataR-package.R} | 8 ++++---- man/{WikidataR.Rd => WikidataR-package.Rd} | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) rename R/{WikidataR.R => WikidataR-package.R} (89%) rename man/{WikidataR.Rd => WikidataR-package.Rd} (93%) diff --git a/R/WikidataR.R b/R/WikidataR-package.R similarity index 89% rename from R/WikidataR.R rename to R/WikidataR-package.R index aa8390d..164a0d1 100644 --- a/R/WikidataR.R +++ b/R/WikidataR-package.R @@ -1,14 +1,14 @@ -#' @title API client library for Wikidata #' @description This package serves as an API client for reading and writing #' to and from \href{https://www.wikidata.org/wiki/Wikidata:Main_Page}{Wikidata}, (including #' via the \href{https://quickstatements.toolforge.org/}{QuickStatements} format), #' as well as for reading from \href{https://www.wikipedia.org}{Wikipedia}. -#' @name WikidataR -#' @docType package #' @seealso \code{\link{get_random}} for selecting a random item or property, #' \code{\link{get_item}} for a /specific/ item or property, or \code{\link{find_item}} #' for using search functionality to pull out item or property IDs where the descriptions #' or aliases match a particular search term. +"_PACKAGE" + +## usethis namespace: start #' @import WikidataQueryServiceR #' @import tibble #' @import dplyr @@ -25,5 +25,5 @@ #' @importFrom WikipediR page_content random_page query #' @importFrom httr user_agent #' @importFrom jsonlite fromJSON -#' @aliases WikidataR WikidataR-package +## usethis namespace: end NULL \ No newline at end of file diff --git a/man/WikidataR.Rd b/man/WikidataR-package.Rd similarity index 93% rename from man/WikidataR.Rd rename to man/WikidataR-package.Rd index d01b7a7..f194146 100644 --- a/man/WikidataR.Rd +++ b/man/WikidataR-package.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/WikidataR.R \docType{package} -\name{WikidataR} +\name{WikidataR-package} \alias{WikidataR} \alias{WikidataR-package} -\title{API client library for Wikidata} +\title{WikidataR: Read-Write API Client Library for Wikidata} \description{ This package serves as an API client for reading and writing to and from \href{https://www.wikidata.org/wiki/Wikidata:Main_Page}{Wikidata}, (including From 899dc7fe5a3274494ea5db41a867c0c8db85c042 Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 6 Jun 2025 10:19:01 -0400 Subject: [PATCH 3/5] fix warnings from roxygen2 --- R/geo.R | 5 ++--- R/gets.R | 6 +++--- man/WikidataR-package.Rd | 2 +- man/find_item.Rd | 17 ++++++++++++++++- man/get_geo_box.Rd | 17 ++++++++++++++++- man/get_geo_entity.Rd | 17 ++++++++++++++++- man/get_item.Rd | 17 ++++++++++++++++- man/get_random.Rd | 17 ++++++++++++++++- 8 files changed, 86 insertions(+), 12 deletions(-) diff --git a/R/geo.R b/R/geo.R index 1e6077b..0ba4f93 100644 --- a/R/geo.R +++ b/R/geo.R @@ -16,8 +16,7 @@ #' #'@param limit the maximum number of results to return. #' -#'@param \\dots further arguments to pass to de{httr:ink[httr::GET]{GET}}. -#' +#'@inheritDotParams httr::GET #'@return a data.frame of 5 columns: #'\itemize{ #' \item{item}{ the Wikidata identifier of each object associated with @@ -112,7 +111,7 @@ get_geo_entity <- function(entity, language = "en", radius = NULL, limit=100, .. #'@param language the two-letter language code to use for the name #'of the item. "en" by default. #' -#'@param \\dots further arguments to pass to de{httr:ink[httr::GET]{GET}}. +#'@inheritDotParams httr::GET #' #'@return a data.frame of 5 columns: #'\itemize{ diff --git a/R/gets.R b/R/gets.R index 4e848e6..4f27eb9 100644 --- a/R/gets.R +++ b/R/gets.R @@ -12,7 +12,7 @@ #'it appropriately. This function is vectorized and will happily accept #'multiple IDs. #' -#'@param \\dots further arguments to pass to de{httr:ink[httr::GET]{GET}}. +#'@inheritDotParams httr::GET #' #'@seealso \code{\link{get_random}} for selecting a random item or property, #'or \code{\link{find_item}} for using search functionality to pull out @@ -57,7 +57,7 @@ get_property <- function(id, ...){ #' #'@param limit how many random items to return. 1 by default, but can be higher. #' -#'@param \\dots arguments to pass to de{httr:ink[httr::GET]{GET}}. +#'@inheritDotParams httr::GET #' #'@seealso \code{\link{get_item}} for selecting a specific item or property, #'or \code{\link{find_item}} for using search functionality to pull out @@ -140,7 +140,7 @@ get_example <- function(example_name){ #' #'@param limit The number of results to return; set to \code{10} by default. #' -#'@param \\dots further arguments to pass to de{httr:ink[httr::GET]{GET}}. +#'@inheritDotParams httr::GET #' #'@seealso \code{\link{get_random}} for selecting a random item or property, #'or \code{\link{get_item}} for selecting a specific item or property. diff --git a/man/WikidataR-package.Rd b/man/WikidataR-package.Rd index f194146..2dc0b23 100644 --- a/man/WikidataR-package.Rd +++ b/man/WikidataR-package.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/WikidataR.R +% Please edit documentation in R/WikidataR-package.R \docType{package} \name{WikidataR-package} \alias{WikidataR} diff --git a/man/find_item.Rd b/man/find_item.Rd index b7dfdb2..302ce04 100644 --- a/man/find_item.Rd +++ b/man/find_item.Rd @@ -28,7 +28,22 @@ consist of an ISO language code. Defaults to \code{"en"}.} \item{limit}{The number of results to return; set to \code{10} by default.} -\item{\\dots}{further arguments to pass to de{httr:ink[httr::GET]{GET}}.} +\item{...}{ + Arguments passed on to \code{\link[httr:GET]{httr::GET}} + \describe{ + \item{\code{url}}{the url of the page to retrieve} + \item{\code{config}}{Additional configuration settings such as http +authentication (\code{\link[httr:authenticate]{authenticate()}}), additional headers +(\code{\link[httr:add_headers]{add_headers()}}), cookies (\code{\link[httr:set_cookies]{set_cookies()}}) etc. +See \code{\link[httr:config]{config()}} for full details and list of helpers.} + \item{\code{handle}}{The handle to use with this request. If not +supplied, will be retrieved and reused from the \code{\link[httr:handle_pool]{handle_pool()}} +based on the scheme, hostname and port of the url. By default \pkg{httr} +requests to the same scheme/host/port combo. This substantially reduces +connection time, and ensures that cookies are maintained over multiple +requests to the same host. See \code{\link[httr:handle_pool]{handle_pool()}} for more +details.} + }} } \value{ A list containing the result of the query. diff --git a/man/get_geo_box.Rd b/man/get_geo_box.Rd index 7f645b2..d41d240 100644 --- a/man/get_geo_box.Rd +++ b/man/get_geo_box.Rd @@ -29,7 +29,22 @@ to \code{city} (eg "NorthWest", "SouthEast").} \item{language}{the two-letter language code to use for the name of the item. "en" by default.} -\item{\\dots}{further arguments to pass to de{httr:ink[httr::GET]{GET}}.} +\item{...}{ + Arguments passed on to \code{\link[httr:GET]{httr::GET}} + \describe{ + \item{\code{url}}{the url of the page to retrieve} + \item{\code{config}}{Additional configuration settings such as http +authentication (\code{\link[httr:authenticate]{authenticate()}}), additional headers +(\code{\link[httr:add_headers]{add_headers()}}), cookies (\code{\link[httr:set_cookies]{set_cookies()}}) etc. +See \code{\link[httr:config]{config()}} for full details and list of helpers.} + \item{\code{handle}}{The handle to use with this request. If not +supplied, will be retrieved and reused from the \code{\link[httr:handle_pool]{handle_pool()}} +based on the scheme, hostname and port of the url. By default \pkg{httr} +requests to the same scheme/host/port combo. This substantially reduces +connection time, and ensures that cookies are maintained over multiple +requests to the same host. See \code{\link[httr:handle_pool]{handle_pool()}} for more +details.} + }} } \value{ a data.frame of 5 columns: diff --git a/man/get_geo_entity.Rd b/man/get_geo_entity.Rd index d41149e..a8a24d2 100644 --- a/man/get_geo_entity.Rd +++ b/man/get_geo_entity.Rd @@ -19,7 +19,22 @@ to restrict the search to.} \item{limit}{the maximum number of results to return.} -\item{\\dots}{further arguments to pass to de{httr:ink[httr::GET]{GET}}.} +\item{...}{ + Arguments passed on to \code{\link[httr:GET]{httr::GET}} + \describe{ + \item{\code{url}}{the url of the page to retrieve} + \item{\code{config}}{Additional configuration settings such as http +authentication (\code{\link[httr:authenticate]{authenticate()}}), additional headers +(\code{\link[httr:add_headers]{add_headers()}}), cookies (\code{\link[httr:set_cookies]{set_cookies()}}) etc. +See \code{\link[httr:config]{config()}} for full details and list of helpers.} + \item{\code{handle}}{The handle to use with this request. If not +supplied, will be retrieved and reused from the \code{\link[httr:handle_pool]{handle_pool()}} +based on the scheme, hostname and port of the url. By default \pkg{httr} +requests to the same scheme/host/port combo. This substantially reduces +connection time, and ensures that cookies are maintained over multiple +requests to the same host. See \code{\link[httr:handle_pool]{handle_pool()}} for more +details.} + }} } \value{ a data.frame of 5 columns: diff --git a/man/get_item.Rd b/man/get_item.Rd index ec66a33..87e5314 100644 --- a/man/get_item.Rd +++ b/man/get_item.Rd @@ -16,7 +16,22 @@ even with an included namespace ("Property:P10") - the function will format it appropriately. This function is vectorized and will happily accept multiple IDs.} -\item{\\dots}{further arguments to pass to de{httr:ink[httr::GET]{GET}}.} +\item{...}{ + Arguments passed on to \code{\link[httr:GET]{httr::GET}} + \describe{ + \item{\code{url}}{the url of the page to retrieve} + \item{\code{config}}{Additional configuration settings such as http +authentication (\code{\link[httr:authenticate]{authenticate()}}), additional headers +(\code{\link[httr:add_headers]{add_headers()}}), cookies (\code{\link[httr:set_cookies]{set_cookies()}}) etc. +See \code{\link[httr:config]{config()}} for full details and list of helpers.} + \item{\code{handle}}{The handle to use with this request. If not +supplied, will be retrieved and reused from the \code{\link[httr:handle_pool]{handle_pool()}} +based on the scheme, hostname and port of the url. By default \pkg{httr} +requests to the same scheme/host/port combo. This substantially reduces +connection time, and ensures that cookies are maintained over multiple +requests to the same host. See \code{\link[httr:handle_pool]{handle_pool()}} for more +details.} + }} } \description{ \code{get_item} and \code{get_property} allow you to retrieve the data associated diff --git a/man/get_random.Rd b/man/get_random.Rd index b85e65d..260644d 100644 --- a/man/get_random.Rd +++ b/man/get_random.Rd @@ -13,7 +13,22 @@ get_random_property(limit = 1, ...) \arguments{ \item{limit}{how many random items to return. 1 by default, but can be higher.} -\item{\\dots}{arguments to pass to de{httr:ink[httr::GET]{GET}}.} +\item{...}{ + Arguments passed on to \code{\link[httr:GET]{httr::GET}} + \describe{ + \item{\code{url}}{the url of the page to retrieve} + \item{\code{config}}{Additional configuration settings such as http +authentication (\code{\link[httr:authenticate]{authenticate()}}), additional headers +(\code{\link[httr:add_headers]{add_headers()}}), cookies (\code{\link[httr:set_cookies]{set_cookies()}}) etc. +See \code{\link[httr:config]{config()}} for full details and list of helpers.} + \item{\code{handle}}{The handle to use with this request. If not +supplied, will be retrieved and reused from the \code{\link[httr:handle_pool]{handle_pool()}} +based on the scheme, hostname and port of the url. By default \pkg{httr} +requests to the same scheme/host/port combo. This substantially reduces +connection time, and ensures that cookies are maintained over multiple +requests to the same host. See \code{\link[httr:handle_pool]{handle_pool()}} for more +details.} + }} } \description{ \code{get_random_item} and \code{get_random_property} allow you to retrieve the data From 34a53a3b881a0b1fca10a1968795aecfd969dc9b Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 6 Jun 2025 10:35:07 -0400 Subject: [PATCH 4/5] fix remaining cran notes --- R/geo.R | 4 ++-- R/gets.R | 3 +-- R/queries.R | 8 ++++---- R/utils.R | 2 +- man/as_quot.Rd | 2 +- man/find_item.Rd | 3 +++ man/get_geo_box.Rd | 2 +- man/get_geo_entity.Rd | 2 +- man/query_wikidata.Rd | 43 ++++++++++++++++++++++++++++++++++++++++++- man/sparql_query.Rd | 43 ++++++++++++++++++++++++++++++++++++++++++- man/wd_query.Rd | 43 ++++++++++++++++++++++++++++++++++++++++++- man/wd_rand_query.Rd | 43 ++++++++++++++++++++++++++++++++++++++++++- 12 files changed, 182 insertions(+), 16 deletions(-) diff --git a/R/geo.R b/R/geo.R index 0ba4f93..7c42ecf 100644 --- a/R/geo.R +++ b/R/geo.R @@ -18,7 +18,7 @@ #' #'@inheritDotParams httr::GET #'@return a data.frame of 5 columns: -#'\itemize{ +#'\describe{ #' \item{item}{ the Wikidata identifier of each object associated with #' \code{entity}.} #' \item{name}{ the name of the item, if available, in the requested language. If it @@ -114,7 +114,7 @@ get_geo_entity <- function(entity, language = "en", radius = NULL, limit=100, .. #'@inheritDotParams httr::GET #' #'@return a data.frame of 5 columns: -#'\itemize{ +#'\describe{ #' \item{item}{ the Wikidata identifier of each object associated with #' \code{entity}.} #' \item{name}{ the name of the item, if available, in the requested language. If it diff --git a/R/gets.R b/R/gets.R index 4f27eb9..425a4d4 100644 --- a/R/gets.R +++ b/R/gets.R @@ -139,7 +139,7 @@ get_example <- function(example_name){ #'consist of an ISO language code. Defaults to \code{"en"}. #' #'@param limit The number of results to return; set to \code{10} by default. -#' +#'@inheritParams searcher #'@inheritDotParams httr::GET #' #'@seealso \code{\link{get_random}} for selecting a random item or property, @@ -153,7 +153,6 @@ get_example <- function(example_name){ #'#Check for properties involving the peerage #'peerage_props <- find_property("peerage") #' -#'@aliases find_item find_property #'@return A list containing the result of the query. #'@rdname find_item #'@export diff --git a/R/queries.R b/R/queries.R index 9568a16..0d78f33 100644 --- a/R/queries.R +++ b/R/queries.R @@ -3,7 +3,7 @@ #'@description Utility wrapper for Wikidata API to download item. #'Used by \code{get_item} and \code{get_property}. #'@param title The Wikidata item or property as a string. -#'@param \\dots Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}. +#'@inheritDotParams httr::POST #'@return A downloaded full wikidata object (item or property) formatted as a #'nested json list. #'@export @@ -24,7 +24,7 @@ wd_query <- function(title, ...){ #'@param ns string indicating namespace, most commonly "Main" for QID items, "Property" #'for PID properties. #'@param limit How many random object to return. -#'@param \\dots Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}. +#'@inheritDotParams httr::POST #'@return Downloaded full wikidata objects (items or properties) formatted #'as nested json lists. #'@export @@ -44,7 +44,7 @@ wd_rand_query <- function(ns, limit, ...){ #'@description Utility wrapper for wikidata spargl endpoint to download items. #'Used by \code{get_geo_entity} and \code{get_geo_box}. #'@param query The SPARQL query as a string -#'@param \\dots Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}. +#'@inheritDotParams httr::POST #'@return a download of the full wikidata objects formatted as a nested json list #'@export sparql_query <- function(query, ...){ @@ -65,7 +65,7 @@ sparql_query <- function(query, ...){ #' `simple` returns a pure character vector, while #' `smart` fetches JSON-formatted data and returns a tibble with datetime #' columns converted to `POSIXct`. -#' @param \\dots Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}. +#'@inheritDotParams httr::POST #' @return A `tibble` or `vector`. Note: QID values will be returned as QIDs, rather than URLs. #' @section Query limits: #' There is a hard query deadline configured which is set to 60 seconds. There diff --git a/R/utils.R b/R/utils.R index 06e3f65..b21f936 100644 --- a/R/utils.R +++ b/R/utils.R @@ -202,7 +202,7 @@ as_sid <- function(x){ #'submission to an API. #'@param x a vector, data frame, or tibble of strings #'@param format either "tibble" / "csv" to use plain quotation marks (default), -#'or "api" / "website" to use '\%22' +#'or "api" / "website" to use `'\%22'` #'@return A tibble of items inside of escaped quotation marks #'unless they are already in escaped quotation marks, is a #'\href{https://www.wikidata.org/wiki/Q43649390}{QID}, diff --git a/man/as_quot.Rd b/man/as_quot.Rd index 11d23f9..4f66d23 100644 --- a/man/as_quot.Rd +++ b/man/as_quot.Rd @@ -10,7 +10,7 @@ as_quot(x, format = "tibble") \item{x}{a vector, data frame, or tibble of strings} \item{format}{either "tibble" / "csv" to use plain quotation marks (default), -or "api" / "website" to use '\\%22'} +or "api" / "website" to use \code{'\\\%22'}} } \value{ A tibble of items inside of escaped quotation marks diff --git a/man/find_item.Rd b/man/find_item.Rd index 302ce04..93fee87 100644 --- a/man/find_item.Rd +++ b/man/find_item.Rd @@ -28,6 +28,9 @@ consist of an ISO language code. Defaults to \code{"en"}.} \item{limit}{The number of results to return; set to \code{10} by default.} +\item{response_language}{the language to return the labels and descriptions in; this should +consist of an ISO language code. Set to "en" by default.} + \item{...}{ Arguments passed on to \code{\link[httr:GET]{httr::GET}} \describe{ diff --git a/man/get_geo_box.Rd b/man/get_geo_box.Rd index d41d240..4caf8e1 100644 --- a/man/get_geo_box.Rd +++ b/man/get_geo_box.Rd @@ -48,7 +48,7 @@ details.} } \value{ a data.frame of 5 columns: -\itemize{ +\describe{ \item{item}{ the Wikidata identifier of each object associated with \code{entity}.} \item{name}{ the name of the item, if available, in the requested language. If it diff --git a/man/get_geo_entity.Rd b/man/get_geo_entity.Rd index a8a24d2..d01e8be 100644 --- a/man/get_geo_entity.Rd +++ b/man/get_geo_entity.Rd @@ -38,7 +38,7 @@ details.} } \value{ a data.frame of 5 columns: -\itemize{ +\describe{ \item{item}{ the Wikidata identifier of each object associated with \code{entity}.} \item{name}{ the name of the item, if available, in the requested language. If it diff --git a/man/query_wikidata.Rd b/man/query_wikidata.Rd index 13d7dec..e8bb74b 100644 --- a/man/query_wikidata.Rd +++ b/man/query_wikidata.Rd @@ -14,7 +14,48 @@ query_wikidata(sparql_query, format = "tibble", ...) \code{smart} fetches JSON-formatted data and returns a tibble with datetime columns converted to \code{POSIXct}.} -\item{\\dots}{Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}.} +\item{...}{ + Arguments passed on to \code{\link[httr:POST]{httr::POST}} + \describe{ + \item{\code{url}}{the url of the page to retrieve} + \item{\code{config}}{Additional configuration settings such as http +authentication (\code{\link[httr:authenticate]{authenticate()}}), additional headers +(\code{\link[httr:add_headers]{add_headers()}}), cookies (\code{\link[httr:set_cookies]{set_cookies()}}) etc. +See \code{\link[httr:config]{config()}} for full details and list of helpers.} + \item{\code{body}}{One of the following: +\itemize{ +\item \code{FALSE}: No body. This is typically not used with \code{POST}, +\code{PUT}, or \code{PATCH}, but can be useful if you need to send a +bodyless request (like \code{GET}) with \code{VERB()}. +\item \code{NULL}: An empty body +\item \code{""}: A length 0 body +\item \code{upload_file("path/")}: The contents of a file. The mime +type will be guessed from the extension, or can be supplied explicitly +as the second argument to \code{upload_file()} +\item A character or raw vector: sent as is in body. Use +\code{\link[httr:content_type]{content_type()}} to tell the server what sort of data +you are sending. +\item A named list: See details for encode. +}} + \item{\code{encode}}{If the body is a named list, how should it be encoded? Can be +one of form (application/x-www-form-urlencoded), multipart, +(multipart/form-data), or json (application/json). + +For "multipart", list elements can be strings or objects created by +\code{\link[httr:upload_file]{upload_file()}}. For "form", elements are coerced to strings +and escaped, use \code{I()} to prevent double-escaping. For "json", +parameters are automatically "unboxed" (i.e. length 1 vectors are +converted to scalars). To preserve a length 1 vector as a vector, +wrap in \code{I()}. For "raw", either a character or raw vector. You'll +need to make sure to set the \code{\link[httr:content_type]{content_type()}} yourself.} + \item{\code{handle}}{The handle to use with this request. If not +supplied, will be retrieved and reused from the \code{\link[httr:handle_pool]{handle_pool()}} +based on the scheme, hostname and port of the url. By default \pkg{httr} +requests to the same scheme/host/port combo. This substantially reduces +connection time, and ensures that cookies are maintained over multiple +requests to the same host. See \code{\link[httr:handle_pool]{handle_pool()}} for more +details.} + }} } \value{ A \code{tibble} or \code{vector}. Note: QID values will be returned as QIDs, rather than URLs. diff --git a/man/sparql_query.Rd b/man/sparql_query.Rd index 712698f..bba88fc 100644 --- a/man/sparql_query.Rd +++ b/man/sparql_query.Rd @@ -9,7 +9,48 @@ sparql_query(query, ...) \arguments{ \item{query}{The SPARQL query as a string} -\item{\\dots}{Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}.} +\item{...}{ + Arguments passed on to \code{\link[httr:POST]{httr::POST}} + \describe{ + \item{\code{url}}{the url of the page to retrieve} + \item{\code{config}}{Additional configuration settings such as http +authentication (\code{\link[httr:authenticate]{authenticate()}}), additional headers +(\code{\link[httr:add_headers]{add_headers()}}), cookies (\code{\link[httr:set_cookies]{set_cookies()}}) etc. +See \code{\link[httr:config]{config()}} for full details and list of helpers.} + \item{\code{body}}{One of the following: +\itemize{ +\item \code{FALSE}: No body. This is typically not used with \code{POST}, +\code{PUT}, or \code{PATCH}, but can be useful if you need to send a +bodyless request (like \code{GET}) with \code{VERB()}. +\item \code{NULL}: An empty body +\item \code{""}: A length 0 body +\item \code{upload_file("path/")}: The contents of a file. The mime +type will be guessed from the extension, or can be supplied explicitly +as the second argument to \code{upload_file()} +\item A character or raw vector: sent as is in body. Use +\code{\link[httr:content_type]{content_type()}} to tell the server what sort of data +you are sending. +\item A named list: See details for encode. +}} + \item{\code{encode}}{If the body is a named list, how should it be encoded? Can be +one of form (application/x-www-form-urlencoded), multipart, +(multipart/form-data), or json (application/json). + +For "multipart", list elements can be strings or objects created by +\code{\link[httr:upload_file]{upload_file()}}. For "form", elements are coerced to strings +and escaped, use \code{I()} to prevent double-escaping. For "json", +parameters are automatically "unboxed" (i.e. length 1 vectors are +converted to scalars). To preserve a length 1 vector as a vector, +wrap in \code{I()}. For "raw", either a character or raw vector. You'll +need to make sure to set the \code{\link[httr:content_type]{content_type()}} yourself.} + \item{\code{handle}}{The handle to use with this request. If not +supplied, will be retrieved and reused from the \code{\link[httr:handle_pool]{handle_pool()}} +based on the scheme, hostname and port of the url. By default \pkg{httr} +requests to the same scheme/host/port combo. This substantially reduces +connection time, and ensures that cookies are maintained over multiple +requests to the same host. See \code{\link[httr:handle_pool]{handle_pool()}} for more +details.} + }} } \value{ a download of the full wikidata objects formatted as a nested json list diff --git a/man/wd_query.Rd b/man/wd_query.Rd index ec52e0f..d8f35c9 100644 --- a/man/wd_query.Rd +++ b/man/wd_query.Rd @@ -9,7 +9,48 @@ wd_query(title, ...) \arguments{ \item{title}{The Wikidata item or property as a string.} -\item{\\dots}{Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}.} +\item{...}{ + Arguments passed on to \code{\link[httr:POST]{httr::POST}} + \describe{ + \item{\code{url}}{the url of the page to retrieve} + \item{\code{config}}{Additional configuration settings such as http +authentication (\code{\link[httr:authenticate]{authenticate()}}), additional headers +(\code{\link[httr:add_headers]{add_headers()}}), cookies (\code{\link[httr:set_cookies]{set_cookies()}}) etc. +See \code{\link[httr:config]{config()}} for full details and list of helpers.} + \item{\code{body}}{One of the following: +\itemize{ +\item \code{FALSE}: No body. This is typically not used with \code{POST}, +\code{PUT}, or \code{PATCH}, but can be useful if you need to send a +bodyless request (like \code{GET}) with \code{VERB()}. +\item \code{NULL}: An empty body +\item \code{""}: A length 0 body +\item \code{upload_file("path/")}: The contents of a file. The mime +type will be guessed from the extension, or can be supplied explicitly +as the second argument to \code{upload_file()} +\item A character or raw vector: sent as is in body. Use +\code{\link[httr:content_type]{content_type()}} to tell the server what sort of data +you are sending. +\item A named list: See details for encode. +}} + \item{\code{encode}}{If the body is a named list, how should it be encoded? Can be +one of form (application/x-www-form-urlencoded), multipart, +(multipart/form-data), or json (application/json). + +For "multipart", list elements can be strings or objects created by +\code{\link[httr:upload_file]{upload_file()}}. For "form", elements are coerced to strings +and escaped, use \code{I()} to prevent double-escaping. For "json", +parameters are automatically "unboxed" (i.e. length 1 vectors are +converted to scalars). To preserve a length 1 vector as a vector, +wrap in \code{I()}. For "raw", either a character or raw vector. You'll +need to make sure to set the \code{\link[httr:content_type]{content_type()}} yourself.} + \item{\code{handle}}{The handle to use with this request. If not +supplied, will be retrieved and reused from the \code{\link[httr:handle_pool]{handle_pool()}} +based on the scheme, hostname and port of the url. By default \pkg{httr} +requests to the same scheme/host/port combo. This substantially reduces +connection time, and ensures that cookies are maintained over multiple +requests to the same host. See \code{\link[httr:handle_pool]{handle_pool()}} for more +details.} + }} } \value{ A downloaded full wikidata object (item or property) formatted as a diff --git a/man/wd_rand_query.Rd b/man/wd_rand_query.Rd index fa23026..c0701c6 100644 --- a/man/wd_rand_query.Rd +++ b/man/wd_rand_query.Rd @@ -12,7 +12,48 @@ for PID properties.} \item{limit}{How many random object to return.} -\item{\\dots}{Additional parameters to supply to \code{httr:\link[httr::POST]{POST}}.} +\item{...}{ + Arguments passed on to \code{\link[httr:POST]{httr::POST}} + \describe{ + \item{\code{url}}{the url of the page to retrieve} + \item{\code{config}}{Additional configuration settings such as http +authentication (\code{\link[httr:authenticate]{authenticate()}}), additional headers +(\code{\link[httr:add_headers]{add_headers()}}), cookies (\code{\link[httr:set_cookies]{set_cookies()}}) etc. +See \code{\link[httr:config]{config()}} for full details and list of helpers.} + \item{\code{body}}{One of the following: +\itemize{ +\item \code{FALSE}: No body. This is typically not used with \code{POST}, +\code{PUT}, or \code{PATCH}, but can be useful if you need to send a +bodyless request (like \code{GET}) with \code{VERB()}. +\item \code{NULL}: An empty body +\item \code{""}: A length 0 body +\item \code{upload_file("path/")}: The contents of a file. The mime +type will be guessed from the extension, or can be supplied explicitly +as the second argument to \code{upload_file()} +\item A character or raw vector: sent as is in body. Use +\code{\link[httr:content_type]{content_type()}} to tell the server what sort of data +you are sending. +\item A named list: See details for encode. +}} + \item{\code{encode}}{If the body is a named list, how should it be encoded? Can be +one of form (application/x-www-form-urlencoded), multipart, +(multipart/form-data), or json (application/json). + +For "multipart", list elements can be strings or objects created by +\code{\link[httr:upload_file]{upload_file()}}. For "form", elements are coerced to strings +and escaped, use \code{I()} to prevent double-escaping. For "json", +parameters are automatically "unboxed" (i.e. length 1 vectors are +converted to scalars). To preserve a length 1 vector as a vector, +wrap in \code{I()}. For "raw", either a character or raw vector. You'll +need to make sure to set the \code{\link[httr:content_type]{content_type()}} yourself.} + \item{\code{handle}}{The handle to use with this request. If not +supplied, will be retrieved and reused from the \code{\link[httr:handle_pool]{handle_pool()}} +based on the scheme, hostname and port of the url. By default \pkg{httr} +requests to the same scheme/host/port combo. This substantially reduces +connection time, and ensures that cookies are maintained over multiple +requests to the same host. See \code{\link[httr:handle_pool]{handle_pool()}} for more +details.} + }} } \value{ Downloaded full wikidata objects (items or properties) formatted From 4432fb6bc79e58567eef8e916b1df974a835e173 Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 13 Jun 2025 08:28:58 -0400 Subject: [PATCH 5/5] fix remaining notes --- DESCRIPTION | 1 + NAMESPACE | 1 + R/WikidataR-package.R | 21 +++++++++++---------- R/writes.R | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bbf168b..07308e8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -34,6 +34,7 @@ Imports: stats, readr, crayon, + tidyr, utils Suggests: markdown, diff --git a/NAMESPACE b/NAMESPACE index c8f0685..07d64e3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -52,6 +52,7 @@ importFrom(WikipediR,page_content) importFrom(WikipediR,query) importFrom(WikipediR,random_page) importFrom(dplyr,bind_cols) +importFrom(httr,POST) importFrom(httr,user_agent) importFrom(jsonlite,fromJSON) importFrom(readr,format_delim) diff --git a/R/WikidataR-package.R b/R/WikidataR-package.R index 164a0d1..7c0d252 100644 --- a/R/WikidataR-package.R +++ b/R/WikidataR-package.R @@ -9,21 +9,22 @@ "_PACKAGE" ## usethis namespace: start -#' @import WikidataQueryServiceR -#' @import tibble +#' @import crayon #' @import dplyr -#' @import stringr #' @import pbapply #' @import progress -#' @import crayon +#' @import stringr +#' @import tibble #' @import utils -#' @importFrom readr format_tsv -#' @importFrom readr format_delim +#' @import WikidataQueryServiceR #' @importFrom dplyr bind_cols -#' @importFrom stats var -#' @importFrom stats cor -#' @importFrom WikipediR page_content random_page query +#' @importFrom httr POST #' @importFrom httr user_agent #' @importFrom jsonlite fromJSON +#' @importFrom readr format_delim +#' @importFrom readr format_tsv +#' @importFrom stats cor +#' @importFrom stats var +#' @importFrom WikipediR page_content random_page query ## usethis namespace: end -NULL \ No newline at end of file +NULL diff --git a/R/writes.R b/R/writes.R index 87097ad..764156a 100644 --- a/R/writes.R +++ b/R/writes.R @@ -217,7 +217,7 @@ write_wikidata <- function(items, # remove any impossible rows (value is NA) if(nrow(QS.tib)!=1){ QS.tib <- QS.tib[!is.na(QS.tib$Value),] - QS.tib <- as_tibble(apply(QS.tib,2,replace_na,"")) + QS.tib <- as_tibble(apply(QS.tib,2,tidyr::replace_na,"")) } # format up the output