Cinderella-Man / hands-on-elixir-and-otp-cryptocurrency-trading-bot

Source code to generate the "Hands-on Elixir & OTP: Cryptocurrency trading bot" book
https://elixircryptobot.com
262 stars 34 forks source link

Building Rmd files in RStudio fails, three chapters has misformatted backticks #39

Closed kamidev closed 2 months ago

kamidev commented 2 months ago

Hi! Great to see that you are updating this book, it's a really good Elixir resource.

The Rmd files for Chapter 17, 21 and 23 has a handful of misformatted backticks (initial space). This breaks building the book from scratch with RStudio and Bookdown:

processing file: hands-on-elixir-and-otp-cryptocurrency-trading-bot.Rmd
Error: The closing fence on line 8269 ("``` ") in hands-on-elixir-and-otp-cryptocurrency-trading-bot.Rmd does not match the opening fence " ```" on line 8262. You are recommended to fix either the opening or closing fence of the code chunk to use exactly the same numbers of backticks and same level of indentation (or blockquote). See https://yihui.org/en/2021/10/unbalanced-delimiters/ for more info.
Execution halted

Fixing the Rmd files is trivial, the errors are clearly visible in RStudio. But since the generated "docs" folder is commited with changes, I didn't send a PR. Perhaps that is just temporary?

Anyway, here are the fixes I made to make building from scrach work again:

--- a/17-mox-rocks.Rmd
+++ b/17-mox-rocks.Rmd
@@ -268,7 +268,7 @@ We are moving on to the configuration. As the `Naive.Leader` wasn't part of the

 First, let's add the `:leader` key inside the `config :naive` in the default `/config/config.exs` configuration file:

- ```{r, engine = 'elixir', eval = FALSE}
+```{r, engine = 'elixir', eval = FALSE}
 # /config/config.exs
 ...
 config :naive,
@@ -279,7 +279,7 @@ config :naive,

 and then we need to apply the same update to the `/config/test.exs` configuration file(it will point to the module generated by the `mox` package - `Test.Naive.LeaderMock`):

-  ```{r, engine = 'elixir', eval = FALSE}
+```{r, engine = 'elixir', eval = FALSE}
 # /config/test.exs
 ...
 config :naive,
@@ -347,7 +347,7 @@ In the above code, we've told the `mox` package to define the `Test.PubSubMock`

 The final step will be to append the `:core, :pubsub_client` configuration to the `/config/config.exs` file:

- ```{r, engine = 'elixir', eval = FALSE}
+```{r, engine = 'elixir', eval = FALSE}
 # /config/config.exs
 config :core,                  # <= added
   pubsub_client: Phoenix.PubSub # <= added
@@ -355,7 +355,7 @@ config :core,                  # <= added

 and the test `/config/test.exs` configuration file:

-  ```{r, engine = 'elixir', eval = FALSE}
+```{r, engine = 'elixir', eval = FALSE}
 # /config/test.exs
 config :core,                  # <= added
   pubsub_client: Test.PubSubMock # <= added
diff --git a/21-layers-of-abstraction.Rmd b/21-layers-of-abstraction.Rmd
index 12277fa..41d94d3 100644
--- a/21-layers-of-abstraction.Rmd
+++ b/21-layers-of-abstraction.Rmd
@@ -522,7 +522,7 @@ As the behaviour's interface(public functions) differs from the `Binance` module

 As of now, we will deal only with the `Exchange.Order` structs instead a pair of `Binance.OrderResponse` and `Binance.Order`, we can simplify the existing two clauses of `broadcast_order/1` into a single one(and remove the `convert_to_order/1` function):

- ```{r, engine = 'elixir', eval = FALSE}
+```{r, engine = 'elixir', eval = FALSE}
   # /apps/naive/lib/naive/strategy.ex
   defp broadcast_order(%Exchange.Order{} = order) do
     @pubsub_client.broadcast(
Cinderella-Man commented 2 months ago

Hello,

Thank you very much for raising this issue and it's awesome to hear that you appreciate the updates and see value in the book :rocket:

In regards to the backticks problem, after reading this issue, I updated all the places where additional space was occurring.

What's strange for me is that my RStudio has no issue with compiling the book - I had an old version(2023.12.1+402) and updated to a new one(2024.04.2+764) thinking that this could be an issue in the new version - nope, it's all still fine with those spaces being there.

Either way I applied the fix as maybe I'm blessed somehow :wink:

Thank you once again taking time to report this and reading the book!

kamidev commented 2 months ago

My, that was quick! Thanks for the update, it works right away now.

For the record, I build on macOS 14.5. Installed and downloaded the latest R, RStudio and MacTex installers today and used the latest Bookdown plugin. No idea why my setup is more sensitive to this issue, though.

Cinderella-Man commented 2 months ago

Thank you for confirming that building works for you now. I have very different setup - Ubuntu and RStudio installed by a deb package. In regards to plugins they can be quite old.

Either way, it works now for more people so I'm happy - that wouldn't be possible without people like you - thanks! :pray: