-
Notifications
You must be signed in to change notification settings - Fork 356
Markdown formatter refactor #2181
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
base: main
Are you sure you want to change the base?
Conversation
|
📦 Docs artifacts are ready: https://github.com/elixir-lang/ex_doc/actions/runs/20901920771/artifacts/5091642515 |
|
Hi @milmazz! There are some other PRs and I have also refactored some of this code locally, so let's please hold on before merging this, unless there is a bug fix. :) |
| |> Enum.dedup() | ||
| |> Enum.intersperse("\n") | ||
|
|
||
| File.mkdir_p!(Path.dirname(build)) |
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.
Not needed because the config.output directory is always created in the output_setup private helper that is applied before this one.
| config.output | ||
| |> Path.join(filename) | ||
| |> File.write(content) |
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.
Please let me know if we should include a small private helper like:
defp write_content(config, filename, content) do
config.output
|> Path.join(filename)
|> File.write(content)
endBecause this is repeated a few times in this module.
| Enum.map(nodes_map.modules, fn module_node -> | ||
| synopsis = synopsis(module_node.doc) | ||
|
|
||
| ["- [#{module_node.title}](#{module_node.id}.md): ", synopsis, "\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.
I think is more readable to work with lists in this case, and it should be a bit more performant for bigger projects.
|
|
||
| tasks_info = | ||
| if length(nodes_map.tasks) > 0 do | ||
| if Enum.any?(nodes_map.tasks) do |
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.
We just care if there is at least one element in the list, we don't mind about the total number of entries.
|
|
||
| extras_info = | ||
| if is_list(config.extras) and length(config.extras) > 0 do | ||
| if is_list(config.extras) and Enum.any?(config.extras) do |
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.
Same here, we just care if there is at least one element in the list, we don't mind about the total number of entries.
| end | ||
| end | ||
|
|
||
| defp extract_plain_text(_), do: "No documentation available" |
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.
ExDoc.DocAST.synopsis/1 always returns a binary, so, this block was unreachable.
No worries, I'm so inactive in this project that I wasn't planning on merging code without any maintainer review. |
I was curious about this new formatter in
ex_docand I did an initial review. Please let me know what you think.