vrod

vrod

Using Mermaid with ex_doc?

I saw a few thread about mermaid – it is a markdown way to make some charts and diagrams. I think it can be very useful for documentations. Does anyone know if ex_doc has “hooks” where something like this could be used? I’m not sure if I follow the ex_doc documentation, but hopefully someone knows if this might be possible! Thank you!

Marked As Solved

hauleth

hauleth

Yes, in mix help docs:

  • :javascript_config_path - Path of an additional JavaScript file to be
    included on all pages to provide up-to-date data for features like the
    version dropdown - See the “Additional JavaScript config” section. Example:
    "../versions.js"

So you can write script that will process Mermaid blocks in your documentation on the FE side. Alternatively you can write use options/custom wrapper for the Markdown parser, so you will be able to statically generate images basing on the returned data.

Also Liked

ityonemo

ityonemo

I think you can generate the @moduledoc as part of @before_compile. The Macro.Env.t term passed into the before_compile callback should have information about what functions exist in the module.

hauleth

hauleth

Well, if you meant GenStage.init/1 callback then it can return different values depending on passed arguments. So unless you return always the same value, then it is not possible to achieve what you want. If you always return the same value, independently of the argument, then you can do:

defmodule A do
  @init_return …

  @moduledoc """
  #{make_mermaid_chart(@init_return)}
  """

  def init(_), do: @init_return
end

Where Next?

Popular in Questions Top

jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New

Other popular topics Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
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
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
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New

We're in Beta

About us Mission Statement