loops - 如何在 Julia 文档字符串中缩进?

标签 loops julia indentation docstring

我想在 Julia 文档字符串中包含一个循环,但是当我尝试看起来很明显的方法时,缩进没有显示。

"""
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

=#

"""

但是,当我在函数前面添加问号以获取文档时,循环的缩进不存在。

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
=#

我在Python中没有这样的问题。如何让这些选项卡显示在 Julia 中?

最佳答案

请阅读Documentation有关如何格式化文档字符串的更多详细信息,请参阅部分。

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

关于loops - 如何在 Julia 文档字符串中缩进?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64454707/

相关文章:

javascript - 如何通过每次从所有行中取一个值来获取带有循环的二维数组中值的所有组合?

php - 无论如何要简化 foreach 循环的老鼠巢吗?

JQuery 在循环中模拟 Accordion

julia - 在 Julia 中可视化一维随机游走

parallel-processing - Julia pmap : How to effectively send helper functions to other workers?

julia - 尽管使用方法(...)显示,但未找到函数签名

syntax-error - 如何修复 YAML 语法错误 : did not find expected '-' indicator while parsing a block?

java - 让 FileReader 使用循环读取每四行

javascript - 在大括号内时 vim 中的自动换行和缩进?

Python 选项卡创建