@@ -16,16 +16,15 @@ Pkg.instantiate()
1616pkg_status = sprint () do io
1717 Pkg. status (; io= io)
1818end
19- manifest_status = sprint () do io
20- Pkg. status (; io= io, mode= Pkg. PKGMODE_MANIFEST)
21- end
2219
2320using Literate: Literate
2421
2522const MANIFEST_OUT = joinpath (EXAMPLE, " Manifest.toml" )
2623mkpath (joinpath (OUTDIR, EXAMPLE))
2724cp (joinpath (EXAMPLEPATH, " Manifest.toml" ), joinpath (OUTDIR, MANIFEST_OUT); force= true )
2825
26+ using Markdown: htmlesc
27+
2928function preprocess (content)
3029 # Add link to nbviewer below the first heading of level 1
3130 sub = SubstitutionString (
@@ -45,6 +44,8 @@ function preprocess(content)
4544# [Julia source file](@__REPO_ROOT_URL__/examples/@__NAME__/script.jl).
4645#md # The corresponding notebook can be viewed in [nbviewer](@__NBVIEWER_ROOT_URL__/examples/@__NAME__.ipynb).*
4746#nb # The rendered HTML can be viewed [in the docs](https://juliagaussianprocesses.github.io/ApproximateGPs.jl/dev/examples/@__NAME__/).*
47+ #
48+ #md # ---
4849#
4950 """ ,
5051 )
@@ -53,37 +54,34 @@ function preprocess(content)
5354 # remove VSCode `##` block delimiter lines
5455 content = replace (content, r" ^##$." ms => " " )
5556
56- # adds the current version of the packages
57- append = """
58- # ### Package and system information
59- # #### Package version
60- # ```julia
61- $(chomp (replace (pkg_status, r" ^" m => " # " )))
62- # ```
63- # #### Computer information
64- # ```
65- $(chomp (replace (sprint (InteractiveUtils. versioninfo), r" ^" m => " # " )))
66- # ```
67- # #### Manifest
68- # To reproduce this notebook's package environment, you can [download the full Manifest.toml]($(MANIFEST_OUT) ).
69- """
70- # This regex add "# " at the beginning of each line
71- # chomp removes trailing newlines
57+ """ The regex adds "# " at the beginning of each line; chomp removes trailing newlines """
58+ literate_format (s) = chomp (replace (s, r" ^" m => " # " ))
7259
73- # The following gives a preview of the manifest
74- # embedded in a "spoiler", but this is unfortunately very buggy
75- # ```@raw html
60+ # <details></details> seems to be buggy in the notebook, so is avoided for now
61+ info_footer = """
62+ #md # ```@raw html
63+ # <hr />
64+ # <h6>Package and system information</h6>
7665 # <details>
77- # <summary> Show the full Manifest </summary>
78- # ```
79- # ```julia
80- # $(chomp(replace(manifest_status, r"^"m => "# ")))
81- # ```
82- # ```@raw html
66+ # <summary>Package information (click to expand)</summary>
67+ # <pre>
68+ $(literate_format (htmlesc (pkg_status)))
69+ # </pre>
70+ # To reproduce this notebook's package environment, you can
71+ #nb # <a href="$(MANIFEST_OUT) ">
72+ #md # <a href="../$(MANIFEST_OUT) ">
73+ # download the full Manifest.toml</a>.
8374 # </details>
84- # ```
75+ # <details>
76+ # <summary>System information (click to expand)</summary>
77+ # <pre>
78+ $(literate_format (htmlesc (sprint (InteractiveUtils. versioninfo))))
79+ # </pre>
80+ # </details>
81+ #md # ```
82+ """
8583
86- return content * append
84+ return content * info_footer
8785end
8886
8987# Convert to markdown and notebook
0 commit comments