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

Implement SIGNATURES-like abbreviation for collection of methods

Open setempler opened this issue 7 years ago • 1 comments

When I have several methods, for example:

"""
    $(SIGNATURES)

Print-fu.
"""
foo(x::Int) = print(x)
foo(x::Int, y::Int) = print(x + y)

I get

    foo(x)

Print-fu.

But I am looking for an implementation that yields

    foo(x)
    foo(x, y)

Print-fu.

Is this possible at all?

setempler avatar Mar 24 '18 23:03 setempler

Sorry, I must have missed this originally.

Docstrings are, in general, attached to a particular method, and hence $(SIGNATURES) should only contain that method I think. But perhaps we could have $(SIGNATURES) expand to all signatures when attached to a function declaration function foo end. So for your use case it would look something like:

"""
    $(SIGNATURES)

Print-fu.
"""
function foo end

foo(x::Int) = print(x)
foo(x::Int, y::Int) = print(x + y)

I don't think I will have time to look into this myself any time soon though, but a PR would be most welcome if someone wants to take a stab at implementing it.

mortenpi avatar Jul 01 '18 12:07 mortenpi