-
-
Notifications
You must be signed in to change notification settings - Fork 877
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
Implement sass / scss engines #1666
Conversation
Let me know if I should go ahead and change the logic to use the I noticed lines 210-211 contain a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comment to discuss.
Also, I have a behaviour rather strange that we should cover.
I installed sass executable on my Windows. Something was not correct and it does not work. So I should have error printing but nothing. Instead, sass.exe
does not error because the cmd
works, but the conversion does not happen and it sends as output the error message. So following your code, in out
I got
'dart.exe' n'est pas reconnu en tant que commande interne
ou externe, un programme ex‚cutable ou un fichier de commandes.
and as it is not an error, I get in my rendered html
<style type="text/css">
'dart.exe' n'est pas reconnu en tant que commande interne
ou externe, un programme ex‚cutable ou un fichier de commandes.
</style>
The html does open but I don't think this something desirable.
We should instead find a way to catch the error message from saas
executable. I think with system2()
, we should test that returned value has not a status error code. (see ?system2
) with xfun::attr(out, "status")
.
I don't know if you have the same not on windows.
As a general comment also, this need some documentation, maybe first as a bullet point in NEWS.
Thanks @cderv for the review! And apologies -- there are definitely a few things in there that you shouldn't have had to catch. A few follow-up questions:
Per the last comment, I'll also include an updated |
Just a quick reply as it is late but that will keep you going
Do not force push as it is not necessary. When we can avoid I think it is better. We will deal with that later. You can add more commits to this branch. We should be able to "squash and merge" the PR, in order to reduce the amount of commit. Or I'll deal myself with git stuff at the end - I am knew as a reviewer for this 📦, so we both learn in the process 😄
If you want to try add this, feel free. I don't think
Don't worry about |
Thanks for taking the time to reply!
The
Yes! Both versions can handle it.
Thanks - that's a good point. It really does make more sense for this to be an engine option than a chunk option. I'll update this in the code before pushing my new commits. |
I let you push your changes and we'll see what default to choose. 🤔 |
Hi @cderv , I just pushed a number of changes. Let me know what you think! I'm still not sure if I love the API for output styling, so definitely open to more feedback here. In the end I considered four options. Happy to switch if you think one of the others is better.
Most readable / typeable but felt "aggressive" somehow to add a new chunk option for something so specialized.
Feels weird to not have the option labeled "style" in anyway, but that is also unneeded since there is only one option. This felt most in keeping with the main usage of
Most explicit but also unnecessarily verbose.
Most compact but no longer follows same convention as On an unrelated note, there are a lot of degrees of freedom now with two engines, possible options, and different types of warnings / errors. I haven't included tests in the PR as I notice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have still made a few comment, specifically on the error and warning catching. I think we should reproduce more closely eng_interpreted
. I let you read those and see. If you want me to add some commit on this one, as I have the dart.exe
error to test, please tell me.
About the style API, I agree with you it could be improved. one thing is we want the option to work for both package and executable sass. So we can't have a TRUE vs FALSE, if the package have more option for styling.
The cleaner API would be the first : sass.package
and sass.style
chunk option. The more close to knitr current behavior would be the last, as engine.opts
. Some knit engine works that way.
interpreted engine use engine.opts
as a way to provide additional command line options. Some others use it to pass engine specific options. (like tikz)
I guess both are okay, it just need some documentation or examples. Mixing both option as of now may be a bit too complicated for little gain.
On an unrelated note, there are a lot of degrees of freedom now with two engines, possible options, and different types of warnings / errors. I haven't included tests in the PR as I notice
knitr
doesn't have them for most engines (and, of course, the set-up on Travis is non-trivial). That said, if it would ease your job for me to share tests (either through the PR or as an attachment?), please just let me know how you'd like me to send.
knitr 📦 has a very specific workflow for tests. the integration test (among them engines) are done using knitr_example repo. All the file in this repo is reknit each time a travis build is done. Pretty clever, but also a not-so-simple workflow 😄
To test the sxss engine, it would require a new file in the repo (could be a way to add documentation too) and some adjustment in travis to get the executable. I think we could do that afterward - I can work on the integration and you could work on the example file (that you may already have). Will see as soon as we are ok on this PR.
Hi @cderv, I've just pushed a number of updates:
While these aren't "official" tests or in the style of At minimum, hopefully this restores a bit of confidence after I know I've made some pretty stupid mistakes; I'm very grateful for your help and patience! |
R/engine.R
Outdated
|
||
# validate provided engine options | ||
if(!is.logical(package)) { | ||
if(!options$error) stop(paste("package option must be either TRUE or FALSE")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you used warning2
below 👍 (I did not know it)
Should we use stop2
also here ? The wrapper with call. = FALSE
.
As you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! Very nice. I hadn't noticed that wrapper as much in the other engines, but I like it. I will switch over. Thanks for the recommendation!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much !!
This was not a small PR and it is really good! Thanks a lot ! You did an awesome job all along.
This is working with my error now, and your test file is awesome. It could be added in in the test folder, but it is using testit
and not testthat
. But the file was useful to check this PR. Thank you !
I just pushed a small commit to be closer to knit internal code style.
Also, I left 2 small comments. It is more like question I let you deal with.
After you give me an answer, I will merge it.
Thanks again !
R/engine.R
Outdated
|
||
# wrap final output for correct rendering | ||
final_out = if (!is.null(out) && is_html_output(excludes = 'markdown')) { | ||
out_tagged = paste(c('<style type="text/css">', out, '</style>'), collapse = "\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is out_tagged
? it does not seem to be used.
Did I miss something ? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for catching. You didn't -- I did. Previously I had more validation steps after this, but it appears I failed to remove this assignment when I took those out.
Hi @cderv , Thanks for the last polishing thoughts! I switched to Please let me know if there's anything else I should do on my end, like eventually adding examples to the Thank you again so, so much for your help and great feedback at every step of the way! |
Awesome thank you ! I'll need to check if I missed anything in the process. It is my first review for knitr 📦 and first time merging - I'll do it very soon. I will also add you as contributor to the 📦 in DESCRIPTION. |
@yihui, review is done. and this is working well. Just checking how you get things done usually. From what I observed until now
Is this ready to squash and merge ? As it is my first review for knitr, I prefer to go through this time to learn the workflow for this 📦 and be at ease next time Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks great. Please go ahead and make your first merge in this repo! 🎉 Thank you both!
@emilyriederer Next time please feel free to use <-
if you struggle with =
. I'll change it by myself after the PR is merged.
@@ -136,7 +136,7 @@ eng_interpreted = function(options) { | |||
Darwin = paste('-q < %s >', shQuote(xfun::normalize_path(logf))), | |||
Linux = '-q -e do %s', | |||
'-q -b do %s' | |||
), shQuote(normalizePath(f))) | |||
), shQuote(normalizePath(f))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good eye. Thanks!
Thanks, @yihui! And don't worry -- I was just joking, not complaining, about Thanks again to you both! |
This PR closes #1665 and adds Sass / SCSS language engines.
When available and not specifically declined by the user (via an
r.sass = FALSE
chunk option), conversion is handled by LibSass via thesass
R package. Otherwise, conversion is done by the standalone DartSass executable found either via PATH or provided via theengine.path
option.Following conversion, output is handled the same as in the
css
language engine.