【发布时间】:2021-09-05 21:43:21
【问题描述】:
Julia 在命令行上接受?sin 以显示帮助文本。我相信这样的帮助文本是作为文档字符串实现的。我想在运行时从我的 Julia 程序中打印这样的文档字符串。该怎么做?
【问题讨论】:
Julia 在命令行上接受?sin 以显示帮助文本。我相信这样的帮助文本是作为文档字符串实现的。我想在运行时从我的 Julia 程序中打印这样的文档字符串。该怎么做?
【问题讨论】:
julia> @doc sin
sin(x)
Compute sine of x, where x is in radians.
sin(A::AbstractMatrix)
Compute the matrix sine of a square matrix A.
If A is symmetric or Hermitian, its eigendecomposition (eigen) is used to compute the
sine. Otherwise, the sine is determined by calling exp.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> sin(fill(1.0, (2,2)))
2×2 Matrix{Float64}:
0.454649 0.454649
0.454649 0.454649
【讨论】:
@doc宏(例如@doc sin)。
@doc 返回了 md 字符串。
@doc sin 将 markdown 输出格式化为应有的颜色和所有内容。在 Linux shell 中执行相同的程序不会从@doc sin 得到任何输出。是否可以在 shell 中获得格式化输出?
display。在非交互式环境中,您必须自己在结果上调用display/show。
julia -e "print(@doc sin)" 。或者,如果您想要颜色和格式,julia -e "display(@doc sin)"。