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.

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,)
Community
  • 1
  • 1
user3271788
  • 165
  • 5

1 Answers1

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")
Alex A.
  • 5,466
  • 4
  • 26
  • 56
Jeff
  • 1,232
  • 1
  • 13
  • 22