From f0176c57820dec8226f31f59adb3d69aed5415e9 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Fri, 13 Nov 2020 18:52:36 +1300 Subject: [PATCH] List Union{...} type aliases as "Type" (#1474) --- CHANGELOG.md | 4 ++++ src/Utilities/Utilities.jl | 2 +- test/utilities.jl | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46fd9c4d20..bfb27e1d36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ * ![Feature][badge-feature] Documenter can now deploy from Buildkite CI to GitHub Pages with `Documenter.Buildkite`. ([#1469][github-1469]) +* ![Bugfix][badge-bugfix] Type aliases of `Union`s (e.g. `const MyAlias = Union{Foo,Bar}`) are now correctly listed as "Type" in docstrings. ([#1466][github-1466], [#1474][github-1474]) + ## Version `v0.25.3` * ![Feature][badge-feature] Documenter can now deploy from GitLab CI to GitHub Pages with `Documenter.GitLab`. ([#1448][github-1448]) @@ -685,9 +687,11 @@ [github-1452]: https://github.com/JuliaDocs/Documenter.jl/pull/1452 [github-1462]: https://github.com/JuliaDocs/Documenter.jl/issues/1462 [github-1463]: https://github.com/JuliaDocs/Documenter.jl/pull/1463 +[github-1466]: https://github.com/JuliaDocs/Documenter.jl/issues/1466 [github-1468]: https://github.com/JuliaDocs/Documenter.jl/pull/1468 [github-1469]: https://github.com/JuliaDocs/Documenter.jl/pull/1469 [github-1471]: https://github.com/JuliaDocs/Documenter.jl/pull/1471 +[github-1474]: https://github.com/JuliaDocs/Documenter.jl/pull/1474 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 diff --git a/src/Utilities/Utilities.jl b/src/Utilities/Utilities.jl index a08fb0aaa1..24527556cd 100644 --- a/src/Utilities/Utilities.jl +++ b/src/Utilities/Utilities.jl @@ -257,7 +257,7 @@ end doccat(b::Binding, ::Type) = "Method" doccat(::Function) = "Function" -doccat(::DataType) = "Type" +doccat(::Type) = "Type" doccat(x::UnionAll) = doccat(Base.unwrap_unionall(x)) doccat(::Module) = "Module" doccat(::Any) = "Constant" diff --git a/test/utilities.jl b/test/utilities.jl index 973c8e2cec..1595343365 100644 --- a/test/utilities.jl +++ b/test/utilities.jl @@ -27,6 +27,10 @@ module UnitTests f(x) = x const pi = 3.0 + + const TA = Vector{UInt128} + const TB = Array{T, 8} where T + const TC = Union{Int64, Float64, String} end module OuterModule @@ -97,6 +101,9 @@ end @test Documenter.Utilities.doccat(UnitTests.S) == "Type" @test Documenter.Utilities.doccat(UnitTests.f) == "Function" @test Documenter.Utilities.doccat(UnitTests.pi) == "Constant" + @test Documenter.Utilities.doccat(UnitTests.TA) == "Type" + @test Documenter.Utilities.doccat(UnitTests.TB) == "Type" + @test Documenter.Utilities.doccat(UnitTests.TC) == "Type" # repo type @test Documenter.Utilities.repo_host_from_url("https://bitbucket.org/somerepo") == Documenter.Utilities.RepoBitbucket