Skip to content

Refactor documentation and test nomenclature #1694

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

Merged
merged 22 commits into from
Jun 7, 2024

Conversation

olivroy
Copy link
Collaborator

@olivroy olivroy commented Jun 5, 2024

Sorry.. this got out of hand again. Please let me know if you agree with this. If not, I can send smaller separate PRs of the relevant bits!

TL;DR: The goal is basically to simplify the x() function to x() where applicable as recommended in the documentation tidyverse style guide. (only the function bullet)

This PR started as a follow-up to #1683 as I wanted to make clarifications and improved some things I did there after taking a fresh look.
cbb1dca and 018b232 do this. I finally discovered the way to avoid spurious (snapshot git diffs while working on Windows: Set Posix line ending in Rproj (13b2666). Used https://www.tidyverse.org/blog/2020/03/roxygen2-7-1-0/ as ref too.

I'd like to get your views on how I edited the shiny related functions docs 64e80b3. (I removed details that felt redundant? Let me know if you agree. Otherwise, I will rework it!

Changes

  • Renamed is_non_empty_string() to is_non_empty_chr() for clarity (accepts length > 1) e0c4a10 (string is usually for character + length = 1)

  • renamed tests to use the convention ab0ed09

  • Moved some test helper functions into own test helper files to improve testing workflow (i.e. functions are loaded with load_all() af9cdd6

  • Removed duplicate definition of test helper in tests/testthat/helper.R bcbb80d

  • Removed the check for xml2 installation since it is import now (I may do a follow-up where I remove check_suggests() with appropriate skip_if_not_installed() bcbb80d

  • Did minor test refactoring where I saw it useful bcbb80d

  • simplified some dplyr expressions in examples d2aa113, bc70cdb

I verified that they are all correct with this code

v1 <-  towny |>
     dplyr::select(name, csd_type, census_div, population_2021) |>
     dplyr::group_by(census_div) |>
     dplyr::summarize(
       population = sum(population_2021),
       .groups = "drop_last"
     ) |>
     dplyr::arrange(population) |>
     dplyr::slice_head(n = 5) |>
     dplyr::mutate(ranking = dplyr::row_number()) |>
     dplyr::select(ranking, dplyr::everything()) 
v2 <- towny |>
  dplyr::select(name, csd_type, census_div, population_2021) |>
  dplyr::group_by(census_div) |>
  dplyr::summarize(
    population = sum(population_2021),
    .groups = "drop_last"
  ) |>
  dplyr::slice_min(population, n = 5) |>
  dplyr::mutate(ranking = dplyr::row_number(), .before = 0) 

waldo::compare(
  v1, v2
)

Other considerations:

When I noticed it, avoid self-reference, and 2 cross-refs to the same function in the same paragrah.
The diff is large because I reflowed roxygen comments to be about 80 characters long.

@rich-iannone
Copy link
Member

This is monumental work! I am super impressed so far (and it's okay that this touches so many files, it has to).

@olivroy
Copy link
Collaborator Author

olivroy commented Jun 6, 2024

Thanks for your interest! I pushed another chunk of changes to go around rough edges.

@olivroy olivroy marked this pull request as ready for review June 6, 2024 20:41
@olivroy olivroy changed the title Refactor documentation and test nomenclature [wip] Refactor documentation and test nomenclature Jun 6, 2024
Copy link
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

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

LGTM!

@rich-iannone rich-iannone merged commit 7aaf3a6 into rstudio:master Jun 7, 2024
12 checks passed
@olivroy olivroy deleted the error-msg-follow branch June 7, 2024 17:52
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.

2 participants