-
Notifications
You must be signed in to change notification settings - Fork 10
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
Line break before function() provoke unexpected problem #142
Milestone
Comments
statnmap
added a commit
that referenced
this issue
Apr 29, 2022
Why? - Some may name their functions on multiple lines What? - Modifiy test flat file and fix the inflate function issue #142
Problem: Proposal: |
FlorenceMounier
added a commit
that referenced
this issue
Nov 23, 2022
tags: fix Why? When adding a line break between the affectation sign and the function keyword, fusen does not handle correctly the flat file content. What? - Create a new test-template Rmd file in "inst/tests-templates" that produces this bug with `inflate()` and other examples that should still work after parse_fun() modification - Add a new unit test in "tests/testthat/test-inflate-part2.R" that runs the new test-template and test the proper inflate() of the functions from the template - Modify parse_fun() to read properly the name of the function with linebreaks and comments Issue #142
FlorenceMounier
added a commit
that referenced
this issue
Nov 28, 2022
tags : fix Why? a flat file may contain empty chunks labelled as "function" What? return NA when no function is recognized Issue #142
FlorenceMounier
added a commit
that referenced
this issue
Nov 28, 2022
16 tasks
FlorenceMounier
added a commit
that referenced
this issue
Nov 30, 2022
tags: test, fix Why? - test if examples and tests are condidered properly with linebreaks after function name What? - add examples and tests in two functions from the template, with no @, with @export, with @nord because it changes the outputs of inflate() - add tests in test-inflate-part2.R for /man and /test in progress: the examples are not in the right place in the .R files Issue #142
FlorenceMounier
added a commit
that referenced
this issue
Dec 12, 2022
tags: tests Why? make sure examples are present/absent when expected with all the different syntaxes from dev-template-tests.Rmd What? check the presence in the right place or absence of examples for some functions from dev-template-tests.Rmd Issue #142
FlorenceMounier
added a commit
that referenced
this issue
Dec 12, 2022
tags: test, fix Why? tests failed for the place of examples in .R What? try to fix how example_pos_start and example_pos_end are computed from parse_fun(), they are then used in add_fun_code_examples() in progress: example is fixed for 2nd and 3rd function but not for 1st with no Issue #142
statnmap
added a commit
that referenced
this issue
Feb 18, 2023
tags: feat, test Why? - Dealing with multi-lines functions writing is complex. A another way of exploration is to use `parse()` to get rid of comments and extra line breaks, which reduces the number of cases to deal with. What? - Get back to original version of `parse_fun()`. - Use `parse(text = code)` to deal with first function and extract fun_name - This breaks the "empty" chunks tests examples but this should be easier to deal with. issue #142
statnmap
added a commit
that referenced
this issue
Feb 19, 2023
tags: fix, test Why? - New way of dealing with multilines broke the deal with empty chunks and data chunks What? - Change the order of if() to account for special cases before function cases issue #142
That should be good now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Criteria of validation
All the below cases are tested with a specific flat test file: https://github.com/ThinkR-open/fusen/blob/main/inst/tests-templates/dev-template-function-name-linebreak.Rmd
The use of the following codes in a flat file do not affect the correct detection of the function real name :
Technical
Proposition 1 : detect the 1st assignment arrow in the code that is not in a comment or a roxygen
Propostion 2 : combine the line above in paste(line_before, line). A line break turns into a space, and there is no risk of catching a different name
parse_fun()
, which uses this regex for each single line:fusen/R/inflate-utils.R
Line 18 in bc84590
Problem description
When adding a line break between the affectation sign and the
function
keyword, fusen does not handle correctly the flat file content.fusen shows warning messages that alerts the user :
In the output, the vignette is created as expected but the .R file has the name of the makdown title above the function description in the flat file.
Reprex
Working example
I use a minimal flat file with the following function description and example (no test) :
When inflating, we have : a debug_fusen.R file in R\ and a vignette corresponding to the vignette_name attribute in the fusen::inflate() call.
Not working example
The same cas as below, with the simple addition of a line break before function :
When doing the inflate, we have :
The text was updated successfully, but these errors were encountered: