Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would it be possible to add a TYPEDMETHODLIST abbreviation #150

Open
unnamedunknownusername opened this issue May 14, 2023 · 2 comments
Open

Comments

@unnamedunknownusername
Copy link

unnamedunknownusername commented May 14, 2023

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 unnamedunknownusername changed the title Would it be possible to add a TYPEDMETHODLIST constant Would it be possible to add a TYPEDMETHODLIST abbreviation May 14, 2023
@MichaelHatherly
Copy link
Member

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.

@unnamedunknownusername
Copy link
Author

draft PR is up #153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants