Skip to content

Commit

Permalink
Try MarkdownTables
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiristseng committed Oct 25, 2024
1 parent 77f55e5 commit 1b4f3f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
shell: julia --color=yes {0}
run: |
using Pkg
Pkg.add(["IJulia", "Literate", "PrettyTables", "JSON"])
Pkg.add(["IJulia", "Literate", "Tables", "MarkdownTables", "JSON"])
Pkg.activate(".")
Pkg.instantiate()
Pkg.precompile()
Expand Down
13 changes: 8 additions & 5 deletions ci.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Distributed
using PrettyTables
using Tables
using MarkdownTables
using SHA
using IJulia

Expand All @@ -8,7 +9,7 @@ using IJulia
using Literate, Pkg, JSON
end

# Strip SVG output from a Jupyter notebook
"Strip SVG output from a Jupyter notebook"
@everywhere function strip_svg(ipynb)
@info "Stripping SVG in $(ipynb)"
nb = open(JSON.parse, ipynb, "r")
Expand All @@ -30,7 +31,7 @@ end
return ipynb
end

# Remove cached notebook and sha files if there is no corresponding notebook
"Remove cached notebook and sha files if there is no corresponding notebook"
function clean_cache(cachedir)
for (root, dirs, files) in walkdir(cachedir)
for file in files
Expand All @@ -48,6 +49,7 @@ function clean_cache(cachedir)
end
end

"Recursively list Jupyter and Literate notebooks. Also process caching."
function list_notebooks(basedir, cachedir)
ipynbs = String[]
litnbs = String[]
Expand Down Expand Up @@ -77,6 +79,7 @@ function list_notebooks(basedir, cachedir)
return (; ipynbs, litnbs)
end

"Run a Literate.jl notebook"
@everywhere function run_literate(file, cachedir; rmsvg=true)
outpath = joinpath(abspath(pwd()), cachedir, dirname(file))
mkpath(outpath)
Expand All @@ -88,7 +91,7 @@ end
function main(;
basedir=get(ENV, "DOCDIR", "docs"),
cachedir=get(ENV, "NBCACHE", ".cache"),
printtable=true, rmsvg=true)
rmsvg=true)

mkpath(cachedir)
clean_cache(cachedir)
Expand Down Expand Up @@ -144,7 +147,7 @@ function main(;
end

# Print execution result
printtable && pretty_table([litnbs ts_lit; ipynbs ts_ipynb], header=["Notebook", "Elapsed (s)"])
Tables.table([litnbs ts_lit; ipynbs ts_ipynb]; header=["Notebook", "Elapsed (s)"]) |> markdown_table(String) |> print
end

# Run code
Expand Down

0 comments on commit 1b4f3f2

Please sign in to comment.