Skip to content

Commit cc83610

Browse files
authored
Merge pull request #58 from JuliaDocs/backports-0.4.4
Backports for 0.4.4
2 parents 73fc332 + 897e0ef commit cc83610

File tree

4 files changed

+61
-57
lines changed

4 files changed

+61
-57
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
julia 0.6
2-
Compat 0.33 # Compat.Test
2+
Compat 0.62

src/abbreviations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function format(::TypeFields, buf, doc)
7373
# On 0.7 fieldnames() on an abstract type throws an error. We then explicitly return
7474
# an empty vector to be consistent with the behaviour on v0.6.
7575
# Compat necessary since Base.isabstract was introduced in v0.6.
76-
local fields = Compat.TypeUtils.isabstract(object) ? Symbol[] : fieldnames(object)
76+
local fields = isabstracttype(object) ? Symbol[] : fieldnames(object)
7777
if !isempty(fields)
7878
println(buf)
7979
for field in fields
@@ -136,7 +136,7 @@ function format(::ModuleExports, buf, doc)
136136
# Sorting ignores the `@` in macro names and sorts them in with others.
137137
for sym in sort(exports, by = s -> lstrip(string(s), '@'))
138138
# Skip the module itself, since that's always exported.
139-
sym === module_name(object) && continue
139+
sym === nameof(object) && continue
140140
# We print linked names using Documenter.jl cross-reference syntax
141141
# for ease of integration with that package.
142142
println(buf, " - [`", sym, "`](@ref)")

src/utilities.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ $(:SIGNATURES)
105105
106106
Is the type `t` a `bitstype`?
107107
"""
108-
isbitstype(@nospecialize(t)) = isconcrete(t) && sizeof(t) > 0 && isbits(t)
108+
isbitstype(@nospecialize(t)) = isconcretetype(t) && sizeof(t) > 0 && isbits(t)
109109

110110
"""
111111
$(:SIGNATURES)
@@ -169,7 +169,7 @@ $(:SIGNATURES)
169169
Remove the `Pkg.dir` part of a file `path` if it exists.
170170
"""
171171
function cleanpath(path::AbstractString)
172-
local pkgdir = joinpath(Pkg.dir(), "")
172+
local pkgdir = joinpath(Compat.Pkg.dir(), "")
173173
return startswith(path, pkgdir) ? first(split(path, pkgdir; keep = false)) : path
174174
end
175175

@@ -246,7 +246,7 @@ function keywords(func, m::Method)
246246
# Fetching method keywords stolen from base/replutil.jl:572-576 (commit 3b45cdc9aab0):
247247
local kwargs = Base.kwarg_decl(m, typeof(table.kwsorter))
248248
if isa(kwargs, Vector) && length(kwargs) > 0
249-
filter!(arg -> !contains(string(arg), "#"), kwargs)
249+
filter!(arg -> !occursin("#", string(arg)), kwargs)
250250
# Keywords *may* not be sorted correctly. We move the vararg one to the end.
251251
local index = findfirst(arg -> endswith(string(arg), "..."), kwargs)
252252
if index != nothing && index > 0 # TODO: use Compat.findfirst later on
@@ -301,6 +301,8 @@ on TravisCI as well.
301301
"""
302302
url(m::Method) = url(m.module, string(m.file), m.line)
303303

304+
import Compat.LibGit2
305+
304306
function url(mod::Module, file::AbstractString, line::Integer)
305307
file = Compat.Sys.iswindows() ? replace(file, '\\', '/') : file
306308
if Base.inbase(mod) && !isabspath(file)

test/tests.jl

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
using Compat
3+
24
const DSE = DocStringExtensions
35

46
include("templates.jl")
@@ -73,7 +75,7 @@ end
7375
@test isa(methods(M.j_1), Base.MethodList)
7476
@test isdefined(methods(M.j_1), :mt)
7577
local mt = methods(M.j_1).mt
76-
@test isa(mt, Base.MethodTable)
78+
@test isa(mt, Core.MethodTable)
7779
@test isdefined(mt, :kwsorter)
7880
# .kwsorter is not always defined -- namely, it seems when none of the methods
7981
# have keyword arguments:
@@ -107,13 +109,13 @@ end
107109
)
108110
DSE.format(IMPORTS, buf, doc)
109111
str = String(take!(buf))
110-
@test contains(str, "\n - `Base`\n")
111-
@test contains(str, "\n - `Core`\n")
112+
@test occursin("\n - `Base`\n", str)
113+
@test occursin("\n - `Core`\n", str)
112114

113115
# Module exports.
114116
DSE.format(EXPORTS, buf, doc)
115117
str = String(take!(buf))
116-
@test contains(str, "\n - [`f`](@ref)\n")
118+
@test occursin("\n - [`f`](@ref)\n", str)
117119
end
118120

119121
@testset "type fields" begin
@@ -126,11 +128,11 @@ end
126128
)
127129
DSE.format(FIELDS, buf, doc)
128130
str = String(take!(buf))
129-
@test contains(str, " - `a`")
130-
@test contains(str, " - `b`")
131-
@test contains(str, " - `c`")
132-
@test contains(str, "one")
133-
@test contains(str, "two")
131+
@test occursin(" - `a`", str)
132+
@test occursin(" - `b`", str)
133+
@test occursin(" - `c`", str)
134+
@test occursin("one", str)
135+
@test occursin("two", str)
134136
end
135137

136138
@testset "method lists" begin
@@ -141,9 +143,9 @@ end
141143
)
142144
DSE.format(METHODLIST, buf, doc)
143145
str = String(take!(buf))
144-
@test contains(str, "```julia")
145-
@test contains(str, "f(x)")
146-
@test contains(str, "[`$(joinpath("DocStringExtensions", "test", "tests.jl"))")
146+
@test occursin("```julia", str)
147+
@test occursin("f(x)", str)
148+
@test occursin("[`$(joinpath("DocStringExtensions", "test", "tests.jl"))", str)
147149
end
148150

149151
@testset "method signatures" begin
@@ -154,9 +156,9 @@ end
154156
)
155157
DSE.format(SIGNATURES, buf, doc)
156158
str = String(take!(buf))
157-
@test contains(str, "\n```julia\n")
158-
@test contains(str, "\nf(x)\n")
159-
@test contains(str, "\n```\n")
159+
@test occursin("\n```julia\n", str)
160+
@test occursin("\nf(x)\n", str)
161+
@test occursin("\n```\n", str)
160162

161163
doc.data = Dict(
162164
:binding => Docs.Binding(M, :g),
@@ -165,10 +167,10 @@ end
165167
)
166168
DSE.format(SIGNATURES, buf, doc)
167169
str = String(take!(buf))
168-
@test contains(str, "\n```julia\n")
169-
@test contains(str, "\ng()\n")
170-
@test contains(str, "\ng(x)\n")
171-
@test contains(str, "\n```\n")
170+
@test occursin("\n```julia\n", str)
171+
@test occursin("\ng()\n", str)
172+
@test occursin("\ng(x)\n", str)
173+
@test occursin("\n```\n", str)
172174

173175
doc.data = Dict(
174176
:binding => Docs.Binding(M, :g),
@@ -177,12 +179,12 @@ end
177179
)
178180
DSE.format(SIGNATURES, buf, doc)
179181
str = String(take!(buf))
180-
@test contains(str, "\n```julia\n")
181-
@test contains(str, "\ng()\n")
182-
@test contains(str, "\ng(x)\n")
183-
@test contains(str, "\ng(x, y)\n")
184-
@test contains(str, "\ng(x, y, z; kwargs...)\n")
185-
@test contains(str, "\n```\n")
182+
@test occursin("\n```julia\n", str)
183+
@test occursin("\ng()\n", str)
184+
@test occursin("\ng(x)\n", str)
185+
@test occursin("\ng(x, y)\n", str)
186+
@test occursin("\ng(x, y, z; kwargs...)\n", str)
187+
@test occursin("\n```\n", str)
186188
end
187189

188190
@testset "type definitions" begin
@@ -193,9 +195,9 @@ end
193195
)
194196
DSE.format(TYPEDEF, buf, doc)
195197
str = String(take!(buf))
196-
@test contains(str, "\n```julia\n")
197-
@test contains(str, "\nabstract AbstractType <: Integer\n")
198-
@test contains(str, "\n```\n")
198+
@test occursin("\n```julia\n", str)
199+
@test occursin("\nabstract AbstractType <: Integer\n", str)
200+
@test occursin("\n```\n", str)
199201

200202
doc.data = Dict(
201203
:binding => Docs.Binding(M, :CustomType),
@@ -204,9 +206,9 @@ end
204206
)
205207
DSE.format(TYPEDEF, buf, doc)
206208
str = String(take!(buf))
207-
@test contains(str, "\n```julia\n")
208-
@test contains(str, "\nstruct CustomType{S, T<:Integer} <: Integer\n")
209-
@test contains(str, "\n```\n")
209+
@test occursin("\n```julia\n", str)
210+
@test occursin("\nstruct CustomType{S, T<:Integer} <: Integer\n", str)
211+
@test occursin("\n```\n", str)
210212

211213
doc.data = Dict(
212214
:binding => Docs.Binding(M, :BitType8),
@@ -215,9 +217,9 @@ end
215217
)
216218
DSE.format(TYPEDEF, buf, doc)
217219
str = String(take!(buf))
218-
@test contains(str, "\n```julia\n")
219-
@test contains(str, "\nbitstype 8 BitType8\n")
220-
@test contains(str, "\n```\n")
220+
@test occursin("\n```julia\n", str)
221+
@test occursin("\nbitstype 8 BitType8\n", str)
222+
@test occursin("\n```\n", str)
221223

222224
doc.data = Dict(
223225
:binding => Docs.Binding(M, :BitType32),
@@ -226,26 +228,26 @@ end
226228
)
227229
DSE.format(TYPEDEF, buf, doc)
228230
str = String(take!(buf))
229-
@test contains(str, "\n```julia\n")
230-
@test contains(str, "\nbitstype 32 BitType32 <: Real")
231-
@test contains(str, "\n```\n")
231+
@test occursin("\n```julia\n", str)
232+
@test occursin("\nbitstype 32 BitType32 <: Real", str)
233+
@test occursin("\n```\n", str)
232234
end
233235
end
234236
@testset "templates" begin
235-
let fmt = expr -> Markdown.plain(eval(:(@doc $expr)))
236-
@test contains(fmt(:(TemplateTests.K)), "(DEFAULT)")
237-
@test contains(fmt(:(TemplateTests.T)), "(TYPES)")
238-
@test contains(fmt(:(TemplateTests.f)), "(METHODS, MACROS)")
239-
@test contains(fmt(:(TemplateTests.g)), "(METHODS, MACROS)")
240-
@test contains(fmt(:(TemplateTests.@m)), "(METHODS, MACROS)")
241-
242-
@test contains(fmt(:(TemplateTests.InnerModule.K)), "(DEFAULT)")
243-
@test contains(fmt(:(TemplateTests.InnerModule.T)), "(DEFAULT)")
244-
@test contains(fmt(:(TemplateTests.InnerModule.f)), "(METHODS, MACROS)")
245-
@test contains(fmt(:(TemplateTests.InnerModule.@m)), "(MACROS)")
246-
247-
@test contains(fmt(:(TemplateTests.OtherModule.T)), "(TYPES)")
248-
@test contains(fmt(:(TemplateTests.OtherModule.@m)), "(MACROS)")
237+
let fmt = expr -> Compat.Markdown.plain(eval(:(@doc $expr)))
238+
@test occursin("(DEFAULT)", fmt(:(TemplateTests.K)))
239+
@test occursin("(TYPES)", fmt(:(TemplateTests.T)))
240+
@test occursin("(METHODS, MACROS)", fmt(:(TemplateTests.f)))
241+
@test occursin("(METHODS, MACROS)", fmt(:(TemplateTests.g)))
242+
@test occursin("(METHODS, MACROS)", fmt(:(TemplateTests.@m)))
243+
244+
@test occursin("(DEFAULT)", fmt(:(TemplateTests.InnerModule.K)))
245+
@test occursin("(DEFAULT)", fmt(:(TemplateTests.InnerModule.T)))
246+
@test occursin("(METHODS, MACROS)", fmt(:(TemplateTests.InnerModule.f)))
247+
@test occursin("(MACROS)", fmt(:(TemplateTests.InnerModule.@m)))
248+
249+
@test occursin("(TYPES)", fmt(:(TemplateTests.OtherModule.T)))
250+
@test occursin("(MACROS)", fmt(:(TemplateTests.OtherModule.@m)))
249251
@test fmt(:(TemplateTests.OtherModule.f)) == "method `f`\n"
250252
end
251253
end

0 commit comments

Comments
 (0)