write multiples lines example code in @doc auto-format error

Viewed 20

The function doc is as follows:

  @doc """


  input:


  output:
   

  ## example

    max_height = 5
    max_length = 5
    is_used = true
    result =
      InventoryMap.constrcut_initial_map(
        max_length,
        max_height,
        is_used,
        max_length,
        max_height,
        is_used
      )

  """

The actual result is as follows:

enter image description here

How to make

max_height = 5
max_length = 5
is_used = true

as part of the example?

1 Answers

ExDoc uses Markdown. Code blocks are represented by 4 characters of indentation. You need to indent by 2 more characters.

  @doc """
  input:

  output:

  ## example
      max_height = 5
      max_length = 5
      is_used = true
      result =
        InventoryMap.constrcut_initial_map(
          max_length,
          max_height,
          is_used,
          max_length,
          max_height,
          is_used
        )
  """

Or use backticks:

  ## example
  ```
  max_height = 5
  max_length = 5
  etc...
  ```

enter image description here

Related