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

Extend examples and see also of sprintf_format function #269

Closed
wants to merge 13 commits into from

Conversation

martincadek
Copy link
Contributor

@martincadek martincadek added documentation Improvements or additions to documentation sme Tracks changes for the sme board labels Mar 15, 2024
@martincadek martincadek self-assigned this Mar 15, 2024
Copy link
Contributor

github-actions bot commented Mar 15, 2024

badge

Code Coverage Summary

Filename             Stmts    Miss  Cover    Missing
-----------------  -------  ------  -------  -------------------------------------------------------------------------------------------------------------------------------------------
R/format_value.R       194      12  93.81%   88, 104-111, 194, 306, 406, 417, 425
R/generics.R           105       7  93.33%   454, 466, 499, 528, 652-658
R/labels.R              55       7  87.27%   49, 55, 64, 105, 133, 142, 146
R/matrix_form.R        552      50  90.94%   103, 455-456, 544, 557-560, 579, 611, 705-706, 721-726, 756-759, 792-793, 825-826, 870, 1033, 1057-1079, 1121, 1172, 1175, 1179
R/mpf_exporters.R      238      19  92.02%   2, 90-92, 201, 241, 246, 429, 432, 438-441, 479, 551-554, 567
R/page_size.R           45       1  97.78%   172
R/pagination.R         634      49  92.27%   250, 302-305, 407-420, 582, 765-766, 787-797, 1000-1016, 1148, 1155, 1362-1363, 1375-1376, 1390-1391
R/tostring.R           586      49  91.64%   41, 93, 162, 196, 204, 240, 297-300, 393-397, 400-403, 410-415, 492, 631-632, 697-704, 761-765, 849, 864, 958, 1010, 1051, 1096, 1151, 1158
R/utils.R                3       0  100.00%
R/zzz.R                 17       6  64.71%   29-34
TOTAL                 2429     200  91.77%

Diff against main

Filename      Stmts    Miss  Cover
----------  -------  ------  --------
TOTAL             0       0  +100.00%

Results for commit: ba13221

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

github-actions bot commented Mar 15, 2024

Unit Tests Summary

  1 files    5 suites   9s ⏱️
 43 tests  43 ✅ 0 💤 0 ❌
295 runs  295 ✅ 0 💤 0 ❌

Results for commit ba13221.

♻️ This comment has been updated with latest results.

@martincadek
Copy link
Contributor Author

Check fails at library load which is required for the example.
> library(rtables)
Error in library(rtables) : there is no package called ‘rtables’

I believe the formatters won't import the package but I'll do further tests. If I am not able to use rtables I will use \dontrun{} wrapper.

In addition, this part of the issue is somewhat unclear to me 'It is also necessary imo to have a short explanation at the end of function call list_valid_format* that explains the possibility to use dynamic function calls to set the format.'. The function list_valid_format_labels states "Currently valid format labels can not be added dynamically." Can you please provide what would you suggest adding @Melkiades. Thank you!

@Melkiades Melkiades marked this pull request as draft March 15, 2024 14:24
@Melkiades
Copy link
Contributor

Check fails at library load which is required for the example. > library(rtables) Error in library(rtables) : there is no package called ‘rtables’

I believe the formatters won't import the package but I'll do further tests. If I am not able to use rtables I will use \dontrun{} wrapper.

Do not use rtables from formatters as it would result in circular dependencies

In addition, this part of the issue is somewhat unclear to me 'It is also necessary imo to have a short explanation at the end of function call list_valid_format* that explains the possibility to use dynamic function calls to set the format.'. The function list_valid_format_labels states "Currently valid format labels can not be added dynamically." Can you please provide what would you suggest adding @Melkiades. Thank you!

This issue needs to have documentation for the various sprintf and round formats that we added or can add when format is a function. Indeed, you can use this to change everything that is printed out and we lack documentation for this powerful feature

R/format_value.R Outdated Show resolved Hide resolved
Copy link
Contributor

@Melkiades Melkiades left a comment

Choose a reason for hiding this comment

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

We need to add information about the various possible formats in ?list_valid_format_labels() and in {rtables} with a looot of examples. If you do ?rtables::analyze you will find the format parameter defined as such:

format | FormatSpec. Format associated with this split. Formats can be declared via strings ("xx.x") or function. In cases such as analyze calls, they can character vectors or lists of functions.

But as you can see there are no links to other docs or functions that lists useful formats. We should enhance the network of @seealso by adding these info in a common place (I would opt for ?list_formats) that is linked from many {rtables} functions (the one that have format as argument ideally, while list_formats keeps connection to other formatting functions. Final examples (not to have circular deps) should live in a dedicated vignette in {rtables} along with the format handling/precedence

R/format_value.R Outdated Show resolved Hide resolved
@Melkiades
Copy link
Contributor

@martincadek remember to run the styler from rstudio, so you avoid having annoying lintr issues ;)

@martincadek
Copy link
Contributor Author

Thank you for the reviews so far - working on this to have it resolved today.

Copy link
Contributor

github-actions bot commented Mar 25, 2024

CLA Assistant Lite bot ✅ All contributors have signed the CLA

@martincadek
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@martincadek martincadek marked this pull request as ready for review March 25, 2024 19:21
R/format_value.R Outdated Show resolved Hide resolved
@martincadek martincadek requested a review from Melkiades March 26, 2024 13:42
@@ -119,14 +119,19 @@ check_aligns <- function(algn) {
#' @export
#' @return A formatting function which wraps and will apply the specified \code{printf} style format
#' string \code{format}.
#' @seealso \code{\link[base]{sprintf}}
#'
#' @seealso \code{\link[base]{sprintf}} [round_fmt()] \code{link{list_formats}}
Copy link
Contributor

Choose a reason for hiding this comment

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

@martincadek could you make it all [fnc()] please? Also can you go in the other functions and see that they have some good connection with this one? otherwise it remains difficult to reach

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there should also be a counterpart in {rtables} with links to these in some of the obscure description of parameters. All of this would make a nice extension of the current vignette on format precedence

@Melkiades
Copy link
Contributor

Closing this as outdated

@Melkiades Melkiades closed this Sep 25, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 25, 2024
@insights-engineering-bot insights-engineering-bot deleted the 141_docs_for_format_value@main branch September 29, 2024 03:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation sme Tracks changes for the sme board
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better documentation for function insertion in the format value (e.g. sprintf cooperation)
3 participants