DocStringExtensions.jl
DocStringExtensions.jl copied to clipboard
Provide BODY
Sometimes, short functions are best documented by their full definition (and sometimes I'm just lazy). It would be nice if $(BODY)
was replaced with log(p / (1 - p))
.
""" Logistic regression, $(BODY) """
logit(p) = log(p / (1 - p))
Not sure how easy it is to actually get the function body through the Julia APIs?
I thought that this was all part of a macro and that the Expr
was available...
Not sure how easy it is to actually get the function body through the Julia APIs?
Doesn't look so good https://github.com/JuliaLang/julia/issues/24347
julia> Core.atdoc!((args...)->(global dbg = args))
(::#1) (generic function with 1 method)
julia> @doc """ Testing """ f(x, y=2; z=3) = "hello" * y
(" Testing ", :(f(x, y=2; z=3) = begin # REPL[2], line 1:
"hello" * y
end))
Seems like it's available after all, and it's just a matter of extracting it from the AST.
Will be pretty simple to add once #133 is merged.