我想在 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/