JuliaDocs / JuliaDocs/DocStringExtensions.jl

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

Open
#164 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
126
Forks
35
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Julia example in the issue and inspect how SIGNATURES and TYPEDSIGNATURES process the parametric zero-argument constructor. Compare the generated documentation with the expected MyStruct{T}() and MyStruct{T<:Number}() -> MyStruct forms; the issue is done when both substitutions preserve the constructor's parametric signature.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.