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

Parametric constructors cause `SIGNATURE` and `TYPEDSIGNATURE` to be empty / wrong

Open henrik-wolf opened this issue 9 months ago • 0 comments

I have something similar to the following setup where I try to create a zero argument constructor for a parametric struct:

using DocStringExtensions

"""
# struct definition
My test struct with fields
$(TYPEDFIELDS)
"""
struct MyStruct{T<:Number}
    a::T
end

"""
# empty constructor. Call with
$(SIGNATURES) or:
$(TYPEDSIGNATURES)
"""
function MyStruct{T}() where {T<:Number}
    return MyStruct{T}(one(T))
end

The constructed documentation look like this:

help?> MyStruct
search: MyStruct

  struct definition
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  My test struct with fields

    •  a::Number

  ────────────────────────────────────────

  empty constructor. Call with
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  MyStruct(a)
  


  or:

  MyStruct(a::Number) -> MyStruct

Which does not reproduce the signature of the parametric constructor. Ideally, I would expect something like MyStruct{T}() for $SIGNATURES andMyStruct{T<:Number}() -> MyStruct for $TYPEDSIGNATURES.

(In the documenter build, the result of SIGNATURES and TYPEDSIGNATURES seems to just be empty, hence the empty in the title.)

henrik-wolf avatar May 24 '24 17:05 henrik-wolf