Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for @examplesIf roxygen tag #743

Merged
merged 14 commits into from Mar 12, 2021
Merged

Conversation

krlmlr
Copy link
Member

@krlmlr krlmlr commented Mar 4, 2021

for #742. Ideally we'd add full support for @examplesIf, this gets us halfway. Not sure the final //s* is necessary.

Needs tests.


Here is how the current PR would change benchmark results when merged into master:

  • cache_applying: 0.03 -> 0.03 (-1.3%)
  • cache_recording: 1.19 -> 1.19 (-0.4%)
  • without_cache: 3.44 -> 3.46 (0.6%)

Here is how the current PR would change benchmark results when merged into master:

  • cache_applying: 0.03 -> 0.03 (-0.2%)
  • cache_recording: 0.88 -> 0.88 (0.2%)
  • without_cache: 2.57 -> 2.56 (-0.4%)

@lorenzwalthert

This comment has been minimized.

@codecov-io
Copy link

codecov-io commented Mar 4, 2021

Codecov Report

Merging #743 (c65e562) into master (179a85a) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #743      +/-   ##
==========================================
+ Coverage   90.53%   90.56%   +0.02%     
==========================================
  Files          47       47              
  Lines        2389     2395       +6     
==========================================
+ Hits         2163     2169       +6     
  Misses        226      226              
Impacted Files Coverage Δ
R/roxygen-examples-add-remove.R 92.30% <100.00%> (-1.03%) ⬇️
R/roxygen-examples-find.R 100.00% <100.00%> (ø)
R/roxygen-examples-parse.R 96.66% <100.00%> (+0.51%) ⬆️
R/roxygen-examples.R 97.91% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 179a85a...c65e562. Read the comment docs.

@lorenzwalthert lorenzwalthert changed the title Refine regex Support for @exampleIf roxygen tag Mar 11, 2021
@lorenzwalthert lorenzwalthert changed the title Support for @exampleIf roxygen tag Support for @examplesIf roxygen tag Mar 11, 2021
@lorenzwalthert
Copy link
Collaborator

@krlmlr you can try this if you want, should work now. Maybe have a look at the test cases too and tell me if we miss anything...

Copy link
Member Author

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the effort! I didn't review all the examples, will file new issues if anything breaks in practice.

@@ -30,15 +30,29 @@ remove_roxygen_mask <- function(text) {
#' @keywords internal
remove_roxygen_header <- function(text) {
text <- gsub("^\\s*@examples\\s*", "", text, perl = TRUE)
starts_with_blank <- text[1] == "\n"
c(text[1][!starts_with_blank], text[-1])
if (grepl("^If ", text[1])) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches @examples If . Just sayin...

Can you use the regex from https://github.com/r-lib/styler/pull/743/files#diff-73645d1e1e747d5eeb45cbd47ddb2ef64c658ed5c585763efd004a1b08ba61f9R10, perhaps with rematch2 and a grouped match?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I didn't ever figure out how to use {rematch2} (and did not bother spending time), maybe I should... For now, I think using the regex you linked should be sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants