tcoopman

tcoopman

Mix format doesn't format docs

It looks like mix format doesn’t format documentation, for example a very long line is not splitted over a new line. Is this a bug, or is documentation formating out of scope for format?

Thanks.

Most Liked

mudasobwa

mudasobwa

Creator of Cure

The formatter supports plugins and there is one to format docs.

OvermindDL1

OvermindDL1

The AST of those are different though, which the formatter absolutely, positively, should NOT ever change:

iex> a1 = quote do """
This is a very long explanation of a function that is longer than the default length of 98 characters and so I would have expected it to be split on different lines like the same sentence below this one.
""" end
"This is a very long explanation of a function that is longer than the default length of 98 characters and so I would have expected it to be split on different lines like the same sentence below this one."

iex> a2 = quote do """
This is a very long explanation of a function that is longer than the default length of 98 characters and 
so I would have expected it to be split on different lines like this example.
""" end
"This is a very long explanation of a function that is longer than the default length of 98 characters and \nso I would have expected it to be split on different lines like the same sentence below this one."

iex> a1 == a2
false

Not only is the AST different, the string itself is different! A formatter should not change user specified strings! It could easily break things, say like documentation, or an embedded macro language. I’d argue it’s the job of the IDE to wrap long strings visually.

NobbZ

NobbZ

The formatter is dumb, it does not know if the string it sees is ordinary code or documentation. Changing it in any way might result in broken output if it is regular code, therefore string literals are not touched.

Last Post!

raulrpearson

raulrpearson

epic, thank you!

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement