Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Manifest.toml and append package version at the end of the examples #97

Merged
merged 18 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ tmp/
*.jld2
*.cov
*.info
/test/Manifest.toml
/Manifest.toml
Manifest.toml
theogf marked this conversation as resolved.
Show resolved Hide resolved
44 changes: 43 additions & 1 deletion docs/literate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@ const OUTDIR = ARGS[2]
# Activate environment
# Note that each example's Project.toml must include Literate as a dependency
using Pkg: Pkg

using InteractiveUtils
const EXAMPLEPATH = joinpath(@__DIR__, "..", "examples", EXAMPLE)
Pkg.activate(EXAMPLEPATH)
Pkg.instantiate()
pkg_status = sprint() do io
Pkg.status(; io=io)
end
manifest_status = sprint() do io
Pkg.status(; io=io, mode=Pkg.PKGMODE_MANIFEST)
end

using Literate: Literate

const MANIFEST_OUT = joinpath(EXAMPLE, "Manifest.toml")
mkpath(joinpath(OUTDIR, EXAMPLE))
cp(joinpath(EXAMPLEPATH, "Manifest.toml"), joinpath(OUTDIR, MANIFEST_OUT); force=true)

function preprocess(content)
# Add link to nbviewer below the first heading of level 1
sub = SubstitutionString(
Expand Down Expand Up @@ -40,7 +53,36 @@ function preprocess(content)
# remove VSCode `##` block delimiter lines
content = replace(content, r"^##$."ms => "")

return content
# adds the current version of the packages
append = """
# ### Package and system information
# #### Package version
# ```julia
$(chomp(replace(pkg_status, r"^"m => "# ")))
# ```
# #### Computer information
# ```julia
theogf marked this conversation as resolved.
Show resolved Hide resolved
$(chomp(replace(sprint(InteractiveUtils.versioninfo), r"^"m => "# ")))
# ```
# #### Manifest
""" *
# ```@raw html
# <details>
theogf marked this conversation as resolved.
Show resolved Hide resolved
# <summary> Show the full Manifest </summary>
# ```
# ```julia
# $(chomp(replace(manifest_status, r"^"m => "# ")))
# ```
# ```@raw html
# </details>
# ```
"""
# ---
# [Manifest.toml]($(MANIFEST_OUT)) for this notebook's package environment
"""
theogf marked this conversation as resolved.
Show resolved Hide resolved
# This regex add "# " at the beginning of each line
# chomp removes trailing newlines
return content * append
end

function md_postprocess(content)
Expand Down
Loading