Skip to content

Commit f0a258e

Browse files
st--github-actions[bot]devmotiontheogfrossviljoen
authored
Hide runtime info behind <details> (#104)
* resolves #100 * try it out for notebooks * Update docs/literate.jl * explicit html for notebook * Update docs/literate.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * pre-1.7 compat * Update docs/literate.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * add horizontal rules at top and bottom * fix notebook/documenter link discrepancy * bugfix * fix hrules * fix markdown * fixup * fix notebook formatting * use Markdown.htmlesc * separate System information section ...... * Fix file size of notebook (#103) * Fix file size of notebook * Fix format Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Change comment Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * CompatHelper: bump compat for "GPLikelihoods" to "0.3" (#107) * CompatHelper: bump compat for "GPLikelihoods" to "0.3" * Reorder Gamma parametrization * Update project versions * Missing one Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Théo Galy-Fajou <[email protected]> * Fix outdated `literate.jl` script (#111) * Fix outdated `literate.jl` script * Fix format * Split code into submodules for the different approximations (#96) * stab at submodules * move approx_lml to API * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * clean up imports * remove unused imports * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * docfix * missing import * test: remove submodules from api docs * subpages in docs * hide private API docstrings * mention types in api/index.md * qualify * remove extra line * minor bump# * change docs/ compat * update test compat * explicitly `@reexport` to avoid exporting the submodules! * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * add likelihood imports * add import * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * add import * Update src/SparseVariationalApproximationModule.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Rename the test files (#113) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: David Widmann <[email protected]> Co-authored-by: Théo Galy-Fajou <[email protected]> Co-authored-by: Ross Viljoen <[email protected]>
1 parent e8513ad commit f0a258e

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

docs/literate.jl

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@ Pkg.instantiate()
1616
pkg_status = sprint() do io
1717
Pkg.status(; io=io)
1818
end
19-
manifest_status = sprint() do io
20-
Pkg.status(; io=io, mode=Pkg.PKGMODE_MANIFEST)
21-
end
2219

2320
using Literate: Literate
2421

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

26+
using Markdown: htmlesc
27+
2928
function 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
8785
end
8886

8987
# Convert to markdown and notebook

0 commit comments

Comments
 (0)