Skip to content

Commit

Permalink
Merge pull request #616 from JuliaDocs/backports-0.12.5
Browse files Browse the repository at this point in the history
Backports for 0.12.5
  • Loading branch information
mortenpi authored Dec 29, 2017
2 parents b9d42a3 + d7b2cd8 commit 2fbec9a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ makedocs(
"lib/internals/generator.md",
"lib/internals/mdflatten.md",
"lib/internals/selectors.md",
"lib/internals/textdiff.md",
"lib/internals/utilities.md",
"lib/internals/walkers.md",
"lib/internals/writers.md",
Expand Down
5 changes: 5 additions & 0 deletions docs/src/lib/internals/textdiff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# TextDiff

```@autodocs
Modules = [Documenter.Utilities.TextDiff]
```
1 change: 1 addition & 0 deletions src/Documents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ..Documenter:
Utilities

using Compat, DocStringExtensions
using Compat.Unicode

# Pages.
# ------
Expand Down
2 changes: 1 addition & 1 deletion src/Expanders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ function Selectors.runner(::Type{ExampleBlocks}, x, page, doc)
for (ex, str) in Utilities.parseblock(x.code, doc, page)
(value, success, backtrace, text) = Utilities.withoutput() do
cd(dirname(page.build)) do
eval(mod, :(ans = $(eval(mod, ex))))
eval(mod, Expr(:(=), :ans, ex))
end
end
result = value
Expand Down
16 changes: 12 additions & 4 deletions src/Utilities/TextDiff.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module TextDiff

using Compat
using DocStringExtensions

# Utilities.

Expand Down Expand Up @@ -39,14 +40,21 @@ function makediff!(out, weights, X, Y, i, j)
return out
end

"""
$(SIGNATURES)
Splits `text` at `regex` matches, returning an array of substrings. The parts of the string
that match the regular expression are also included at the ends of the returned strings.
"""
function splitby(reg::Regex, text::AbstractString)
out = SubString{String}[]
last = 1
token_first = 1
for each in eachmatch(reg, text)
push!(out, SubString(text, last, each.match.offset + each.match.endof))
last = each.match.endof + each.offset
token_last = each.offset + endof(each.match) - 1
push!(out, SubString(text, token_first, token_last))
token_first = nextind(text, token_last)
end
laststr = SubString(text, last)
laststr = SubString(text, token_first)
isempty(laststr) || push!(out, laststr)
return out
end
Expand Down
6 changes: 6 additions & 0 deletions test/examples/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ julia> x->x # ignore error on 0.7
#1 (generic function with 1 method)
```

# Assigning symbols example

```@example
r = :a
```

# Bad links (Windows)

* [Colons not allowed on Windows -- `some:path`](some:path)
Expand Down
2 changes: 1 addition & 1 deletion test/examples/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
@test doc.user.clean == true
@test doc.user.format == [:markdown]

@test doc.internal.assets == normpath(joinpath(dirname(@__FILE__), "..", "..", "assets"))
@test realpath(doc.internal.assets) == realpath(joinpath(dirname(@__FILE__), "..", "..", "assets"))

@test length(doc.internal.pages) == 10

Expand Down
11 changes: 11 additions & 0 deletions test/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ end
@test exprs[3][1] === :γγγ
@test exprs[3][2] == "γγγ\n"
end

@testset "TextDiff" begin
import Documenter.Utilities.TextDiff: splitby
@test splitby(r"\s+", "X Y Z") == ["X ", "Y ", "Z"]
@test splitby(r"[~]", "X~Y~Z") == ["X~", "Y~", "Z"]
@test splitby(r"[▶]", "X▶Y▶Z") == ["X▶", "Y▶", "Z"]
@test splitby(r"[▶]+", "X▶▶Y▶Z▶") == ["X▶▶", "Y▶", "Z▶"]
@test splitby(r"[▶]+", "▶▶Y▶Z▶") == ["▶▶", "Y▶", "Z▶"]
@test splitby(r"[▶]+", "Ω▶▶Y▶Z▶") == ["Ω▶▶", "Y▶", "Z▶"]
@test splitby(r"[▶]+", "Ω▶▶Y▶Z▶κ") == ["Ω▶▶", "Y▶", "Z▶", "κ"]
end
end

end

0 comments on commit 2fbec9a

Please sign in to comment.