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

查看:91
本文介绍了在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与

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天全站免登陆