Julia Autodoc

The autodoc extension is used to automatically extract documentation from source code. Contrary to its python equivalent where introspection is used to obtain the necessary information julia autodoc is file based. This means that the filename where the documented object is defined has to be stated explicitly.

The usage of the autodoc extension will be explained using the following file as example

# examples/example.jl
"""
Symbolic mathematical computation library.
"""

abstract MathObject

type Symbol <: MathObject
    name::AbstractString
end

type Sum <: MathObject
    args::Vector{Symbol}
end

"""
Add two symbols.

Arguments
---------
a
    First argument.
b
    Second argument.
"""
function add{T}(a::T, b::T)
    return Sum(Symbol[a, b])
end

The whole content of the file can automatically be imported into the documentation using the :jl:autofile directive.

.. jl:autofile:: examples/example.jl
abstract MathObject
Symbolic mathematical computation library.
type Symbol<: MathObject
type Sum<: MathObject
function add{T}(a, b)

Add two symbols.

Parameters:
  • a – First argument.
  • b – Second argument.

To document only specific parts of the file one can use the directives jl:automodule, jl:autofunction, jl:autotype and jl:autoabstract.

.. jl:autofunction:: examples/example.jl add
function add{T}(a, b)

Add two symbols.

Parameters:
  • a – First argument.
  • b – Second argument.
.. jl:autoabstract:: examples/example.jl MathObject
abstract MathObject
Symbolic mathematical computation library.
.. jl:autotype:: examples/example.jl Sum
type Sum<: MathObject