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 4 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
24 changes: 22 additions & 2 deletions docs/literate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ using Pkg: Pkg
const EXAMPLEPATH = joinpath(@__DIR__, "..", "examples", EXAMPLE)
Pkg.activate(EXAMPLEPATH)
Pkg.instantiate()
pkg_status = sprint() do io
Pkg.status(;io=io)
theogf marked this conversation as resolved.
Show resolved Hide resolved
theogf marked this conversation as resolved.
Show resolved Hide resolved
end
manifest_status = sprint() do io
Pkg.status(;io=io, mode=Pkg.PKGMODE_MANIFEST)
theogf marked this conversation as resolved.
Show resolved Hide resolved
theogf marked this conversation as resolved.
Show resolved Hide resolved
theogf marked this conversation as resolved.
Show resolved Hide resolved
end

using Literate: Literate

function preprocess(content)
Expand Down Expand Up @@ -39,8 +46,21 @@ function preprocess(content)

# remove VSCode `##` block delimiter lines
content = replace(content, r"^##$."ms => "")

return content
# adds the current version of the packages
append = """
# ### Package information
# #### Package version
# ```julia
$(chomp(replace(pkg_status, r"^"m => "# ")))
# ```
# #### Manifest
# ```julia
theogf marked this conversation as resolved.
Show resolved Hide resolved
$(chomp(replace(manifest_status, r"^"m => "# ")))
# ```
"""
# This regex add "# " at the beginning of each line
# chomp removes trailing newlines
return content * append
end

function md_postprocess(content)
Expand Down
Loading