在 Julia 中将程序的文档字符串打印到标准输出
Print a docstring of a program to stdout in 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
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