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

Would it be possible to add a TYPEDMETHODLIST abbreviation

Open unnamedunknownusername opened this issue 1 year ago • 2 comments

Currently I have a module set up like this

module abcFunctionsModule

using DocStringExtensions
DocStringExtensions.@template TYPES =
"""
$(TYPEDEF)
# Descriptions
$(DOCSTRING)
"""

DocStringExtensions.@template (FUNCTIONS) =
"""
$(METHODLIST)

# Description
$(DOCSTRING)
# Examples
"""

DocStringExtensions.@template (METHODS, MACROS) =
"""
$(DOCSTRING)
"""

include("myFunc1.jl")
include("myFunc2.jl")

end

myFunc1.jl file looks like this


"""
An example function which will later be placed in a module to be imported/used elsewhere.
"""
function myFunc1 end 
#this is the empty function definition (i.e it declares a function with 0 methods) and is where we document the `description of the function.


"""
## Example with no arguments
myFunc1() ----> $(myFunc1())
"""
function myFunc1()
	return "MyFunc1"
end

"""
## Example with int
myFunc1(5) ----> $(myFunc1(5))
"""
function myFunc1(x::Int64)
	return "MyFunc1 with an int $x"
end

"""
## Example with string
myFunc1("me") ----> $(myFunc1("me"))
"""
function myFunc1(x::String)
	return "MyFunc1 with a string that says $x"
end

This does 99% of what I want it to. i.e. DocStringExtensions correctly adds the #Decription and #Examples heading and then adds each example as per the documentation above each method. image

However $METHODLIST outputs this image so for the last two methods of myFunc1 ( one that takes in a string and the other that takes in a int) you can't see immediately what the input is because they both show up as

myFunc(x)

Note I cannot do this with TYPEDSIGNATURES in each individual method docString as i specifically want a doc sting like this

"""
# the methods/signatures

# then description

# then examples
# with each example being found in the method DocString to limit duplication/ adhere to single source of truth
""" 
function xyz end ....etc

Would it be possible to add the typed signatures/ typed method list by creating a new $TYPEDMETHODLIST abbreviation similar to how it is done for $TYPEDSIGNATURES

I could then create the module as described above and everything would show up nicely/just work. And I would be able to distinguish between which method is which

I would be happy to contribute to a PR. I am a novice when it comes to meta-programming so guidance on what to do/where to look would be appreciated

Many thanks in advance

unnamedunknownusername avatar May 14 '23 12:05 unnamedunknownusername

Hi @unnamedunknownusername, yes, seems like a reasonable addition.

I would be happy to contribute to a PR. I am a novice when it comes to meta-programming so guidance on what to do/where to look would be appreciate.

Go for it. If you need any help just ping me in the work-in-progress PR once you get going I'll give you some guidance where needed.

MichaelHatherly avatar May 15 '23 09:05 MichaelHatherly

draft PR is up #153

unnamedunknownusername avatar May 17 '23 15:05 unnamedunknownusername