Procházet zdrojové kódy

Gadget is now RegExplain and clean up things

tags/v0.2.0
Garrick Aden-Buie před 8 roky
rodič
revize
8860412d0d
7 změnil soubory, kde provedl 56 přidání a 28 odebrání
  1. +7
    -11
      R/regex_gadget.R
  2. +1
    -0
      R/regexplain-package.R
  3. +6
    -6
      Readme.Rmd
  4. +9
    -9
      Readme.md
  5. +16
    -0
      man/generate_help_ui.Rd
  6. +15
    -0
      man/get_templates.Rd
  7. +2
    -2
      man/regex_gadget.Rd

+ 7
- 11
R/regex_gadget.R Zobrazit soubor

#' regexplain gadget
#' RegExplain gadget
#' #'
#' @import miniUI #' @import miniUI
#' @import shiny #' @import shiny
shiny::includeCSS(system.file("styles", "style.css", package = "regexplain")), shiny::includeCSS(system.file("styles", "style.css", package = "regexplain")),
shiny::includeCSS(system.file("styles", "gadget.css", package = "regexplain")), shiny::includeCSS(system.file("styles", "gadget.css", package = "regexplain")),
gadgetTitleBar( gadgetTitleBar(
"regexplain",
"RegExplain",
right = miniTitleBarButton("done", "Send RegEx To Console", TRUE) right = miniTitleBarButton("done", "Send RegEx To Console", TRUE)
), ),
miniTabstripPanel( miniTabstripPanel(
label = HTML( label = HTML(
'<div style="font-size: 1.25rem;">', '<div style="font-size: 1.25rem;">',
'Option Groups: ', 'Option Groups: ',
'<span style="color: #337ab7;">regexplain</span>,',
'<span style="color: #5cb85c;">all</span>, ',
'<span style="color: #f0ad4e;">base only</span>',
'<span style="color: #337ab7;">RegExplain</span>,',
'<span style="color: #5cb85c;">All</span>, ',
'<span style="color: #f0ad4e;">Base only</span>',
'</div>' '</div>'
), ),
inline = TRUE, inline = TRUE,


# ---- Server - Tab - Help ---- # ---- Server - Tab - Help ----
HELP_DEFAULT_TEXT <- c( HELP_DEFAULT_TEXT <- c(
"<div id=\"welcome-to-regexplain\" class=\"section level3\">",
"<h3>Welcome to RegExplain</h3>", "<h3>Welcome to RegExplain</h3>",
"<p>If you’re new to regular expressions, one of the best places to start is <a href=\"http://stringr.tidyverse.org/articles/regular-expressions.html\">the regular expressions vignette</a> from <code>stringr</code>. The chapter on strings in <a href=\"http://r4ds.had.co.nz/strings.html\">R for Data Science</a> is also an excellent first resource.</p>", "<p>If you’re new to regular expressions, one of the best places to start is <a href=\"http://stringr.tidyverse.org/articles/regular-expressions.html\">the regular expressions vignette</a> from <code>stringr</code>. The chapter on strings in <a href=\"http://r4ds.had.co.nz/strings.html\">R for Data Science</a> is also an excellent first resource.</p>",
"<p><strong>Exploring or looking for a challenge?</strong> Click on <i>Try These Examples</i> to see what you can do with this addin.</p>", "<p><strong>Exploring or looking for a challenge?</strong> Click on <i>Try These Examples</i> to see what you can do with this addin.</p>",
"<div id=\"getting-started\" class=\"section level4\">",
"<h4>Getting Started</h4>", "<h4>Getting Started</h4>",
"<ul>", "<ul>",
"<li><p><i class=\"fa fa-file-text-o\"></i> Enter or edit the <strong>Text</strong> you want to search.</p></li>", "<li><p><i class=\"fa fa-file-text-o\"></i> Enter or edit the <strong>Text</strong> you want to search.</p></li>",
"<li><p><i class=\"fa fa-table\"></i> Test the <strong>Output</strong> of your regular expression with common functions, including <i>search and replace</i> functions.</p></li>", "<li><p><i class=\"fa fa-table\"></i> Test the <strong>Output</strong> of your regular expression with common functions, including <i>search and replace</i> functions.</p></li>",
"<li><p><i class=\"fa fa-support\"></i> Get <strong>Help</strong> and look up the regular expression syntax.</p></li>", "<li><p><i class=\"fa fa-support\"></i> Get <strong>Help</strong> and look up the regular expression syntax.</p></li>",
"</ul>", "</ul>",
"</div>",
"<div id=\"escaping-characters\" class=\"section level4\">",
"<h4>Escaping characters</h4>", "<h4>Escaping characters</h4>",
"<p>In order to store a backslash (<code>\\</code>) as a character in R, backslashes need to be escaped…with another backslash! To write a literal <code>\\</code> in an R character string, you need to actually store <code>&quot;\\\\&quot;</code>.</p>", "<p>In order to store a backslash (<code>\\</code>) as a character in R, backslashes need to be escaped…with another backslash! To write a literal <code>\\</code> in an R character string, you need to actually store <code>&quot;\\\\&quot;</code>.</p>",
"<p>In regular expressions, <code>\\w</code> stands for any alphabetical character, but to store it in a string in R you need <code>&quot;\\w&quot;</code>.</p>", "<p>In regular expressions, <code>\\w</code> stands for any alphabetical character, but to store it in a string in R you need <code>&quot;\\w&quot;</code>.</p>",
"<p>Inside <strong>RegExplain</strong>, however, standard regular expressions can be used so that you can easily copy patterns from other places. When you click on the <span class=\"btn btn-xs btn-primary\">Send RegEX to Console</span> button, the necessary extra <code>\\</code> will be included.</p>", "<p>Inside <strong>RegExplain</strong>, however, standard regular expressions can be used so that you can easily copy patterns from other places. When you click on the <span class=\"btn btn-xs btn-primary\">Send RegEX to Console</span> button, the necessary extra <code>\\</code> will be included.</p>",
"<p>An extra backslash is still needed to match a literal <code>\\</code> in standard regular expressions. This means that you will need to enter <code>\\\\</code> in the <strong>RegEx</strong> tab, and the output to R will be <code>&quot;\\\\\\\\&quot;</code>.</p>",
"</div>")
"<p>An extra backslash is still needed to match a literal <code>\\</code> in standard regular expressions. This means that you will need to enter <code>\\\\</code> in the <strong>RegEx</strong> tab, and the output to R will be <code>&quot;\\\\\\\\&quot;</code>.</p>"
)


source(system.file("shiny", "help_server.R", package = "regexplain"), local = TRUE) source(system.file("shiny", "help_server.R", package = "regexplain"), local = TRUE)



+ 1
- 0
R/regexplain-package.R Zobrazit soubor

#' @importFrom dplyr "%>%" mutate filter group_by summarize select #' @importFrom dplyr "%>%" mutate filter group_by summarize select
#' @importFrom utils getFromNamespace installed.packages packageVersion #' @importFrom utils getFromNamespace installed.packages packageVersion
#' @importFrom rlang .data
#' @keywords internal #' @keywords internal
"_PACKAGE" "_PACKAGE"

+ 6
- 6
Readme.Rmd Zobrazit soubor

--- ---
title: "regexplain"
title: "RegExplain"
output: github_document output: github_document
--- ---




#### Planned improvements #### Planned improvements


- Make better use of the opening view of **Help** tab to explain the gadget.
- **v0.1.6!** Make better use of the opening view of **Help** tab to explain the gadget.
Also add one or more additional tabs with an overview of regular expressions, Also add one or more additional tabs with an overview of regular expressions,
with links to R4DS and `vignette('regular-expressions', package = 'stringr')`. with links to R4DS and `vignette('regular-expressions', package = 'stringr')`.
Maybe also a **Try This** feature that sets the `text` and `pattern` with Maybe also a **Try This** feature that sets the `text` and `pattern` with
regex challenges (possibly borrowed from R4DS). regex challenges (possibly borrowed from R4DS).


- Add a global search option to the **Regex** tab. Groups would be lost, but I
can still highlight global matches.
- ~~Add a global search option to the **Regex** tab. Groups would be lost, but I
can still highlight global matches.~~


- Add "flavors" menu to **Regex** tab. Automatically sets options to common flavors.
Mainly for clarity when switching between "base"" style and "tidyverse/stringr" defaults.
- ~~Add "flavors" menu to **Regex** tab. Automatically sets options to common flavors.
Mainly for clarity when switching between "base"" style and "tidyverse/stringr" defaults.~~
- **Done in v0.1.5!** Add replacement functions somewhere. Maybe to **Output** tab with `g?sub` and - **Done in v0.1.5!** Add replacement functions somewhere. Maybe to **Output** tab with `g?sub` and
`str_replace(_all)?` as options with an additional "replacement" field that `str_replace(_all)?` as options with an additional "replacement" field that

+ 9
- 9
Readme.md Zobrazit soubor

regexplain
RegExplain
================ ================


<!-- [![packageversion](https://img.shields.io/github/description/v/gadenbuie/regexplain.svg)](commits/master) --> <!-- [![packageversion](https://img.shields.io/github/description/v/gadenbuie/regexplain.svg)](commits/master) -->
state and is being actively state and is being actively
developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/regexplain)](https://cran.r-project.org/package=regexplain) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/regexplain)](https://cran.r-project.org/package=regexplain)
<!-- [![Last-changedate](https://img.shields.io/badge/last%20change-2018--03--14-yellowgreen.svg)](/commits/master) -->
<!-- [![Last-changedate](https://img.shields.io/badge/last%20change-2018--03--21-yellowgreen.svg)](/commits/master) -->


<!-- Links --> <!-- Links -->




#### Planned improvements #### Planned improvements


- Make better use of the opening view of **Help** tab to explain the
gadget. Also add one or more additional tabs with an overview of
regular expressions, with links to R4DS and
- **v0.1.6\!** Make better use of the opening view of **Help** tab to
explain the gadget. Also add one or more additional tabs with an
overview of regular expressions, with links to R4DS and
`vignette('regular-expressions', package = 'stringr')`. Maybe also a `vignette('regular-expressions', package = 'stringr')`. Maybe also a
**Try This** feature that sets the `text` and `pattern` with regex **Try This** feature that sets the `text` and `pattern` with regex
challenges (possibly borrowed from R4DS). challenges (possibly borrowed from R4DS).


- Add a global search option to the **Regex** tab. Groups would be
lost, but I can still highlight global matches.
- ~~Add a global search option to the **Regex** tab. Groups would be
lost, but I can still highlight global matches.~~


- Add “flavors” menu to **Regex** tab. Automatically sets options to
- ~~Add “flavors” menu to **Regex** tab. Automatically sets options to
common flavors. Mainly for clarity when switching between “base”" common flavors. Mainly for clarity when switching between “base”"
style and “tidyverse/stringr” defaults.
style and “tidyverse/stringr” defaults.~~


- **Done in v0.1.5\!** Add replacement functions somewhere. Maybe to - **Done in v0.1.5\!** Add replacement functions somewhere. Maybe to
**Output** tab with `g?sub` and `str_replace(_all)?` as options with **Output** tab with `g?sub` and `str_replace(_all)?` as options with

+ 16
- 0
man/generate_help_ui.Rd Zobrazit soubor

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/help_ui.R
\name{generate_help_ui}
\alias{generate_help_ui}
\title{Generates Help Tab UI}
\usage{
generate_help_ui(cheatsheet_only = TRUE)
}
\arguments{
\item{cheatsheet_only}{If TRUE then returns just basic regex
explainer UI.}
}
\description{
Generates Help Tab UI
}
\keyword{internal}

+ 15
- 0
man/get_templates.Rd Zobrazit soubor

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regex_gadget.R
\name{get_templates}
\alias{get_templates}
\title{Loads Regex Pattern Templates}
\usage{
get_templates()
}
\description{
Sourced from \href{https://projects.lukehaas.me/regexhub}{Regex Hub}
and available at \url{https://github.com/lukehaas/RegexHub}. Copyright
Luke Haas licensed under the MIT license available at
\url{https://github.com/lukehaas/RegexHub/commit/3ab87b5a4fd2817b42e2e45dcf040d4f0164ea37}.
}
\keyword{internal}

+ 2
- 2
man/regex_gadget.Rd Zobrazit soubor

% Please edit documentation in R/regex_gadget.R % Please edit documentation in R/regex_gadget.R
\name{regex_gadget} \name{regex_gadget}
\alias{regex_gadget} \alias{regex_gadget}
\title{regexplain gadget}
\title{RegExplain gadget}
\usage{ \usage{
regex_gadget(text = NULL, start_page = if (is.null(text)) "Text" else regex_gadget(text = NULL, start_page = if (is.null(text)) "Text" else
"RegEx") "RegEx")
\code{"Output"}, or \code{"Help"}} \code{"Output"}, or \code{"Help"}}
} }
\description{ \description{
regexplain gadget
RegExplain gadget
} }

Načítá se…
Zrušit
Uložit