How do I get indents in a Julia docstring?

Viewed 200

I want to include a loop in a Julia docstring, yet the indent does not show up when I try what looks like the obvious way to do it.

"""
Function: dave

Arguments

  x: first number

  y: second number

Returns

  interaction_sum: x + y + xy

Examples

#=

for i in 1:5

    println(dave(i, i)) # 3, 8, 15, 24, 35

end

=#

"""

However, when I throw the question mark in front of my function to get the documentation, the indent for the loop isn't there.

Function: dave
Arguments
x: first number
y: second number
Returns 
interaction_sum: x + y + xy
Examples
#=
for i in 1:5
println(dave(i, i)) # 3, 8, 15, 24, 35
end
=#

I have no such issue in Python. How do I get those tabs to show up in Julia?

1 Answers

Please read the Documentation section for more details on how to format the doc string.

julia> """
           dave

       # Arguments

         x: first number

         y: second number

       # Returns

         interaction_sum: x + y + xy

       # Examples

       ```
       for i in 1:5

           println(dave(i, i)) # 3, 8, 15, 24, 35

       end

       ```
       """
       function dave() end
help?> dave
search: dave code_native @code_native readavailable

  dave

  Arguments
  ≡≡≡≡≡≡≡≡≡≡≡

  x: first number

  y: second number

  Returns
  ≡≡≡≡≡≡≡≡≡

  interaction_sum: x + y + xy

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  for i in 1:5
  
      println(dave(i, i)) # 3, 8, 15, 24, 35
  
  end
Related