Skip to content

Commit

Permalink
Add grep search (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
coatless authored Feb 4, 2024
1 parent e1edd26 commit 7578e23
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BugReports: https://github.com/coatless-rpkg/searcher/issues
Depends: R (>= 3.3.0)
License: GPL (>= 2)
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Suggests:
testthat (>= 2.1.0),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export(search_ecosia)
export(search_gh)
export(search_github)
export(search_google)
export(search_grep)
export(search_ixquick)
export(search_rscom)
export(search_rseek)
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# searcher 0.0.7

## Features

- Added search portal:
- `search_grep()`: Searches on grep.app.
([#35](https://github.com/r-assist/searcher/issues/35),
[#37](https://github.com/r-assist/searcher/pull/37))


# searcher 0.0.6

## Features
Expand Down
2 changes: 2 additions & 0 deletions R/index-sites.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ site_index =
list(
site_entry("google", "https://google.com/search?q="),
site_entry("bing", "https://bing.com/search?q="),
site_entry("grep", "https://grep.app/search?q=",
keywords = keyword_entry("&filter[lang][0]=R")),
site_entry("duckduckgo", "https://duckduckgo.com/?q=", "ddg"),
site_entry("startpage", "https://startpage.com/do/dsearch?query=", "sp"),
site_entry("ecosia", "https://www.ecosia.org/search?q="),
Expand Down
18 changes: 17 additions & 1 deletion R/search-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @seealso [search_google()], [search_bing()], [search_duckduckgo()],
#' [search_startpage()], [search_rseek()], [search_twitter()],
#' [search_rstudio_community()], [search_stackoverflow()],
#' [search_github()], [search_bitbucket()], and [searcher()]
#' [search_github()], [search_grep()], [search_bitbucket()], and [searcher()]
#' @examples
#' # Search in a generic way
#' search_site("r-project", "google")
Expand Down Expand Up @@ -55,6 +55,12 @@
#' # Search all languages on GitHub Issues for bivariate normal
#' search_github("bivariate normal", rlang = FALSE)
#'
#' # Search R code on GitHub for numerical optimization
#' search_grep("optim")
#'
#' # Search all code on GitHub for numerical optimization
#' search_grep("optim", rlang = FALSE)
#'
#' # Search BitBucket for assertions
#' search_bitbucket("assertions")
#'
Expand All @@ -79,6 +85,7 @@ search_site = function(query,
"so",
"github",
"gh",
"grep",
"bitbucket",
"bb"
),
Expand All @@ -102,6 +109,7 @@ search_site = function(query,
so = search_stackoverflow(query, rlang),
github = , # empty case carried below
gh = search_github(query, rlang),
grep = search_grep(query, rlang),
bitbucket = , # empty case carried below
bb = search_bitbucket(query, rlang)
)
Expand Down Expand Up @@ -295,6 +303,14 @@ search_github = searcher("gh")
#' @export
search_gh = search_github

#' @rdname search_site
#' @export
#' @section grep.app Search:
#' The `search_grep()` function searches all public code on
#' [GitHub](https://github.com) using [grep.app](https://grep.app) by
#' querying: `https://grep.app/search?q=<query-here>&filter[lang][0]=R`
search_grep = searcher("grep")

#' @rdname search_site
#' @export
#' @section BitBucket Search:
Expand Down
11 changes: 8 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ The `search_*()` functions can be used to search a query directly from _R_ on
major search engines, programming help websites, and code repositories. The following search
platforms are supported: [Google](https://www.google.com), [Bing](https://www.bing.com/),
[DuckDuckGo](https://duckduckgo.com/), [Startpage](https://www.startpage.com/en/),
Ecosia, [rseek](https://rseek.org/),
[Twitter](https://twitter.com/search), [StackOverflow](https://stackoverflow.com/search),
Ecosia, [rseek](https://rseek.org/), [Twitter](https://twitter.com/search), [StackOverflow](https://stackoverflow.com/search),
[RStudio Community](https://community.rstudio.com/search),
[GitHub](https://github.com/search), and [BitBucket](https://bitbucket.org/product/).
[GitHub](https://github.com/search), [grep.app](https://grep.app/),
and [BitBucket](https://bitbucket.org/product/).
By default, an appropriate suffix for each platform that ensures relevant
results to _R_ is appended to all queries. This behavior can be disabled by
using `rlang = FALSE`.
Expand All @@ -93,6 +93,10 @@ search_stackoverflow("linear regression", rlang = FALSE) # or search_so(...)
search_rstudio_community("tips")
search_rstudio_community("tips", rlang = FALSE) # or search_rscom(...)

# Searching GitHub code for graphs in R and other languages
search_grep("graph")
search_grep("graph", rlang = FALSE)

# Searching GitHub Issues for maps in R and other languages
search_github("maps")
search_github("maps", rlang = FALSE) # or search_gh(...)
Expand Down Expand Up @@ -138,6 +142,7 @@ search_bing()
search_ecosia()
search_rseek()
search_twitter()
search_grep()
search_duckduckgo() # or search_ddg()
search_startpage() # or search_sp()
search_stackoverflow() # or search_so()
Expand Down
20 changes: 18 additions & 2 deletions man/search_site.Rd

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

1 change: 0 additions & 1 deletion man/searcher-package.Rd

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

0 comments on commit 7578e23

Please sign in to comment.