diff --git a/.travis.yml b/.travis.yml index cc04a2a..1116e9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ os: julia: - 0.4 - 0.5 + - 0.6 - nightly notifications: @@ -20,4 +21,3 @@ after_success: - julia -e 'include(Pkg.dir("DocStringExtensions", "test", "coverage.jl"))' - julia -e 'Pkg.add("Documenter"); Pkg.checkout("Documenter")' - julia -e 'include(Pkg.dir("DocStringExtensions", "docs", "make.jl"))' - diff --git a/REQUIRE b/REQUIRE index 2564873..d395c2a 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ julia 0.4 -Compat 0.8 +Compat 0.18 diff --git a/appveyor.yml b/appveyor.yml index a9dc307..f4cbd92 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,9 @@ environment: matrix: - - JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe" - - JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe" - - JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe" + - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe" + - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe" + - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe" + - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" branches: only: @@ -16,9 +17,10 @@ notifications: on_build_status_changed: false install: + - ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" # Download most recent Julia Windows binary - ps: (new-object net.webclient).DownloadFile( - $("http://s3.amazonaws.com/"+$env:JULIAVERSION), + $env:JULIA_URL, "C:\projects\julia-binary.exe") # Run installer silently, output to C:\projects\julia - C:\projects\julia-binary.exe /S /D=C:\projects\julia diff --git a/src/abbreviations.jl b/src/abbreviations.jl index 0074792..496756d 100644 --- a/src/abbreviations.jl +++ b/src/abbreviations.jl @@ -10,7 +10,7 @@ expanded automatically before parsing the text to markdown. $(:FIELDS) """ -abstract Abbreviation +@compat abstract type Abbreviation end """ $(:SIGNATURES) @@ -70,7 +70,10 @@ function format(::TypeFields, buf, doc) local docs = get(doc.data, :fields, Dict()) local binding = doc.data[:binding] local object = Docs.resolve(binding) - local fields = fieldnames(object) + # On 0.7 fieldnames() on an abstract type throws an error. We then explicitly return + # and empty vector to be consistent with the behaviour on v0.6 and below. + # Compat necessary since Base.isabstract was introduced in v0.6. + local fields = Compat.TypeUtils.isabstract(object) ? Symbol[] : fieldnames(object) if !isempty(fields) println(buf) for field in fields @@ -351,7 +354,7 @@ const TYPEDEF = TypeDefinition() function format(::TypeDefinition, buf, doc) local binding = doc.data[:binding] - local object = Docs.resolve(binding) + local object = gettype(Docs.resolve(binding)) if isa(object, DataType) println(buf, "\n```julia") if isbitstype(object) diff --git a/src/templates.jl b/src/templates.jl index ec28db3..6011b6b 100644 --- a/src/templates.jl +++ b/src/templates.jl @@ -109,6 +109,11 @@ function template_hook(docstr, expr::Expr) end template_hook(args...) = args +# The signature for the atdocs() calls changed in v0.7 +# On v0.6 and below it seems it was assumed to be (docstr::String, expr::Expr), but on v0.7 +# it is (source::LineNumberNode, mod::Module, docstr::String, expr::Expr) +template_hook(source::LineNumberNode, mod::Module, args...) = (source, mod, template_hook(args...)...) + interp_string(str::AbstractString) = Expr(:string, str) interp_string(other) = other diff --git a/src/utilities.jl b/src/utilities.jl index ce4c36c..f5b244f 100644 --- a/src/utilities.jl +++ b/src/utilities.jl @@ -53,6 +53,23 @@ function comparemethods(a::Method, b::Method) comp == 0 ? a.line < b.line : comp < 0 end +if isdefined(Base, :UnionAll) + uniontypes(T) = uniontypes!(Any[], T) + function uniontypes!(out, T) + if isa(T, Union) + push!(out, T.a) + uniontypes!(out, T.b) + else + push!(out, T) + end + return out + end + gettype(T::UnionAll) = gettype(T.body) +else + uniontypes(T) = collect(T.types) +end +gettype(other) = other + """ $(:SIGNATURES) @@ -62,7 +79,7 @@ function getmethods!(results, f, sig) if sig == Union{} append!(results, methods(f)) elseif isa(sig, Union) - for each in sig.types + for each in uniontypes(sig) append!(results, getmethods(f, each)) end else @@ -99,9 +116,9 @@ isabstracttype(t::ANY) = isa(t, DataType) && getfield(t, :abstract) """ $(:SIGNATURES) -Returns a `SimpleVector` of the `Tuple` types contained in `sig`. +Returns a `Vector` of the `Tuple` types contained in `sig`. """ -alltypesigs(sig) = isa(sig, Union) ? sig.types : Core.svec(sig) +alltypesigs(sig) = sig == Union{} ? Any[] : isa(sig, Union) ? uniontypes(sig) : Any[sig] """ $(:SIGNATURES) @@ -197,6 +214,10 @@ if isdefined(Base, :LambdaInfo) has_method_source(m::Method) = isdefined(m, :lambda_template) get_method_source(m::Method) = m.lambda_template nargs(m::Method) = m.lambda_template.nargs +elseif VERSION >= v"0.6.0-pre.alpha.244" + has_method_source(m::Method) = true + get_method_source(m::Method) = Base.uncompressed_ast(m) + nargs(m::Method) = m.nargs else has_method_source(m::Method) = isdefined(m, :source) get_method_source(m::Method) = m.source diff --git a/test/tests.jl b/test/tests.jl index 3267435..5fc3099 100644 --- a/test/tests.jl +++ b/test/tests.jl @@ -5,13 +5,15 @@ include("templates.jl") module M +using Compat + export f f(x) = x g(x = 1, y = 2, z = 3; kwargs...) = x -typealias A{T} Union{Vector{T}, Matrix{T}} +@compat const A{T} = Union{Vector{T}, Matrix{T}} h_1(x::A) = x h_2(x::A{Int}) = x @@ -27,14 +29,14 @@ immutable K end -abstract AbstractType <: Integer +@compat abstract type AbstractType <: Integer end immutable CustomType{S, T <: Integer} <: Integer end -bitstype 8 BitType8 +@compat primitive type BitType8 8 end -bitstype 32 BitType32 <: Real +@compat primitive type BitType32 <: Real 32 end end @@ -305,9 +307,9 @@ end @test length(DSE.methodgroups(M.h_2, Tuple{M.A{Int}}, M)[1]) == 1 end @testset "alltypesigs" begin - @test DSE.alltypesigs(Union{}) == Core.svec() - @test DSE.alltypesigs(Union{Tuple{}}) == Core.svec(Tuple{}) - @test DSE.alltypesigs(Tuple{}) == Core.svec(Tuple{}) + @test DSE.alltypesigs(Union{}) == Any[] + @test DSE.alltypesigs(Union{Tuple{}}) == Any[Tuple{}] + @test DSE.alltypesigs(Tuple{}) == Any[Tuple{}] end @testset "groupby" begin let groups = DSE.groupby(Int, Vector{Int}, collect(1:10)) do each