Skip to content

Add Livebook README - #2

Merged
msaraiva merged 6 commits into
msaraiva:masterfrom
tiagoefmoraes:livebook
Jan 17, 2022
Merged

Add Livebook README#2
msaraiva merged 6 commits into
msaraiva:masterfrom
tiagoefmoraes:livebook

Conversation

@tiagoefmoraes

@tiagoefmoraes tiagoefmoraes commented Jan 9, 2022

Copy link
Copy Markdown
Contributor

Includes a .livemd file to help with github-linguist/linguist#5672

Some samples didn't work with elixir 1.6+ so I did some yak shaving:

  • configured github actions to run in elixir 1.5 to 1.13
  • fixed the code for elixir 1.6+

Run in Livebook

If you evaluate the cells now some will fail because of the elixir version. To get all working change the code on Setup section to:

Mix.install([
  {:exsamples, github: "tiagoefmoraes/exsamples", branch: "livebook"}
])

And evaluate all cells with ea to check the outputs.

@msaraiva
msaraiva merged commit 010af38 into msaraiva:master Jan 17, 2022
@msaraiva

Copy link
Copy Markdown
Owner

Hey @tiagoefmoraes. Thanks for the PR!

For context, the reason I kind of abandoned this lib was due to the introduction of the elixir formatter a couple of years ago, which makes the tables look awful. However, I just saw this in Elxiir's CHANGELOG:

  * [mix format] Allow plugins to also format `.ex` and `.exs` files

As far as I understood, that means it would be possible now to use the new plugin API to take over the formatting of the samples do...end block. So I guess we can bring back this project to life :)

I always liked to use this approach in tests but now with Livebook, it might get even more useful ;)

@tiagoefmoraes

Copy link
Copy Markdown
Contributor Author

I had to disable formatting on samples do...end blocks,

I had a look if I could implement the formatter, but what I understood is that, right now, it only supports plugins for formating sigils or entire files. https://hexdocs.pm/mix/1.13.2/Mix.Tasks.Format.html#module-plugins

@tiagoefmoraes
tiagoefmoraes deleted the livebook branch January 17, 2022 22:28
@msaraiva

Copy link
Copy Markdown
Owner

it only supports plugins for formating sigils or entire files

Yes! The idea is to format the entire file by calling the built-in formatter first, which is available using format_string!/2, then replacing the samples do...end contents afterwards. This way we keep the default formatting and update only what we need.

@msaraiva

Copy link
Copy Markdown
Owner

@tiagoefmoraes I just added the formatter plugin! 😉

I'll add some docs later with instructions on how to set it up and then release a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants