Julia 0.3 中 Docile.jl 的示例用法 [英] Example usage of Docile.jl in Julia 0.3

查看:21
本文介绍了Julia 0.3 中 Docile.jl 的示例用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Julia 的新手.我有兴趣使用 Docile.jl 向现有的 Julia 添加文档项目.根据 这篇文章,文档字符串已经添加到 Julia 0.4,但我想让文档字符串在 0.3 中工作.

I'm new to Julia. I'm interested in using Docile.jl to add documentation to an existing Julia project. According to this post, docstrings have already been added to Julia 0.4, but I'd like to get docstrings working in 0.3.

不过,上面帖子中的示例在 0.3 中不起作用.help(f) 不显示文档字符串,并且 @doc f 返回错误.有人可以帮我看看缺少什么吗?

The example in the post above doesn't work in 0.3, though. help(f) doesn't show the docstring, and @doc f returns an error. Can someone help me see what is missing?

$ julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.3.6 (2015-01-08 22:33 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org release
|__/                   |  x86_64-linux-gnu

julia> using Docile

julia> @doc """
              Compute 2 times x minus y squared.
              """ ->
              function f(x::Float64, y::Float64)
                  return 2x - y^2
              end
f (generic function with 1 method)

julia> help(f)
INFO: Loading help data...
f (generic function with 1 method)

julia> @doc f
ERROR: @doc: use `->` to separate docs/object:
(:f,)

推荐答案

您可能希望将 Docile.jl 与 Lexicon.jl.下面的会话表明,如果您只记录函数而不使用 Lexicon,则任何函数的帮助文本都不会改变.只有在您键入 using Lexicon 后,帮助文本才会反映您的文档.请注意,在下面,我通过在 repl 中键入 ? 来获取帮助文本,而不是使用函数 help.

You probably want to use Docile.jl in conjunction with Lexicon.jl. The session below shows that if you just document functions without using Lexicon, help text for any function won't change. The help text only reflects your documentation once you type using Lexicon. Note that, below, I'm getting help text by typing a ? at the repl, not by using the function help.

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.3.6 (2015-02-17 22:12 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-unknown-linux-gnu

julia> using Docile

julia> 

julia> @doc """
                            Compute 2 times x minus y squared.
                            """ ->
                            function f(x::Float64, y::Float64)
                                return 2x - y^2
                            end
f (generic function with 1 method)

help?> f
INFO: Loading help data...
f (generic function with 1 method)

julia> using Lexicon

help?> f
f (generic function with 1 method)

INFO: Parsing documentation for Docile.
INFO: Parsing documentation for Lexicon.
INFO: Parsing documentation for Docile.Interface.

[method]

.f(x::Float64, y::Float64)

  Compute 2 times x minus y squared. 

 Details:

    source: (3,"none")

这篇关于Julia 0.3 中 Docile.jl 的示例用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆