Document Julia Functions (methods, arguments, keywords)
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
.travis.yml
ACKNOWLEDGMENTS.md
COPYING.md
LICENSE
MADS.md
README.md
REQUIRE

README.md

DocumentFunction

DocumentFunction DocumentFunction DocumentFunction Build Status Coverage Status

DocumentFunction is a module of MADS (Model Analysis & Decision Support).

Installation:

Pkg.add("DocumentFunction")

Example:

import DocumentFunction

function getfunctionarguments(f::Function)
    m = methods(f)
    getfunctionarguments(f, string.(collect(m.ms)))
end
function getfunctionarguments(f::Function, m::Vector{String})
    l = length(m)
    mp = Array{Symbol}(0)
    for i in 1:l
        r = match(r"(.*)\(([^;]*);(.*)\)", m[i])
        if typeof(r) == Void
            r = match(r"(.*)\((.*)\)", m[i])
        end
        if typeof(r) != Void && length(r.captures) > 1
            fargs = strip.(split(r.captures[2], ", "))
            for j in 1:length(fargs)
                if !contains(string(fargs[j]), "...") && fargs[j] != ""
                    push!(mp, fargs[j])
                end
            end
        end
    end
    return sort(unique(mp))
end

@doc """
$(DocumentFunction.documentfunction(getfunctionarguments;
location=false,
maintext="Get function arguments",
argtext=Dict("f"=>"Function to be documented",
             "m"=>"Function methods")))
""" getfunctionarguments

Execution of

?getfunctionarguments

produces the following output:

  DocumentFunction.getfunctionarguments

  Get function arguments

  Methods

    •    DocumentFunction.getfunctionarguments(f::Function)

    •    DocumentFunction.getfunctionarguments(f::Function, m::Array{String,1})


  Arguments

    •    f::Function : Function to be documented

    •    m::Array{String,1} : Function methods

Developers

Publications, Presentations, Projects