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

How to use alias of AbstractArray instead of the full name? (Feature request) #108

Closed
ShuhuaGao opened this issue Feb 5, 2021 · 2 comments

Comments

@ShuhuaGao
Copy link

Consider the following function in a module CGP

"""
$(TYPEDSIGNATURES)
"""
function f2(v::Vector{Int}, m::Matrix{Float64})
    return sum(v) + sum(m)
end

which produces documentation:
Snipaste_2021-02-05_15-02-54

It seems to me that the built-in alias Vector and Matrix are more readable. Is it possible to show the short alias instead of the original type in the documentation?

@MichaelHatherly
Copy link
Member

Agreed, definitely a nice to have feature. If you're on Julia 1.6 or above this should just work out the box since TYPEDSIGNATURES hooks into the base display system for printing types, and printing of the type alias was added for 1.6:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.0-beta1.91 (2021-02-02)
 _/ |\__'_|_|_|\__'_|  |  release-1.6/e02764ca43* (fork: 198 commits, 57 days)
|__/                   |

(@v1.6) pkg> add DocStringExtensions
    Updating registry at `~/.julia/registries/General`
    Updating registry at `~/.julia/registries/PumasRegistry`
   Resolving package versions...
    Updating `~/.julia/environments/v1.6/Project.toml`
  [ffbed154] + DocStringExtensions v0.8.3
  No Changes to `~/.julia/environments/v1.6/Manifest.toml`

julia> using DocStringExtensions

julia> """
       $(TYPEDSIGNATURES)
       """
       function f2(v::Vector{Int}, m::Matrix{Float64})
           return sum(v) + sum(m)
       end
f2

help?> f2
search: Float32 f2 Inf32 ComplexF32

  f2(v::Vector{Int64}, m::Matrix{Float64}) -> Float64

For 1.5 and below there's no general way to do this properly since it requires support in base Julia.

@ShuhuaGao
Copy link
Author

@MichaelHatherly Noted with thanks. Currently, I am using 1.5, but will switch to 1.6 once it is released.

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

No branches or pull requests

2 participants