pharmaverse / pharmaverse/formatters
Follow-up to wrapper refactoring
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 20
- Forks
- 8
- Avg merge
- 12h 28m
- Merged PRs (30d)
- 1
Description
btw for the reviewers @edelarua @ayogasekaram: 250+ line additions are simply comments, missing documentation, and missing tests. There were NO direct tests of the wrapping, hence imo the source of multiple problems and bugs downstream. Nonetheless, the wrapping algorithm now is entirely new and it has nothing shared with the old method. I kept wrap_txt for no other reason than the deprecation cycle. The indentation is as before removed and reinserted but now it is all self-contained in specific helper functions that have indentation checks that are a bit more formal than before. The indentation fixes were introduced by me when the wrapping went live and completely broke the indentation because base::strwrap destroys empty spaces. Now empty spaces are supported and they are destroyed only when trailing on a string that needs to be split because too long. Otherwise, they are kept as if they are a word (e.g. if you have " " (3 times \s), then it is considered as one word made of one white space). Failures related to \n need to be resolved in a separate PR as this is specifically related to wrap_string and toString refactoring while the \n solution needs to happen in matrix_form. In other words, here what it is missing from this refactoring that needs to touch other functions:
- #208 Special characters (
\nand\t, for example) need to be resolved before going intotoString(i.e. inmatrix_form) - top left material needs to be better handled by
matrix_form: indentation and wrapping are broken there and do not cooperate well with column names (which should be always top, I think - we can discuss this) -
tf_wrapandmax_widthare overlapping parameters that should be merged into one (withif (!is.null(max_width))) -
widthsandcolwidthsare two parameters that do the same but there is no reason to keep them separate - more examples and vignette
- Found downstream 3 exceptions to be handled more uniformly -> 1. ContentRows with no labels, 2.
rtables::rtable()with no content does havemf_rinfoas null, 3. cases where input widths are 0 0 0
Originally posted by @Melkiades in https://github.com/insightsengineering/formatters/issues/203#issuecomment-1744686341
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the wrapping-related entry points named in the issue: wrap_string, toString, matrix_form, tf_wrap, max_width, widths, and colwidths. Review the existing wrapping tests, then define the parameter consolidation, examples and vignette updates, and the three downstream exceptions as separate completion checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100