beautifyR
beautifyR copied to clipboard
Beautify Comment: Keep `-` and don't break inline code
Hi, thanks for the great addin - I am using Beautify Comment on a regular basis. However, I find myself manually
- re-inserting
-
hyphens/dashes, because they are always removed - removing linebreaks to make inline code
r mean(c(1,2))
appear on a single line
Do you think there is a better way to handle these?
Hey @SchmidtPaul, glad to hear you like the addin. Could you provide one (or two) sample tables against which I could develop the fix?
Sure, but note I am talking about beautifying comments, not tables:
Here is a sample:
# This is my dash-dash word. And this right here is inline code `r mean(c(1,2))` that is
# separated into two lines when beautifying this comment.
which currently is being beautifyed into this:
# This is my dash dash word. And this right here is inline code `r
# mean(c(1,2))` that is separated into two lines when beautifying this
# comment.
Notice the missing -
and the linebreak within the inline code.
Thus, I would like it to be beautifyed to this instead:
# This is my dash-dash word. And this right here is inline code
# `r mean(c(1,2))` that is separated into two lines when beautifying
# this comment.
Sorry to bother you, but any news about this? I am still re-inserting all the dashes after beautifying my comments 😅
@SchmidtPaul, sorry for taking so long. Was busy with my thesis. I added two fixes to for this. I'd kindly ask you to test this. Maybe throw in some odd-balls, too. Once you confirm, I'll merge this.
Just install the patched version via
devtools::install_github("mwip/beautifyR", ref="dont_split_inline_code_and_dashes")
Thanks for your participation in this.
Thanks for taking the time!
So, the example from above works perfectly fine. However, I then tried this one here:
#' Bzgl. der Behandlungseffekte ist der Versuch prinzipiell 3 faktoriell, allerdings ist `Sorte` geschachtelt im Effekt `Typ`, da jede Sorte nur
#' genau zu einem Typ gehört und ein Sorten-übergreifender Effekt des Typs
#' explizit untersucht werden soll. Somit gibt es die festen Effekte
#' `Intensität`, `Saatzeit`, `Typ` und `Typ:Sorte` und all deren Wechselwirkungen. Bzgl. der Designeffekte werden alle oben genannten
#' Effekte als zufällig ins Modell aufgenommen: Wiederholung (`Wdh`),
#' Großteilstück (`GT`), Kleinteilstück (`KT`), und Doppelplot (`DP`).
and it was beautified to
#' Bzgl. der Behandlungseffekte ist der Versuch prinzipiell 3 faktoriell,
#' allerdings ist
#'
#' `Sorte` geschachtelt im Effekt `Typ`, da jede Sorte nur genau zu einem Typ gehört und ein Sorten-übergreifender Effekt des Typs explizit untersucht werden soll. Somit gibt es die festen Effekte `Intensität`, `Saatzeit`, `Typ`
#' und
#'
#' `Typ:Sorte` und all deren Wechselwirkungen. Bzgl. der Designeffekte werden alle oben genannten Effekte als zufällig ins Modell aufgenommen: Wiederholung (`Wdh`), Großteilstück (`GT`), Kleinteilstück (`KT`), und Doppelplot (`DP`).
which seems odd?! Can you replicate this? I mean the dash is still there 👍 But somehow linebreaks are inserted at the wrong positions?
Thanks for taking the time to test it, I really appreciate it. I did not have single words in back ticks in mind. I'll fix it and let you know in the next days. Hope you are up for another test.
I fixed it in 2cfbe07. Could you try again?
devtools::install_github("mwip/beautifyR", ref="dont_split_inline_code_and_dashes")
Yes, I tried out several comments and I think we can close this issue now. Thanks a lot!
Thank you for your patience and constructive criticism. Hope you enjoy working with beautifyR :+1:
Hey, somehow I stumbled across a case where it still doesn't work right?
Before
#' Sidenote: One can also use the `dispformula = ~ 0` argument to set the error
#' variance to 0. Technically it is not being set to exactly 0, but to a very
#' small value defined as `sqrt(.Machine$double.eps)` (find more on this
#' [here](https://github.com/glmmTMB/glmmTMB/issues/653) and [here](https://schmidtpaul.github.io/MMFAIR/glmmtmbdispformula0.html)). As a consequence,
#' this can be seen as an alternative way of formulating the model for the special case of setting
#' the error variance to 0. It was shown [here](https://github.com/glmmTMB/glmmTMB/issues/833#issuecomment-1182840849) that the resulting model is
#' indeed equivalent to fixing the error variance via the method shown above to
#' `start = list(betad = log(sqrt(.Machine$double.eps)))`.
After
#' Sidenote: One can also use the `dispformula = ~ 0` argument to set the
#' error variance to 0. Technically it is not being set to exactly 0, but to a
#' very small value defined as
#'
#' `sqrt(.Machine$double.eps)` (find more on this [here](https://github.com/glmmTMB/glmmTMB/issues/653) and [here](https://schmidtpaul.github.io/MMFAIR/glmmtmbdispformula0.html)). As a consequence, this can be seen as an alternative way of formulating the model for the special case of setting the error variance to 0. It was shown [here](https://github.com/glmmTMB/glmmTMB/issues/833#issuecomment-1182840849) that the resulting model is indeed equivalent to fixing the error variance via the method shown above to `start = list(betad = log(sqrt(.Machine$double.eps)))`.
Should be fixed. I am now using proper testing with testthat. Maybe you want to have a look at tests/testthat/test-beautifyComment.R
whether This is right. The latest example comment will now be beautified to:
#' Sidenote: One can also use the `dispformula = ~ 0` argument to set the
#' error variance to 0. Technically it is not being set to exactly 0, but to a
#' very small value defined as `sqrt(.Machine$double.eps)` (find more on this
#' [here](https://github.com/glmmTMB/glmmTMB/issues/653) and
#' [here](https://schmidtpaul.github.io/MMFAIR/glmmtmbdispformula0.html)). As
#' a consequence, this can be seen as an alternative way of formulating the
#' model for the special case of setting the error variance to 0. It was shown
#' [here](https://github.com/glmmTMB/glmmTMB/issues/833#issuecomment-1182840849)
#' that the resulting model is indeed equivalent to fixing the error variance
#' via the method shown above to
#' `start = list(betad = log(sqrt(.Machine$double.eps)))`.
Hope this is what you were looking for. And again, sorry for the late response.