Skip to content

Commit

Permalink
Fix takebuf_string deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHatherly committed Nov 18, 2016
1 parent fddfc99 commit bd2a28a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
8 changes: 8 additions & 0 deletions src/DocStringExtensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ const FIELDS, EXPORTS, METHODLIST, IMPORTS, SIGNATURES, TYPEDEF = "", "", "", ""

else # VERSION < v"0.5.0-dev"

# Compat.

if VERSION < v"0.6.0-dev.1254"
takebuf_str(b) = takebuf_string(b)
else
takebuf_str(b) = String(take!(b))
end

# Includes.

include("utilities.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function printmethod(buffer::IOBuffer, binding::Docs.Binding, func, method::Meth
return buffer
end

printmethod(b, f, m) = takebuf_string(printmethod(IOBuffer(), b, f, m))
printmethod(b, f, m) = takebuf_str(printmethod(IOBuffer(), b, f, m))

# Handle differences between Julia 0.5/0.6 where `LambdaInfo` is replaced with `CodeInfo`.
if isdefined(Base, :LambdaInfo)
Expand Down
22 changes: 11 additions & 11 deletions test/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ end
:typesig => Union{},
)
DSE.format(IMPORTS, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, "\n - `Base`\n")
@test contains(str, "\n - `Core`\n")

# Module exports.
DSE.format(EXPORTS, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, "\n - [`f`](@ref)\n")
end

Expand All @@ -71,7 +71,7 @@ end
),
)
DSE.format(FIELDS, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, " - `a`")
@test contains(str, " - `b`")
@test contains(str, " - `c`")
Expand All @@ -86,7 +86,7 @@ end
:module => M,
)
DSE.format(METHODLIST, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, "```julia")
@test contains(str, "f(x)")
@test contains(str, "[`$(joinpath("DocStringExtensions", "test", "tests.jl"))")
Expand All @@ -99,7 +99,7 @@ end
:module => M,
)
DSE.format(SIGNATURES, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, "\n```julia\n")
@test contains(str, "\nf(x)\n")
@test contains(str, "\n```\n")
Expand All @@ -110,7 +110,7 @@ end
:module => M,
)
DSE.format(SIGNATURES, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, "\n```julia\n")
@test contains(str, "\ng()\n")
@test contains(str, "\ng(x)\n")
Expand All @@ -122,7 +122,7 @@ end
:module => M,
)
DSE.format(SIGNATURES, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, "\n```julia\n")
@test contains(str, "\ng()\n")
@test contains(str, "\ng(x)\n")
Expand All @@ -138,7 +138,7 @@ end
:module => M,
)
DSE.format(TYPEDEF, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, "\n```julia\n")
@test contains(str, "\nabstract AbstractType <: Integer\n")
@test contains(str, "\n```\n")
Expand All @@ -149,7 +149,7 @@ end
:module => M,
)
DSE.format(TYPEDEF, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, "\n```julia\n")
@test contains(str, "\nimmutable CustomType{S, T<:Integer} <: Integer\n")
@test contains(str, "\n```\n")
Expand All @@ -160,7 +160,7 @@ end
:module => M,
)
DSE.format(TYPEDEF, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, "\n```julia\n")
@test contains(str, "\nbitstype 8 BitType8\n")
@test contains(str, "\n```\n")
Expand All @@ -171,7 +171,7 @@ end
:module => M,
)
DSE.format(TYPEDEF, buf, doc)
str = takebuf_string(buf)
str = DSE.takebuf_str(buf)
@test contains(str, "\n```julia\n")
@test contains(str, "\nbitstype 32 BitType32 <: Real")
@test contains(str, "\n```\n")
Expand Down

0 comments on commit bd2a28a

Please sign in to comment.