Skip to content

Commit f1e43f4

Browse files
authored
Kaleido (#342)
* ENH: use PlotlyBase's Kaleido for savefig * OPS: add pkg-butler * DEPS: depend on plotlyBase 0.4 * ENH: delete pkg-butler -- we need special CI * ENH: update travis settings * WIP: migrate docs to Documenter.jl instead of mkdocs
1 parent 49fe3b3 commit f1e43f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3523
-5300
lines changed

.github/workflows/deploy_docs.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Deploy documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- v*
9+
10+
jobs:
11+
docdeploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: julia-actions/julia-buildpkg@latest
16+
env:
17+
PYTHON: ""
18+
- uses: julia-actions/julia-docdeploy@releases/v1
19+
env:
20+
DOCUMENTER_KEY: ${{ secrets.JLPKGBUTLER_TOKEN }}
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# Documentation: http://docs.travis-ci.com/user/languages/julia/
2-
language: julia
3-
sudo: required
4-
os:
5-
- linux
6-
julia:
7-
- 1.3
1+
# Documentation: http://docs.travis-ci.com/user/languages/julia/
2+
language: julia
3+
sudo: required
4+
os:
5+
- linux
6+
julia:
7+
- 1.3
88
- 1.4
9-
- nightly
10-
matrix:
11-
allow_failures:
12-
- julia: nightly
13-
addons:
14-
apt:
15-
packages:
16-
- xvfb
17-
- xauth
18-
- libgtk-3-0
19-
notifications:
20-
email: false
21-
# uncomment the following lines to override the default test script
22-
script:
23-
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
24-
- xvfb-run julia -e 'using Pkg; Pkg.build(); Pkg.test(coverage=true)'
9+
- 1.5
10+
- nightly
11+
matrix:
12+
allow_failures:
13+
- julia: nightly
14+
addons:
15+
apt:
16+
packages:
17+
- xvfb
18+
- xauth
19+
- libgtk-3-0
20+
notifications:
21+
email: false
22+
# uncomment the following lines to override the default test script
23+
script:
24+
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi

CHANGELOG.md

Lines changed: 498 additions & 210 deletions
Large diffs are not rendered by default.

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PlotlyJS"
22
uuid = "f0f68f2c-4968-5e81-91da-67840de0976a"
33
authors = ["Spencer Lyon <[email protected]>"]
4-
version = "0.13.1"
4+
version = "0.14.0"
55

66
[deps]
77
Blink = "ad839575-38b3-5650-b840-f874b8c74a25"
@@ -22,7 +22,7 @@ Blink = "≥ 0.8.0"
2222
Compat = "≥ 0.69.0"
2323
JSExpr = "0.5"
2424
JSON = "≥ 0.7.0"
25-
PlotlyBase = "0.4.0"
25+
PlotlyBase = "0.4"
2626
Reexport = "≥ 0.2.0"
2727
Requires = "1.0"
2828
WebIO = "≥ 0.8.6"

deploy_docs.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
site/

docs/Project.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[deps]
2+
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
3+
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
4+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
5+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
6+
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
7+
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
8+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
9+
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
10+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
11+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
12+
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
13+
RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b"
14+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
15+
16+
[compat]
17+
PlotlyBase = "0.4.1"

docs/build_example_docs.jl

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,69 +5,81 @@ puts each example from the julia file into a code block and adds
55
a short html div below with the interactive output.
66
=#
77
using PlotlyJS
8-
using Distributions, Quandl, RDatasets # used in examples
98

10-
doc_style = Style(layout=Layout(margin=attr(t=60, b=60, l=50, r=50)))
9+
# used in examples
10+
using Distributions, HTTP, DataFrames, RDatasets, Colors, CSV, JSON
11+
using Random, Dates, LinearAlgebra, DelimitedFiles
1112

12-
# Read all file names in
13-
this_dir = dirname(@__FILE__)
14-
if length(ARGS) == 0
15-
all_file_names = readdir(joinpath(this_dir, "..", "examples"))
16-
else
17-
all_file_names = [endswith(i, ".jl") ? i : "$(i).jl" for i in ARGS]
18-
end
19-
20-
nfiles = length(all_file_names)
2113

22-
# Check whether files are julia files and select julia files
23-
cft(x) = x[end-2:end]==".jl" ? true : false
24-
am_i_julia_file = map(cft, all_file_names)
25-
all_julia_files = all_file_names[am_i_julia_file]
26-
for i in all_julia_files
27-
println(i)
28-
include(joinpath(this_dir, "..", "examples", i))
29-
end
14+
const THIS_DIR = dirname(@__FILE__)
3015

31-
use_style!(doc_style)
3216

3317
# Walk through each example in a file and get the markdown from `single_example`
34-
function single_file(filename::String)
18+
function single_example_file(filename::String)
19+
base_fn = split(filename, ".")[1]
20+
start_example = "```@example $(base_fn)"
21+
end_example = "```"
3522
# Open a file to write to
36-
open(joinpath(this_dir, "examples", filename[1:end-3]*".md"), "w") do outfile
23+
open(joinpath(THIS_DIR, "src", "examples", "$(base_fn).md"), "w") do outfile
3724

38-
# Read lines from a files
39-
fulltext = open(f->read(f, String), joinpath(this_dir, "..", "examples", filename), "r")
40-
all_lines = split(fulltext, "\n")
41-
l = 1
42-
regex = r"^function ([^_].+?)\("
43-
regex_end = r"^end$"
25+
write_example(ex) = println(outfile, start_example, "\n", ex, "\n", end_example, "\n")
4426

45-
while true
46-
# Find next function name (break if none)
47-
l = findnext(x -> match(regex, x) != nothing, all_lines, l+1)
48-
if l == 0
49-
break
50-
end
51-
# find corresponding end for this function
52-
end_l = findnext(x -> match(regex_end, x) != nothing, all_lines, l+1)
27+
fn_h1 = titlecase(replace(base_fn, "_" => " "))
28+
println(outfile, "# $(fn_h1)\n")
5329

54-
# Pull out function text
55-
func_block = join(all_lines[l:end_l], "\n")
56-
fun_name = match(regex, all_lines[l])[1]
30+
# Read lines from a files
31+
fulltext = open(
32+
f->read(f, String),
33+
joinpath(THIS_DIR, "..", "examples", filename),
34+
"r"
35+
)
36+
all_lines = split(fulltext, "\n")
37+
l = 1
38+
regex = r"^function ([^_].+?)\("
39+
regex_end = r"^end$"
5740

58-
println("adding $fun_name")
41+
# find preamble
42+
if base_fn == "subplots" # special case
43+
preamble = "using PlotlyJS, Dates\ninclude(\"../../../examples/line_scatter.jl\")"
44+
write_example(preamble)
45+
else
46+
first_line = findfirst(x -> match(regex, x) !== nothing, all_lines)
47+
if first_line !== nothing
48+
preamble = strip(join(all_lines[1:first_line-1], "\n"))
49+
write_example(preamble)
50+
end
51+
end
5952

60-
# Get html block
61-
plt = eval(Expr(:call, Symbol(fun_name))).plot
62-
relayout!(plt, margin=attr(t=60, b=60, l=50, r=50))
63-
html_block = PlotlyJS.html_body(plt)
53+
while true
54+
# Find next function name (break if none)
55+
l = findnext(x -> match(regex, x) !== nothing, all_lines, l+1)
56+
if l == 0 || l === nothing
57+
break
58+
end
59+
# find corresponding end for this function
60+
end_l = findnext(x -> match(regex_end, x) !== nothing, all_lines, l+1)
6461

65-
println(outfile, "```julia\n$func_block\n$(fun_name)()\n```\n\n\n$html_block\n\n")
66-
l = end_l
67-
end
62+
# Pull out function text
63+
func_block = join(all_lines[l:end_l], "\n")
64+
fun_name = match(regex, all_lines[l])[1]
65+
# println("adding $fun_name")
66+
an_ex = string(func_block, "\n", fun_name, "()")
67+
write_example(an_ex)
68+
l = end_l
69+
end
6870
end # do outfile
6971

7072
return nothing
7173
end
7274

73-
main() = map(single_file, all_julia_files)
75+
function main()
76+
# Read all file names in
77+
if length(ARGS) == 0
78+
all_file_names = readdir(joinpath(THIS_DIR, "..", "examples"))
79+
else
80+
all_file_names = [endswith(i, ".jl") ? i : "$(i).jl" for i in ARGS]
81+
end
82+
all_julia_files = filter(x -> endswith(x, ".jl"), all_file_names)
83+
84+
foreach(single_example_file, all_julia_files)
85+
end

0 commit comments

Comments
 (0)