Browse Source

Upgrade to Julia v0.7 (#14)

pull/18/head
Fredrik Ekre 8 years ago committed by GitHub
parent
commit
11175059bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 17
      .travis.yml
  3. 11
      Project.toml
  4. 3
      REQUIRE
  5. 18
      appveyor.yml
  6. 10
      docs/make.jl
  7. 7
      docs/src/outputformats.md
  8. 2
      examples/example.jl
  9. 22
      src/Documenter.jl
  10. 3
      src/IJulia.jl
  11. 28
      src/Literate.jl
  12. 6
      test/coverage.jl
  13. 8
      test/runtests.jl

1
.gitignore vendored

@ -2,3 +2,4 @@
*.jl.*.cov *.jl.*.cov
*.jl.mem *.jl.mem
*.DS_Store *.DS_Store
Manifest.toml

17
.travis.yml

@ -4,13 +4,11 @@ os:
- linux - linux
- osx - osx
julia: julia:
- 0.6
- 0.7 - 0.7
- nightly - nightly
matrix: # matrix:
allow_failures: # allow_failures:
- julia: nightly # - julia: nightly
- julia: 0.7
branches: branches:
only: only:
- master - master
@ -18,16 +16,13 @@ branches:
jobs: jobs:
include: include:
- stage: deploy - stage: deploy
julia: 0.6 julia: nightly
os: linux os: linux
script: script:
- julia -e 'Pkg.clone(pwd()); Pkg.build("Literate")' - julia docs/make.jl
- julia -e 'Pkg.add("Documenter"); Pkg.add("Plots"); Pkg.build("Plots")'
- julia -e 'cd(Pkg.dir("Literate")); include("docs/make.jl")'
notifications: notifications:
email: false email: false
git: git:
depth: 99999999 depth: 99999999
after_success: after_success:
# push coverage results to Codecov - julia test/coverage.jl
- julia -e 'cd(Pkg.dir("Literate")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'

11
Project.toml

@ -0,0 +1,11 @@
name = "Literate"
uuid = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
version = "0.2.2"
[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
[targets.test.deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

3
REQUIRE

@ -1,3 +1,2 @@
julia 0.6 julia 0.7.0-alpha
JSON JSON
Compat

18
appveyor.yml

@ -1,14 +1,15 @@
environment: environment:
JULIA_PROJECT: "@."
matrix: matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe" - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe" - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
matrix: # matrix:
allow_failures: # allow_failures:
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" # - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" # - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
branches: branches:
only: only:
@ -38,8 +39,7 @@ install:
build_script: build_script:
# Need to convert from shallow to complete for Pkg.clone to work # Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow) - IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo(); - C:\projects\julia\bin\julia -e "using InteractiveUtils; versioninfo(); Pkg.build()"
Pkg.clone(pwd(), \"Literate\"); Pkg.build(\"Literate\")"
test_script: test_script:
- C:\projects\julia\bin\julia -e "Pkg.test(\"Literate\")" - C:\projects\julia\bin\julia -e "Pkg.test()"

10
docs/make.jl

@ -1,10 +1,10 @@
using Pkg
pkg"add Documenter Plots#master GR#master"
pkg"precompile"
using Documenter using Documenter
using Literate using Literate
# import these to make sure they precompile here instead of when generating output
import Plots
import GR
# generate examples # generate examples
EXAMPLE = joinpath(@__DIR__, "..", "examples", "example.jl") EXAMPLE = joinpath(@__DIR__, "..", "examples", "example.jl")
OUTPUT = joinpath(@__DIR__, "src/generated") OUTPUT = joinpath(@__DIR__, "src/generated")
@ -53,7 +53,7 @@ deploydocs(
repo = "github.com/fredrikekre/Literate.jl.git", repo = "github.com/fredrikekre/Literate.jl.git",
target = "build", target = "build",
osname = "linux", osname = "linux",
julia = "0.6", julia = "nightly",
deps = nothing, deps = nothing,
make = nothing make = nothing
) )

7
docs/src/outputformats.md

@ -4,6 +4,7 @@ When the source is parsed, and have been processed it is time to render the outp
We will consider the following source snippet: We will consider the following source snippet:
```@eval ```@eval
import Markdown
Markdown.parse("```julia\n" * rstrip(read("outputformats.jl", String)) * "\n```") Markdown.parse("```julia\n" * rstrip(read("outputformats.jl", String)) * "\n```")
``` ```
@ -14,7 +15,8 @@ and see how this is rendered in each of the output formats.
The (default) markdown output of the source snippet above is as follows The (default) markdown output of the source snippet above is as follows
```@eval ```@eval
file = joinpath(@__DIR__, "src/generated/name.md") import Markdown
file = joinpath(@__DIR__, "../src/generated/name.md")
str = "````markdown\n" * rstrip(read(file, String)) * "\n````" str = "````markdown\n" * rstrip(read(file, String)) * "\n````"
rm(file) rm(file)
Markdown.parse(str) Markdown.parse(str)
@ -55,7 +57,8 @@ Literate.notebook
The (default) script output of the source snippet above is as follows The (default) script output of the source snippet above is as follows
```@eval ```@eval
file = joinpath(@__DIR__, "src/generated/outputformats.jl") import Markdown
file = joinpath(@__DIR__, "../src/generated/outputformats.jl")
str = "```julia\n" * rstrip(read(file, String)) * "\n```" str = "```julia\n" * rstrip(read(file, String)) * "\n```"
rm(file) rm(file)
Markdown.parse(str) Markdown.parse(str)

2
examples/example.jl

@ -64,7 +64,7 @@ foo()
# [Plots.jl](https://github.com/JuliaPlots/Plots.jl) package # [Plots.jl](https://github.com/JuliaPlots/Plots.jl) package
using Plots using Plots
x = linspace(0, 6π, 1000) x = range(0, stop=6π, length=1000)
y1 = sin.(x) y1 = sin.(x)
y2 = cos.(x) y2 = cos.(x)
plot(x, [y1, y2]) plot(x, [y1, y2])

22
src/Documenter.jl

@ -2,22 +2,6 @@
# (https://github.com/JuliaDocs/Documenter.jl), see LICENSE.md for license # (https://github.com/JuliaDocs/Documenter.jl), see LICENSE.md for license
module Documenter module Documenter
using Compat: stdout, stderr, Cvoid
@static if VERSION < v"0.7.0-DEV.3951"
link_pipe!(pipe; reader_supports_async = true, writer_supports_async = true) =
Base.link_pipe(pipe, julia_only_read = reader_supports_async, julia_only_write = writer_supports_async)
else
import Base: link_pipe!
end
@static if isdefined(Base, :with_logger)
using Logging
else # make things a no-op since warnings/info already print to stdout
struct ConsoleLogger end
ConsoleLogger(io) = ConsoleLogger()
with_logger(f, logger) = f()
end
function withoutput(f) function withoutput(f)
# Save the default output streams. # Save the default output streams.
default_stdout = stdout default_stdout = stdout
@ -25,18 +9,18 @@ function withoutput(f)
# Redirect both the `stdout` and `stderr` streams to a single `Pipe` object. # Redirect both the `stdout` and `stderr` streams to a single `Pipe` object.
pipe = Pipe() pipe = Pipe()
link_pipe!(pipe; reader_supports_async = true, writer_supports_async = true) Base.link_pipe!(pipe; reader_supports_async = true, writer_supports_async = true)
redirect_stdout(pipe.in) redirect_stdout(pipe.in)
redirect_stderr(pipe.in) redirect_stderr(pipe.in)
# Also redirect logging stream to the same pipe # Also redirect logging stream to the same pipe
logger = ConsoleLogger(pipe.in) logger = Base.CoreLogging.SimpleLogger(pipe.in)
# Bytes written to the `pipe` are captured in `output` and converted to a `String`. # Bytes written to the `pipe` are captured in `output` and converted to a `String`.
output = UInt8[] output = UInt8[]
# Run the function `f`, capturing all output that it might have generated. # Run the function `f`, capturing all output that it might have generated.
# Success signals whether the function `f` did or did not throw an exception. # Success signals whether the function `f` did or did not throw an exception.
result, success, backtrace = with_logger(logger) do result, success, backtrace = Base.CoreLogging.with_logger(logger) do
try try
f(), true, Vector{Ptr{Cvoid}}() f(), true, Vector{Ptr{Cvoid}}()
catch err catch err

3
src/IJulia.jl

@ -1,8 +1,7 @@
# this file contains some utilities copied from the IJulia.jl package # this file contains some utilities copied from the IJulia.jl package
# (https://github.com/JuliaLang/IJulia.jl), see LICENSE.md for license # (https://github.com/JuliaLang/IJulia.jl), see LICENSE.md for license
module IJulia module IJulia
using Compat.Base64 using Base64
import Compat: showable
const text_plain = MIME("text/plain") const text_plain = MIME("text/plain")
const image_svg = MIME("image/svg+xml") const image_svg = MIME("image/svg+xml")

28
src/Literate.jl

@ -1,9 +1,7 @@
__precompile__() __precompile__()
module Literate module Literate
import Compat: replace, popfirst!, @error, @info, occursin import JSON, REPL
import JSON
include("IJulia.jl") include("IJulia.jl")
import .IJulia import .IJulia
@ -319,11 +317,23 @@ function markdown(inputfile, outputdir; preprocess = identity, postprocess = ide
# run some Documenter specific things # run some Documenter specific things
if documenter if documenter
# change the Edit on GitHub link # change the Edit on GitHub link
repo = get(ENV, "TRAVIS_REPO_SLUG", "") repo = get(ENV, "TRAVIS_REPO_SLUG", nothing)
pkg = first(split(last(split(repo, '/')), '.')) if repo === nothing
path = ""
else
pkg = String(first(split(last(split(repo, '/')), '.')))
pkgsrc = Base.find_package(pkg)
if pkgsrc === nothing
path = ""
else
repo_root = first(split(pkgsrc, joinpath("src", pkg * ".jl")))
path = relpath(inputfile, repo_root)
path = replace(path, "\\" => "/")
end
end
content = """ content = """
# ```@meta # ```@meta
# EditURL = "@__REPO_ROOT_URL__$(replace(relpath(inputfile, Pkg.dir(pkg)), "\\" => "/"))" # EditURL = "@__REPO_ROOT_URL__$(path)"
# ``` # ```
""" * content """ * content
@ -516,12 +526,12 @@ function execute_notebook(nb)
stream = Dict{String,Any}() stream = Dict{String,Any}()
stream["output_type"] = "stream" stream["output_type"] = "stream"
stream["name"] = "stdout" stream["name"] = "stdout"
stream["text"] = collect(Any, eachline(IOBuffer(String(str)), chomp = false)) # 0.7 chomp = false => keep = true stream["text"] = collect(Any, eachline(IOBuffer(String(str)), keep = true))
push!(cell["outputs"], stream) push!(cell["outputs"], stream)
end end
# check if ; is used to suppress output # check if ; is used to suppress output
r = Base.REPL.ends_with_semicolon(block) ? nothing : r r = REPL.ends_with_semicolon(block) ? nothing : r
# r should go into execute_result # r should go into execute_result
if r !== nothing if r !== nothing
@ -533,7 +543,7 @@ function execute_notebook(nb)
# we need to split some mime types into vectors of lines instead of a single string # we need to split some mime types into vectors of lines instead of a single string
for mime in ("image/svg+xml", "text/html") for mime in ("image/svg+xml", "text/html")
if haskey(dd, mime) if haskey(dd, mime)
dd[mime] = collect(Any, eachline(IOBuffer(dd[mime]), chomp = false)) dd[mime] = collect(Any, eachline(IOBuffer(dd[mime]), keep = true))
end end
end end
execute_result["data"] = dd execute_result["data"] = dd

6
test/coverage.jl

@ -0,0 +1,6 @@
using Pkg
Pkg.add("Coverage")
using Coverage
cd(joinpath(@__DIR__, "..")) do
Codecov.submit(Codecov.process_folder())
end

8
test/runtests.jl

@ -1,8 +1,6 @@
import Literate import Literate
import Literate: Chunk, MDChunk, CodeChunk import Literate: Chunk, MDChunk, CodeChunk
import Compat using Test
import Compat: occursin
using Compat.Test
# compare content of two parsed chunk vectors # compare content of two parsed chunk vectors
function compare_chunks(chunks1, chunks2) function compare_chunks(chunks1, chunks2)
@ -539,7 +537,7 @@ end
lastidx = 1 lastidx = 1
for cell in expected_cells for cell in expected_cells
idx = Compat.findnext(cell, notebook, lastidx) idx = findnext(cell, notebook, lastidx)
@test idx !== nothing @test idx !== nothing
lastidx = nextind(notebook, last(idx)) lastidx = nextind(notebook, last(idx))
end end
@ -619,7 +617,7 @@ end
lastidx = 1 lastidx = 1
for out in expected_outputs for out in expected_outputs
idx = Compat.findnext(out, notebook, lastidx) idx = findnext(out, notebook, lastidx)
@test idx !== nothing @test idx !== nothing
lastidx = nextind(notebook, last(idx)) lastidx = nextind(notebook, last(idx))
end end

Loading…
Cancel
Save