DocStringExtensions.jl icon indicating copy to clipboard operation
DocStringExtensions.jl copied to clipboard

Provide BODY

Open cstjean opened this issue 6 years ago • 4 comments

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

cstjean avatar Mar 13 '18 13:03 cstjean

Not sure how easy it is to actually get the function body through the Julia APIs?

mortenpi avatar Mar 26 '18 03:03 mortenpi

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

cstjean avatar Mar 26 '18 09:03 cstjean

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.

cstjean avatar Apr 05 '18 12:04 cstjean

Will be pretty simple to add once #133 is merged.

MichaelHatherly avatar Feb 05 '23 21:02 MichaelHatherly