From 1b4f3f2b1702386cc9d369444fe1be748380feb5 Mon Sep 17 00:00:00 2001 From: Wen Wei Tseng Date: Fri, 25 Oct 2024 10:12:29 +0800 Subject: [PATCH] Try MarkdownTables --- .github/workflows/ci.yml | 2 +- ci.jl | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d89d6c3..ff91a5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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() diff --git a/ci.jl b/ci.jl index 04ed6ac..a5df3c1 100644 --- a/ci.jl +++ b/ci.jl @@ -1,5 +1,6 @@ using Distributed -using PrettyTables +using Tables +using MarkdownTables using SHA using IJulia @@ -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") @@ -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 @@ -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[] @@ -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) @@ -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) @@ -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