Example usage of Docile.jl in Julia 0.3

三世轮回 提交于 2019-12-07 14:28:00

问题


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.

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,)

回答1:


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")


来源:https://stackoverflow.com/questions/28662958/example-usage-of-docile-jl-in-julia-0-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!