打印帮助?Julia中函数的信息

打印帮助?Julia中函数的信息,julia,Julia,标题很好地概括了这一点。有没有一种简单的方法可以远程显示函数的帮助信息 DispHelp = function(query_string) # Enter help mode as you would by pressing `?` and query the given string print(help_text) return help_text end 有什么想法吗?可能有 julia-1.2> for f in [sin, cos, tan]

标题很好地概括了这一点。有没有一种简单的方法可以远程显示函数的帮助信息

DispHelp = function(query_string)
  # Enter help mode as you would by pressing `?` and query the given string
  print(help_text)
  return help_text
end
有什么想法吗?

可能有

julia-1.2> for f in [sin, cos, tan]
              println(Base.doc(f))
           end
```
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`](@ref)) is used to compute the sine. Otherwise, the sine is determined by calling [`exp`](@ref).

# Examples

```jldoctest
julia> sin(fill(1.0, (2,2)))
2×2 Array{Float64,2}:
 0.454649  0.454649
 0.454649  0.454649
```

```
cos(x)
```

Compute cosine of `x`, where `x` is in radians.

```
cos(A::AbstractMatrix)
```

Compute the matrix cosine of a square matrix `A`.

If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](@ref)) is used to compute the cosine. Otherwise, the cosine is determined by calling [`exp`](@ref).

# Examples

```jldoctest
julia> cos(fill(1.0, (2,2)))
2×2 Array{Float64,2}:
  0.291927  -0.708073
 -0.708073   0.291927
```

```
tan(x)
```

Compute tangent of `x`, where `x` is in radians.

```
tan(A::AbstractMatrix)
```

Compute the matrix tangent of a square matrix `A`.

If `A` is symmetric or Hermitian, its eigendecomposition ([`eigen`](@ref)) is used to compute the tangent. Otherwise, the tangent is determined by calling [`exp`](@ref).

# Examples

```jldoctest
julia> tan(fill(1.0, (2,2)))
2×2 Array{Float64,2}:
 -1.09252  -1.09252
 -1.09252  -1.09252
```

有了Julia,您可以阅读所有代码,因此花几个小时仔细阅读应该会有所启发。

完成daycaster关于如何显示内置函数帮助的回答

如果您想在自己的函数上显示帮助,则必须在此示例函数上编写一个文档字符串,如下所示:


#Here is my docstring between triple quote, just before function declaration
"""
square(x)


Return the square of x, if it's a number. If it's a vector, return element-wise square of the vector
"""
function square(x)
#And now the body of my function
       out = x.*x
end

据我所知,没有办法做到这一点。“帮助信息是直接从docstring中获取的,我认为不能以编程方式调用它。@user3303504最好将您的“编辑”添加为单独的答案,而不是“编辑我的答案”,因为“编辑我的答案”属于我