mermaid extension for edoc

Copyright © 2020 João Henrique Ferreira de Freitas

Version: 0.1.0

Authors: João Henrique Ferreira de Freitas (

The purpose of this tiny library is to help creating better documentation using text based diagram that allows expressing ideas using traditional techniques like sequence diagram, state chart and flowcharts. The mermaid javascript library renders Markdown-inspired text and creates each diagram dynamically. edocmermaid is just a little help to make mermaid happens when writing documentation with edoc tool.

edocmermaid brings two additional modules that include the mermaid javascript library for each html page created by running edoc.

The module edocmermaid_doclet check and copy the mermaid javascript to the correct place. While the module edocmermaid_layout patches each html file, created by edoc, adding a reference and enabling mermaid javascript.


  1. Configure rebar3
  2. Add mermaid tag
  3. Examples

Configure rebar3

Add edocmermaid dependency to the docs profile. Like this:

{profiles, [
  {docs, [
    {deps, [edocmermaid]}

That way, the rebar3 command edoc will fetch and use edocmermaid as dependency.

Next, the following edoc options are necessary in order to configure edoc callbacks properly:

Also, if specified, the option mermaid_url can be used as an alternative mermaid javascript location. The default is copy and use the edocmermaid version.

The section edoc_opts` from `rebar.config file will look like this:

{edoc_opts, [
    {doclet, edocmermaid_doclet},
    {layout, edocmermaid_layout},
    % specificy the mermaid URL, optional
    {mermaid_url, ""}

Add mermaid tag

Wherever you want to add text based diagram, use the <div class=mermaid> tag. like so:
<div class="mermaid">
    Alice->>John: Hello John, how are you?
    Note over Alice,John: A typical interaction
sequenceDiagram Alice->>John: Hello John, how are you? Note over Alice,John: A typical interaction


Please visite the mermaid website for a full set of examples and valuable instructions about how to use mermaid.

The following examples is just a prove of concept that edocmermaid works.


Generated by EDoc