From 393749388019125269aad0a7a4c9236a1fb71b26 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 10 Mar 2026 16:19:26 +0530 Subject: [PATCH 1/7] Add Google Colab supported notebooks for examples --- GeneralisedFilters/docs/literate.jl | 63 ++++++++++++++++++++++++++++- README.md | 11 +++++ SSMProblems/docs/literate.jl | 63 ++++++++++++++++++++++++++++- 3 files changed, 133 insertions(+), 4 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index feb1e47b..d730c0fd 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -14,6 +14,65 @@ Pkg.activate(EXAMPLEPATH) Pkg.instantiate() using Literate: Literate +function insert_colab_preamble(content) + # Extract dependencies from Project.toml + project_toml_path = joinpath(EXAMPLEPATH, "Project.toml") + preamble = """ + #nb # This cell specifies dependencies for the notebook to run in environments like Google Colab. + #nb import Pkg + #nb Pkg.add(url="https://github.com/TuringLang/SSMProblems.jl", subdir="SSMProblems") + #nb """ + + if occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) + preamble *= "Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"GeneralisedFilters\")\n #nb " + end + + if isfile(project_toml_path) + deps_lines = String[] + in_deps = false + for line in readlines(project_toml_path) + if startswith(line, "[deps]") + in_deps = true + continue + elseif startswith(line, "[") && in_deps + in_deps = false + continue + end + if in_deps && occursin("=", line) + pkg = strip(split(line, "=")[1]) + if pkg != "SSMProblems" && pkg != "GeneralisedFilters" && pkg != "Literate" + push!(deps_lines, "\"$pkg\"") + end + end + end + if !isempty(deps_lines) + preamble *= "Pkg.add([$(join(deps_lines, ", "))])\n" + end + end + + # Also download extra files if they exist (e.g., data.csv, utilities.jl) + for file in readdir(EXAMPLEPATH) + if file != "script.jl" && file != "script-alt.jl" && !endswith(file, ".toml") && !isdir(joinpath(EXAMPLEPATH, file)) + # Determine base URL dynamically based on whether we're in GeneralisedFilters or SSMProblems + pkg_subdir = occursin("GeneralisedFilters", EXAMPLEPATH) ? "GeneralisedFilters" : "SSMProblems" + url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/\$(pkg_subdir)/examples/\$(EXAMPLE)/\$file" + preamble *= " #nb download(\"$url\", \"\$file\")\n" + if endswith(file, ".jl") + preamble *= " #nb include(\"\$file\")\n" + end + end + end + + return preamble * "\n" * content +end + # Convert to markdown and notebook -const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") -Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true) +for filename in readdir(EXAMPLEPATH) + if endswith(filename, ".jl") && filename != "utilities.jl" + SCRIPTJL = joinpath(EXAMPLEPATH, filename) + # Map script -> example_name, script-alt -> example_name-alt + name = replace(splitext(filename)[1], "script" => EXAMPLE) + Literate.markdown(SCRIPTJL, OUTDIR; name=name, execute=true) + Literate.notebook(SCRIPTJL, OUTDIR; name=name, execute=true, preprocess=insert_colab_preamble) + end +end diff --git a/README.md b/README.md index 5ac01fb4..5bb9893c 100644 --- a/README.md +++ b/README.md @@ -100,3 +100,14 @@ function distribution( return Normal(state, sig_v) end ``` + +## Examples + +You can run our examples directly in your browser using Google Colab: + +- **GeneralisedFilters: Trend Inflation** + [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/TuringLang/SSMProblems.jl/blob/gh-pages/GeneralisedFilters/dev/examples/trend-inflation.ipynb) +- **GeneralisedFilters: Trend Inflation (alternative implementation)** + [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/TuringLang/SSMProblems.jl/blob/gh-pages/GeneralisedFilters/dev/examples/trend-inflation-alt.ipynb) +- **SSMProblems: Kalman Filter** + [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/TuringLang/SSMProblems.jl/blob/gh-pages/SSMProblems/dev/examples/kalman-filter.ipynb) diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index 879ec107..00945d2a 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -13,6 +13,65 @@ Pkg.activate(EXAMPLEPATH) Pkg.instantiate() using Literate: Literate +function insert_colab_preamble(content) + # Extract dependencies from Project.toml + project_toml_path = joinpath(EXAMPLEPATH, "Project.toml") + preamble = """ + #nb # This cell specifies dependencies for the notebook to run in environments like Google Colab. + #nb import Pkg + #nb Pkg.add(url="https://github.com/TuringLang/SSMProblems.jl", subdir="SSMProblems") + #nb """ + + if occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) + preamble *= "Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"GeneralisedFilters\")\n #nb " + end + + if isfile(project_toml_path) + deps_lines = String[] + in_deps = false + for line in readlines(project_toml_path) + if startswith(line, "[deps]") + in_deps = true + continue + elseif startswith(line, "[") && in_deps + in_deps = false + continue + end + if in_deps && occursin("=", line) + pkg = strip(split(line, "=")[1]) + if pkg != "SSMProblems" && pkg != "GeneralisedFilters" && pkg != "Literate" + push!(deps_lines, "\"$pkg\"") + end + end + end + if !isempty(deps_lines) + preamble *= "Pkg.add([$(join(deps_lines, ", "))])\n" + end + end + + # Also download extra files if they exist (e.g., data.csv, utilities.jl) + for file in readdir(EXAMPLEPATH) + if file != "script.jl" && file != "script-alt.jl" && !endswith(file, ".toml") && !isdir(joinpath(EXAMPLEPATH, file)) + # Determine base URL dynamically based on whether we're in GeneralisedFilters or SSMProblems + pkg_subdir = occursin("GeneralisedFilters", EXAMPLEPATH) ? "GeneralisedFilters" : "SSMProblems" + url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/\$(pkg_subdir)/examples/\$(EXAMPLE)/\$file" + preamble *= " #nb download(\"$url\", \"\$file\")\n" + if endswith(file, ".jl") + preamble *= " #nb include(\"\$file\")\n" + end + end + end + + return preamble * "\n" * content +end + # Convert to markdown and notebook -const SCRIPTJL = joinpath(EXAMPLEPATH, "script.jl") -Literate.markdown(SCRIPTJL, OUTDIR; name=EXAMPLE, execute=true) +for filename in readdir(EXAMPLEPATH) + if endswith(filename, ".jl") && filename != "utilities.jl" + SCRIPTJL = joinpath(EXAMPLEPATH, filename) + # Map script -> example_name, script-alt -> example_name-alt + name = replace(splitext(filename)[1], "script" => EXAMPLE) + Literate.markdown(SCRIPTJL, OUTDIR; name=name, execute=true) + Literate.notebook(SCRIPTJL, OUTDIR; name=name, execute=true, preprocess=insert_colab_preamble) + end +end From 37c36f742db1b497ad64760422062b219fa3a300 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 10 Mar 2026 16:35:43 +0530 Subject: [PATCH 2/7] improve implementation --- GeneralisedFilters/docs/literate.jl | 84 ++++++++++++------- .../examples/trend-inflation/script.jl | 2 + README.md | 11 ++- SSMProblems/docs/literate.jl | 84 ++++++++++++------- 4 files changed, 111 insertions(+), 70 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index d730c0fd..d3b1114d 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -14,65 +14,85 @@ Pkg.activate(EXAMPLEPATH) Pkg.instantiate() using Literate: Literate +# Notebook preprocessor: prepend a Colab-friendly setup cell that installs packages +# and downloads auxiliary files. Uses #nb so these lines only appear in notebooks. function insert_colab_preamble(content) - # Extract dependencies from Project.toml - project_toml_path = joinpath(EXAMPLEPATH, "Project.toml") - preamble = """ - #nb # This cell specifies dependencies for the notebook to run in environments like Google Colab. - #nb import Pkg - #nb Pkg.add(url="https://github.com/TuringLang/SSMProblems.jl", subdir="SSMProblems") - #nb """ - + lines = String[] + + push!(lines, "#nb # ## Environment Setup") + push!(lines, "#nb #") + push!( + lines, "#nb # Install required packages (for Google Colab or fresh environments)." + ) + push!(lines, "#nb import Pkg") + push!( + lines, + "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"SSMProblems\")", + ) + if occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) - preamble *= "Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"GeneralisedFilters\")\n #nb " + push!( + lines, + "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"GeneralisedFilters\")", + ) end + # Parse extra dependencies from Project.toml + project_toml_path = joinpath(EXAMPLEPATH, "Project.toml") if isfile(project_toml_path) - deps_lines = String[] + deps = String[] in_deps = false for line in readlines(project_toml_path) if startswith(line, "[deps]") in_deps = true continue elseif startswith(line, "[") && in_deps - in_deps = false - continue + break end if in_deps && occursin("=", line) pkg = strip(split(line, "=")[1]) - if pkg != "SSMProblems" && pkg != "GeneralisedFilters" && pkg != "Literate" - push!(deps_lines, "\"$pkg\"") + if pkg ∉ ("SSMProblems", "GeneralisedFilters", "Literate") + push!(deps, "\"$pkg\"") end end end - if !isempty(deps_lines) - preamble *= "Pkg.add([$(join(deps_lines, ", "))])\n" + if !isempty(deps) + push!(lines, "#nb Pkg.add([$(join(deps, ", "))])") end end - - # Also download extra files if they exist (e.g., data.csv, utilities.jl) + + # Download auxiliary files (data, utility scripts) for Colab + pkg_subdir = + occursin("GeneralisedFilters", EXAMPLEPATH) ? "GeneralisedFilters" : "SSMProblems" for file in readdir(EXAMPLEPATH) - if file != "script.jl" && file != "script-alt.jl" && !endswith(file, ".toml") && !isdir(joinpath(EXAMPLEPATH, file)) - # Determine base URL dynamically based on whether we're in GeneralisedFilters or SSMProblems - pkg_subdir = occursin("GeneralisedFilters", EXAMPLEPATH) ? "GeneralisedFilters" : "SSMProblems" - url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/\$(pkg_subdir)/examples/\$(EXAMPLE)/\$file" - preamble *= " #nb download(\"$url\", \"\$file\")\n" + if !endswith(file, ".toml") && + !isdir(joinpath(EXAMPLEPATH, file)) && + !startswith(file, "script") + url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/$(pkg_subdir)/examples/$(EXAMPLE)/$(file)" + push!(lines, "#nb download(\"$(url)\", \"$(file)\")") if endswith(file, ".jl") - preamble *= " #nb include(\"\$file\")\n" + push!(lines, "#nb include(\"$(file)\")") end end end - - return preamble * "\n" * content + + push!(lines, "") # blank line before original content + return join(lines, "\n") * "\n" * content end -# Convert to markdown and notebook +# Process all Literate-formatted scripts in the example directory for filename in readdir(EXAMPLEPATH) - if endswith(filename, ".jl") && filename != "utilities.jl" - SCRIPTJL = joinpath(EXAMPLEPATH, filename) - # Map script -> example_name, script-alt -> example_name-alt + if endswith(filename, ".jl") && + filename != "utilities.jl" && + startswith(filename, "script") + scriptjl = joinpath(EXAMPLEPATH, filename) + # Name mapping: script.jl -> example_name, script-alt.jl -> example_name-alt name = replace(splitext(filename)[1], "script" => EXAMPLE) - Literate.markdown(SCRIPTJL, OUTDIR; name=name, execute=true) - Literate.notebook(SCRIPTJL, OUTDIR; name=name, execute=true, preprocess=insert_colab_preamble) + # Generate executed markdown for Documenter + Literate.markdown(scriptjl, OUTDIR; name=name, execute=true) + # Generate notebook (not executed — user runs it interactively or on Colab) + Literate.notebook( + scriptjl, OUTDIR; name=name, execute=false, preprocess=insert_colab_preamble + ) end end diff --git a/GeneralisedFilters/examples/trend-inflation/script.jl b/GeneralisedFilters/examples/trend-inflation/script.jl index 126db1db..2b3537c7 100644 --- a/GeneralisedFilters/examples/trend-inflation/script.jl +++ b/GeneralisedFilters/examples/trend-inflation/script.jl @@ -15,8 +15,10 @@ using PDMats const GF = GeneralisedFilters INFL_PATH = joinpath(@__DIR__, "..", "..", "..", "examples", "trend-inflation"); #hide +#nb INFL_PATH = @__DIR__ # INFL_PATH = joinpath(@__DIR__) include(joinpath(INFL_PATH, "utilities.jl")); #hide +#nb include(joinpath(INFL_PATH, "utilities.jl")) # ## Model Definition diff --git a/README.md b/README.md index 5bb9893c..3ac1263f 100644 --- a/README.md +++ b/README.md @@ -105,9 +105,8 @@ end You can run our examples directly in your browser using Google Colab: -- **GeneralisedFilters: Trend Inflation** - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/TuringLang/SSMProblems.jl/blob/gh-pages/GeneralisedFilters/dev/examples/trend-inflation.ipynb) -- **GeneralisedFilters: Trend Inflation (alternative implementation)** - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/TuringLang/SSMProblems.jl/blob/gh-pages/GeneralisedFilters/dev/examples/trend-inflation-alt.ipynb) -- **SSMProblems: Kalman Filter** - [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/TuringLang/SSMProblems.jl/blob/gh-pages/SSMProblems/dev/examples/kalman-filter.ipynb) +| Example | Colab Link | +| :------ | :--------: | +| Trend Inflation (GeneralisedFilters) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/TuringLang/SSMProblems.jl/blob/gh-pages/GeneralisedFilters/dev/examples/trend-inflation.ipynb) | +| Kalman Filter (SSMProblems) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/TuringLang/SSMProblems.jl/blob/gh-pages/SSMProblems/dev/examples/kalman-filter.ipynb) | + diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index 00945d2a..4a9dca9e 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -13,65 +13,85 @@ Pkg.activate(EXAMPLEPATH) Pkg.instantiate() using Literate: Literate +# Notebook preprocessor: prepend a Colab-friendly setup cell that installs packages +# and downloads auxiliary files. Uses #nb so these lines only appear in notebooks. function insert_colab_preamble(content) - # Extract dependencies from Project.toml - project_toml_path = joinpath(EXAMPLEPATH, "Project.toml") - preamble = """ - #nb # This cell specifies dependencies for the notebook to run in environments like Google Colab. - #nb import Pkg - #nb Pkg.add(url="https://github.com/TuringLang/SSMProblems.jl", subdir="SSMProblems") - #nb """ - + lines = String[] + + push!(lines, "#nb # ## Environment Setup") + push!(lines, "#nb #") + push!( + lines, "#nb # Install required packages (for Google Colab or fresh environments)." + ) + push!(lines, "#nb import Pkg") + push!( + lines, + "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"SSMProblems\")", + ) + if occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) - preamble *= "Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"GeneralisedFilters\")\n #nb " + push!( + lines, + "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"GeneralisedFilters\")", + ) end + # Parse extra dependencies from Project.toml + project_toml_path = joinpath(EXAMPLEPATH, "Project.toml") if isfile(project_toml_path) - deps_lines = String[] + deps = String[] in_deps = false for line in readlines(project_toml_path) if startswith(line, "[deps]") in_deps = true continue elseif startswith(line, "[") && in_deps - in_deps = false - continue + break end if in_deps && occursin("=", line) pkg = strip(split(line, "=")[1]) - if pkg != "SSMProblems" && pkg != "GeneralisedFilters" && pkg != "Literate" - push!(deps_lines, "\"$pkg\"") + if pkg ∉ ("SSMProblems", "GeneralisedFilters", "Literate") + push!(deps, "\"$pkg\"") end end end - if !isempty(deps_lines) - preamble *= "Pkg.add([$(join(deps_lines, ", "))])\n" + if !isempty(deps) + push!(lines, "#nb Pkg.add([$(join(deps, ", "))])") end end - - # Also download extra files if they exist (e.g., data.csv, utilities.jl) + + # Download auxiliary files (data, utility scripts) for Colab + pkg_subdir = + occursin("GeneralisedFilters", EXAMPLEPATH) ? "GeneralisedFilters" : "SSMProblems" for file in readdir(EXAMPLEPATH) - if file != "script.jl" && file != "script-alt.jl" && !endswith(file, ".toml") && !isdir(joinpath(EXAMPLEPATH, file)) - # Determine base URL dynamically based on whether we're in GeneralisedFilters or SSMProblems - pkg_subdir = occursin("GeneralisedFilters", EXAMPLEPATH) ? "GeneralisedFilters" : "SSMProblems" - url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/\$(pkg_subdir)/examples/\$(EXAMPLE)/\$file" - preamble *= " #nb download(\"$url\", \"\$file\")\n" + if !endswith(file, ".toml") && + !isdir(joinpath(EXAMPLEPATH, file)) && + !startswith(file, "script") + url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/$(pkg_subdir)/examples/$(EXAMPLE)/$(file)" + push!(lines, "#nb download(\"$(url)\", \"$(file)\")") if endswith(file, ".jl") - preamble *= " #nb include(\"\$file\")\n" + push!(lines, "#nb include(\"$(file)\")") end end end - - return preamble * "\n" * content + + push!(lines, "") # blank line before original content + return join(lines, "\n") * "\n" * content end -# Convert to markdown and notebook +# Process all Literate-formatted scripts in the example directory for filename in readdir(EXAMPLEPATH) - if endswith(filename, ".jl") && filename != "utilities.jl" - SCRIPTJL = joinpath(EXAMPLEPATH, filename) - # Map script -> example_name, script-alt -> example_name-alt + if endswith(filename, ".jl") && + filename != "utilities.jl" && + startswith(filename, "script") + scriptjl = joinpath(EXAMPLEPATH, filename) + # Name mapping: script.jl -> example_name, script-alt.jl -> example_name-alt name = replace(splitext(filename)[1], "script" => EXAMPLE) - Literate.markdown(SCRIPTJL, OUTDIR; name=name, execute=true) - Literate.notebook(SCRIPTJL, OUTDIR; name=name, execute=true, preprocess=insert_colab_preamble) + # Generate executed markdown for Documenter + Literate.markdown(scriptjl, OUTDIR; name=name, execute=true) + # Generate notebook (not executed — user runs it interactively or on Colab) + Literate.notebook( + scriptjl, OUTDIR; name=name, execute=false, preprocess=insert_colab_preamble + ) end end From b2e12b0849f09ffefa8c9149e62724953f5bfaca Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 10 Mar 2026 17:07:39 +0530 Subject: [PATCH 3/7] CI aware colab badges and few more improvements --- GeneralisedFilters/docs/literate.jl | 70 +++++++++++++------ .../examples/trend-inflation/script.jl | 2 + SSMProblems/docs/literate.jl | 70 +++++++++++++------ SSMProblems/examples/kalman-filter/script.jl | 2 + 4 files changed, 104 insertions(+), 40 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index d3b1114d..112d6a68 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -14,7 +14,43 @@ Pkg.activate(EXAMPLEPATH) Pkg.instantiate() using Literate: Literate -# Notebook preprocessor: prepend a Colab-friendly setup cell that installs packages +# Determine the package name (GeneralisedFilters or SSMProblems) +const PKG_NAME = + occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) ? "GeneralisedFilters" : + "SSMProblems" + +# Compute a version/PR-aware Colab root URL, mirroring Literate.jl's deploy folder logic. +# On CI this produces URLs like: +# .../blob/gh-pages/GeneralisedFilters/dev/... +# .../blob/gh-pages/SSMProblems/v1.2.0/... +# .../blob/gh-pages/GeneralisedFilters/previews/PR42/... +function colab_root_url() + repo = get(ENV, "GITHUB_REPOSITORY", "TuringLang/SSMProblems.jl") + deploy_folder = if haskey(ENV, "GITHUB_ACTIONS") + if get(ENV, "GITHUB_EVENT_NAME", nothing) == "push" + ref = get(ENV, "GITHUB_REF", "") + m = match(r"^refs\/tags\/(.*)$", ref) + m !== nothing ? String(m.captures[1]) : "dev" + elseif (m = match(r"refs\/pull\/(\d+)\/merge", get(ENV, "GITHUB_REF", ""))) !== + nothing + "previews/PR$(m.captures[1])" + else + "dev" + end + else + "dev" + end + return "https://colab.research.google.com/github/$(repo)/blob/gh-pages/$(PKG_NAME)/$(deploy_folder)" +end + +const COLAB_ROOT_URL = colab_root_url() + +# Preprocess for markdown: replace @__COLAB_ROOT_URL__ placeholder +function replace_colab_url(content) + return replace(content, "@__COLAB_ROOT_URL__" => COLAB_ROOT_URL) +end + +# Preprocess for notebooks: prepend a Colab-friendly setup cell that installs packages # and downloads auxiliary files. Uses #nb so these lines only appear in notebooks. function insert_colab_preamble(content) lines = String[] @@ -30,7 +66,7 @@ function insert_colab_preamble(content) "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"SSMProblems\")", ) - if occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) + if PKG_NAME == "GeneralisedFilters" push!( lines, "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"GeneralisedFilters\")", @@ -62,13 +98,11 @@ function insert_colab_preamble(content) end # Download auxiliary files (data, utility scripts) for Colab - pkg_subdir = - occursin("GeneralisedFilters", EXAMPLEPATH) ? "GeneralisedFilters" : "SSMProblems" for file in readdir(EXAMPLEPATH) if !endswith(file, ".toml") && !isdir(joinpath(EXAMPLEPATH, file)) && !startswith(file, "script") - url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/$(pkg_subdir)/examples/$(EXAMPLE)/$(file)" + url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/$(PKG_NAME)/examples/$(EXAMPLE)/$(file)" push!(lines, "#nb download(\"$(url)\", \"$(file)\")") if endswith(file, ".jl") push!(lines, "#nb include(\"$(file)\")") @@ -80,19 +114,15 @@ function insert_colab_preamble(content) return join(lines, "\n") * "\n" * content end -# Process all Literate-formatted scripts in the example directory -for filename in readdir(EXAMPLEPATH) - if endswith(filename, ".jl") && - filename != "utilities.jl" && - startswith(filename, "script") - scriptjl = joinpath(EXAMPLEPATH, filename) - # Name mapping: script.jl -> example_name, script-alt.jl -> example_name-alt - name = replace(splitext(filename)[1], "script" => EXAMPLE) - # Generate executed markdown for Documenter - Literate.markdown(scriptjl, OUTDIR; name=name, execute=true) - # Generate notebook (not executed — user runs it interactively or on Colab) - Literate.notebook( - scriptjl, OUTDIR; name=name, execute=false, preprocess=insert_colab_preamble - ) - end +# Process the Literate-formatted script in the example directory +let scriptjl = joinpath(EXAMPLEPATH, "script.jl") + # Generate executed markdown for Documenter (with Colab URL replacement) + Literate.markdown( + scriptjl, OUTDIR; name=EXAMPLE, execute=true, preprocess=replace_colab_url + ) + # Generate notebook with Colab preamble + Literate.notebook( + scriptjl, OUTDIR; name=EXAMPLE, execute=true, preprocess=insert_colab_preamble + ) end + diff --git a/GeneralisedFilters/examples/trend-inflation/script.jl b/GeneralisedFilters/examples/trend-inflation/script.jl index 2b3537c7..f2d7970b 100644 --- a/GeneralisedFilters/examples/trend-inflation/script.jl +++ b/GeneralisedFilters/examples/trend-inflation/script.jl @@ -1,5 +1,7 @@ # # Trend Inflation # +#md # [![](https://colab.research.google.com/assets/colab-badge.svg)](@__COLAB_ROOT_URL__/examples/trend-inflation.ipynb) +# # This example is a replication of the univariate state space model suggested by (Stock & # Watson, 2016) using GeneralisedFilters to define a heirarchical model for use in Rao- # Blackwellised particle filtering. diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index 4a9dca9e..c9467557 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -13,7 +13,43 @@ Pkg.activate(EXAMPLEPATH) Pkg.instantiate() using Literate: Literate -# Notebook preprocessor: prepend a Colab-friendly setup cell that installs packages +# Determine the package name (GeneralisedFilters or SSMProblems) +const PKG_NAME = + occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) ? "GeneralisedFilters" : + "SSMProblems" + +# Compute a version/PR-aware Colab root URL, mirroring Literate.jl's deploy folder logic. +# On CI this produces URLs like: +# .../blob/gh-pages/SSMProblems/dev/... +# .../blob/gh-pages/SSMProblems/v1.2.0/... +# .../blob/gh-pages/SSMProblems/previews/PR42/... +function colab_root_url() + repo = get(ENV, "GITHUB_REPOSITORY", "TuringLang/SSMProblems.jl") + deploy_folder = if haskey(ENV, "GITHUB_ACTIONS") + if get(ENV, "GITHUB_EVENT_NAME", nothing) == "push" + ref = get(ENV, "GITHUB_REF", "") + m = match(r"^refs\/tags\/(.*)$", ref) + m !== nothing ? String(m.captures[1]) : "dev" + elseif (m = match(r"refs\/pull\/(\d+)\/merge", get(ENV, "GITHUB_REF", ""))) !== + nothing + "previews/PR$(m.captures[1])" + else + "dev" + end + else + "dev" + end + return "https://colab.research.google.com/github/$(repo)/blob/gh-pages/$(PKG_NAME)/$(deploy_folder)" +end + +const COLAB_ROOT_URL = colab_root_url() + +# Preprocess for markdown: replace @__COLAB_ROOT_URL__ placeholder +function replace_colab_url(content) + return replace(content, "@__COLAB_ROOT_URL__" => COLAB_ROOT_URL) +end + +# Preprocess for notebooks: prepend a Colab-friendly setup cell that installs packages # and downloads auxiliary files. Uses #nb so these lines only appear in notebooks. function insert_colab_preamble(content) lines = String[] @@ -29,7 +65,7 @@ function insert_colab_preamble(content) "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"SSMProblems\")", ) - if occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) + if PKG_NAME == "GeneralisedFilters" push!( lines, "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"GeneralisedFilters\")", @@ -61,13 +97,11 @@ function insert_colab_preamble(content) end # Download auxiliary files (data, utility scripts) for Colab - pkg_subdir = - occursin("GeneralisedFilters", EXAMPLEPATH) ? "GeneralisedFilters" : "SSMProblems" for file in readdir(EXAMPLEPATH) if !endswith(file, ".toml") && !isdir(joinpath(EXAMPLEPATH, file)) && !startswith(file, "script") - url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/$(pkg_subdir)/examples/$(EXAMPLE)/$(file)" + url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/$(PKG_NAME)/examples/$(EXAMPLE)/$(file)" push!(lines, "#nb download(\"$(url)\", \"$(file)\")") if endswith(file, ".jl") push!(lines, "#nb include(\"$(file)\")") @@ -79,19 +113,15 @@ function insert_colab_preamble(content) return join(lines, "\n") * "\n" * content end -# Process all Literate-formatted scripts in the example directory -for filename in readdir(EXAMPLEPATH) - if endswith(filename, ".jl") && - filename != "utilities.jl" && - startswith(filename, "script") - scriptjl = joinpath(EXAMPLEPATH, filename) - # Name mapping: script.jl -> example_name, script-alt.jl -> example_name-alt - name = replace(splitext(filename)[1], "script" => EXAMPLE) - # Generate executed markdown for Documenter - Literate.markdown(scriptjl, OUTDIR; name=name, execute=true) - # Generate notebook (not executed — user runs it interactively or on Colab) - Literate.notebook( - scriptjl, OUTDIR; name=name, execute=false, preprocess=insert_colab_preamble - ) - end +# Process the Literate-formatted script in the example directory +let scriptjl = joinpath(EXAMPLEPATH, "script.jl") + # Generate executed markdown for Documenter (with Colab URL replacement) + Literate.markdown( + scriptjl, OUTDIR; name=EXAMPLE, execute=true, preprocess=replace_colab_url + ) + # Generate notebook with Colab preamble + Literate.notebook( + scriptjl, OUTDIR; name=EXAMPLE, execute=true, preprocess=insert_colab_preamble + ) end + diff --git a/SSMProblems/examples/kalman-filter/script.jl b/SSMProblems/examples/kalman-filter/script.jl index d924f69a..943e38a7 100644 --- a/SSMProblems/examples/kalman-filter/script.jl +++ b/SSMProblems/examples/kalman-filter/script.jl @@ -1,5 +1,7 @@ # # Kalman Filter # +#md # [![](https://colab.research.google.com/assets/colab-badge.svg)](@__COLAB_ROOT_URL__/examples/kalman-filter.ipynb) +# # This example implements a Kalman filter for a linear Gaussian state space model using the # SSMProblems interface. From 1dbe15e6c5c410664fc3895996bc1c53e2af0c86 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 10 Mar 2026 17:14:28 +0530 Subject: [PATCH 4/7] format --- GeneralisedFilters/docs/literate.jl | 9 +++++---- SSMProblems/docs/literate.jl | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index 112d6a68..c38f1de5 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -15,9 +15,11 @@ Pkg.instantiate() using Literate: Literate # Determine the package name (GeneralisedFilters or SSMProblems) -const PKG_NAME = - occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) ? "GeneralisedFilters" : +const PKG_NAME = if occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) + "GeneralisedFilters" +else "SSMProblems" +end # Compute a version/PR-aware Colab root URL, mirroring Literate.jl's deploy folder logic. # On CI this produces URLs like: @@ -32,7 +34,7 @@ function colab_root_url() m = match(r"^refs\/tags\/(.*)$", ref) m !== nothing ? String(m.captures[1]) : "dev" elseif (m = match(r"refs\/pull\/(\d+)\/merge", get(ENV, "GITHUB_REF", ""))) !== - nothing + nothing "previews/PR$(m.captures[1])" else "dev" @@ -125,4 +127,3 @@ let scriptjl = joinpath(EXAMPLEPATH, "script.jl") scriptjl, OUTDIR; name=EXAMPLE, execute=true, preprocess=insert_colab_preamble ) end - diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index c9467557..892ee710 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -14,9 +14,11 @@ Pkg.instantiate() using Literate: Literate # Determine the package name (GeneralisedFilters or SSMProblems) -const PKG_NAME = - occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) ? "GeneralisedFilters" : +const PKG_NAME = if occursin("GeneralisedFilters", abspath(EXAMPLEPATH)) + "GeneralisedFilters" +else "SSMProblems" +end # Compute a version/PR-aware Colab root URL, mirroring Literate.jl's deploy folder logic. # On CI this produces URLs like: @@ -31,7 +33,7 @@ function colab_root_url() m = match(r"^refs\/tags\/(.*)$", ref) m !== nothing ? String(m.captures[1]) : "dev" elseif (m = match(r"refs\/pull\/(\d+)\/merge", get(ENV, "GITHUB_REF", ""))) !== - nothing + nothing "previews/PR$(m.captures[1])" else "dev" @@ -124,4 +126,3 @@ let scriptjl = joinpath(EXAMPLEPATH, "script.jl") scriptjl, OUTDIR; name=EXAMPLE, execute=true, preprocess=insert_colab_preamble ) end - From 230d2feaa6b8c357f7e6ea47bffab46e334399d8 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 10 Mar 2026 17:57:35 +0530 Subject: [PATCH 5/7] improve few more things --- .gitignore | 6 +++--- GeneralisedFilters/docs/literate.jl | 33 +++++++++++++++++++++++++---- GeneralisedFilters/docs/make.jl | 4 ++-- SSMProblems/docs/Project.toml | 1 + SSMProblems/docs/literate.jl | 33 +++++++++++++++++++++++++---- SSMProblems/docs/make.jl | 4 ++-- 6 files changed, 66 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 6f6156ff..9a050fb8 100644 --- a/.gitignore +++ b/.gitignore @@ -14,9 +14,9 @@ deps/usr/ deps/src/ # Build artifacts for creating documentation generated by the Documenter package -docs/build/ -docs/site/ -**/docs/src/examples/ +**/**/docs/build/ +**/**/docs/site/ +**/**/docs/src/examples/ # File generated by Pkg, the package manager, based on a corresponding Project.toml # It records a fixed state of all packages used by the project. As such, it should not be diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index c38f1de5..870f8523 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -21,6 +21,22 @@ else "SSMProblems" end +# Git revision for Pkg.add — use the current commit/branch on CI so notebooks match the docs build +const GIT_REV = if haskey(ENV, "GITHUB_ACTIONS") + ref = get(ENV, "GITHUB_REF", "") + if startswith(ref, "refs/heads/") + String(match(r"refs\/heads\/(.*)", ref).captures[1]) + elseif startswith(ref, "refs/tags/") + String(match(r"refs\/tags\/(.*)", ref).captures[1]) + else + get(ENV, "GITHUB_SHA", "main") + end +else + "main" +end + +const REPO_URL = "https://github.com/TuringLang/SSMProblems.jl" + # Compute a version/PR-aware Colab root URL, mirroring Literate.jl's deploy folder logic. # On CI this produces URLs like: # .../blob/gh-pages/GeneralisedFilters/dev/... @@ -65,13 +81,13 @@ function insert_colab_preamble(content) push!(lines, "#nb import Pkg") push!( lines, - "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"SSMProblems\")", + "#nb Pkg.add(url=\"$(REPO_URL)\", subdir=\"SSMProblems\", rev=\"$(GIT_REV)\")", ) if PKG_NAME == "GeneralisedFilters" push!( lines, - "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"GeneralisedFilters\")", + "#nb Pkg.add(url=\"$(REPO_URL)\", subdir=\"GeneralisedFilters\", rev=\"$(GIT_REV)\")", ) end @@ -104,7 +120,7 @@ function insert_colab_preamble(content) if !endswith(file, ".toml") && !isdir(joinpath(EXAMPLEPATH, file)) && !startswith(file, "script") - url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/$(PKG_NAME)/examples/$(EXAMPLE)/$(file)" + url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/$(GIT_REV)/$(PKG_NAME)/examples/$(EXAMPLE)/$(file)" push!(lines, "#nb download(\"$(url)\", \"$(file)\")") if endswith(file, ".jl") push!(lines, "#nb include(\"$(file)\")") @@ -116,6 +132,14 @@ function insert_colab_preamble(content) return join(lines, "\n") * "\n" * content end +# Postprocess for notebooks: fix kernelspec to be "julia" instead of "julia-1.x" for Colab support +function fix_kernelspec(nb) + if haskey(nb, "metadata") && haskey(nb["metadata"], "kernelspec") + nb["metadata"]["kernelspec"]["name"] = "julia" + end + return nb +end + # Process the Literate-formatted script in the example directory let scriptjl = joinpath(EXAMPLEPATH, "script.jl") # Generate executed markdown for Documenter (with Colab URL replacement) @@ -124,6 +148,7 @@ let scriptjl = joinpath(EXAMPLEPATH, "script.jl") ) # Generate notebook with Colab preamble Literate.notebook( - scriptjl, OUTDIR; name=EXAMPLE, execute=true, preprocess=insert_colab_preamble + scriptjl, OUTDIR; name=EXAMPLE, execute=true, + preprocess=insert_colab_preamble, postprocess=fix_kernelspec ) end diff --git a/GeneralisedFilters/docs/make.jl b/GeneralisedFilters/docs/make.jl index 117d6cff..4512667c 100644 --- a/GeneralisedFilters/docs/make.jl +++ b/GeneralisedFilters/docs/make.jl @@ -14,9 +14,9 @@ mkpath(EXAMPLES_OUT) examples = filter!(isdir, readdir(joinpath(@__DIR__, "..", "examples"); join=true)) above = joinpath(@__DIR__, "..") ssmproblems_path = joinpath(above, "..", "SSMProblems") -let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.develop(path=\"$(above)\"); Pkg.develop(path=\"$(ssmproblems_path)\"); Pkg.instantiate()" +let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.develop(path=ARGS[2]); Pkg.develop(path=ARGS[3]); Pkg.instantiate()" for example in examples - if !success(`$(Base.julia_cmd()) -e $script $example`) + if !success(`$(Base.julia_cmd()) -e $script $example $above $ssmproblems_path`) error( "project environment of example ", basename(example), diff --git a/SSMProblems/docs/Project.toml b/SSMProblems/docs/Project.toml index cf645b52..c8faa358 100644 --- a/SSMProblems/docs/Project.toml +++ b/SSMProblems/docs/Project.toml @@ -1,3 +1,4 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" +SSMProblems = "26aad666-b158-4e64-9d35-0e672562fa48" diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index 892ee710..cd7d2332 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -20,6 +20,22 @@ else "SSMProblems" end +# Git revision for Pkg.add — use the current commit/branch on CI so notebooks match the docs build +const GIT_REV = if haskey(ENV, "GITHUB_ACTIONS") + ref = get(ENV, "GITHUB_REF", "") + if startswith(ref, "refs/heads/") + String(match(r"refs\/heads\/(.*)", ref).captures[1]) + elseif startswith(ref, "refs/tags/") + String(match(r"refs\/tags\/(.*)", ref).captures[1]) + else + get(ENV, "GITHUB_SHA", "main") + end +else + "main" +end + +const REPO_URL = "https://github.com/TuringLang/SSMProblems.jl" + # Compute a version/PR-aware Colab root URL, mirroring Literate.jl's deploy folder logic. # On CI this produces URLs like: # .../blob/gh-pages/SSMProblems/dev/... @@ -64,13 +80,13 @@ function insert_colab_preamble(content) push!(lines, "#nb import Pkg") push!( lines, - "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"SSMProblems\")", + "#nb Pkg.add(url=\"$(REPO_URL)\", subdir=\"SSMProblems\", rev=\"$(GIT_REV)\")", ) if PKG_NAME == "GeneralisedFilters" push!( lines, - "#nb Pkg.add(url=\"https://github.com/TuringLang/SSMProblems.jl\", subdir=\"GeneralisedFilters\")", + "#nb Pkg.add(url=\"$(REPO_URL)\", subdir=\"GeneralisedFilters\", rev=\"$(GIT_REV)\")", ) end @@ -103,7 +119,7 @@ function insert_colab_preamble(content) if !endswith(file, ".toml") && !isdir(joinpath(EXAMPLEPATH, file)) && !startswith(file, "script") - url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/main/$(PKG_NAME)/examples/$(EXAMPLE)/$(file)" + url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/$(GIT_REV)/$(PKG_NAME)/examples/$(EXAMPLE)/$(file)" push!(lines, "#nb download(\"$(url)\", \"$(file)\")") if endswith(file, ".jl") push!(lines, "#nb include(\"$(file)\")") @@ -115,6 +131,14 @@ function insert_colab_preamble(content) return join(lines, "\n") * "\n" * content end +# Postprocess for notebooks: fix kernelspec to be "julia" instead of "julia-1.x" for Colab support +function fix_kernelspec(nb) + if haskey(nb, "metadata") && haskey(nb["metadata"], "kernelspec") + nb["metadata"]["kernelspec"]["name"] = "julia" + end + return nb +end + # Process the Literate-formatted script in the example directory let scriptjl = joinpath(EXAMPLEPATH, "script.jl") # Generate executed markdown for Documenter (with Colab URL replacement) @@ -123,6 +147,7 @@ let scriptjl = joinpath(EXAMPLEPATH, "script.jl") ) # Generate notebook with Colab preamble Literate.notebook( - scriptjl, OUTDIR; name=EXAMPLE, execute=true, preprocess=insert_colab_preamble + scriptjl, OUTDIR; name=EXAMPLE, execute=true, + preprocess=insert_colab_preamble, postprocess=fix_kernelspec ) end diff --git a/SSMProblems/docs/make.jl b/SSMProblems/docs/make.jl index 2a130b14..a337a791 100644 --- a/SSMProblems/docs/make.jl +++ b/SSMProblems/docs/make.jl @@ -13,9 +13,9 @@ mkpath(EXAMPLES_OUT) # Workaround for https://github.com/JuliaLang/Pkg.jl/issues/2219 examples = filter!(isdir, readdir(joinpath(@__DIR__, "..", "examples"); join=true)) above = joinpath(@__DIR__, "..") -let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.develop(path=\"$(above)\"); Pkg.instantiate()" +let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.develop(path=ARGS[2]); Pkg.instantiate()" for example in examples - if !success(`$(Base.julia_cmd()) -e $script $example`) + if !success(`$(Base.julia_cmd()) -e $script $example $above`) error( "project environment of example ", basename(example), From fb87af6d00e9ea62209f18ae0c2e49590003e886 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 10 Mar 2026 18:01:01 +0530 Subject: [PATCH 6/7] format --- GeneralisedFilters/docs/literate.jl | 8 ++++++-- SSMProblems/docs/literate.jl | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index 870f8523..56661e98 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -148,7 +148,11 @@ let scriptjl = joinpath(EXAMPLEPATH, "script.jl") ) # Generate notebook with Colab preamble Literate.notebook( - scriptjl, OUTDIR; name=EXAMPLE, execute=true, - preprocess=insert_colab_preamble, postprocess=fix_kernelspec + scriptjl, + OUTDIR; + name=EXAMPLE, + execute=true, + preprocess=insert_colab_preamble, + postprocess=fix_kernelspec, ) end diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index cd7d2332..e76621dc 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -147,7 +147,11 @@ let scriptjl = joinpath(EXAMPLEPATH, "script.jl") ) # Generate notebook with Colab preamble Literate.notebook( - scriptjl, OUTDIR; name=EXAMPLE, execute=true, - preprocess=insert_colab_preamble, postprocess=fix_kernelspec + scriptjl, + OUTDIR; + name=EXAMPLE, + execute=true, + preprocess=insert_colab_preamble, + postprocess=fix_kernelspec, ) end From 027a723e6af8b8107738737dff98ea18478f1da7 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Tue, 10 Mar 2026 18:20:52 +0530 Subject: [PATCH 7/7] revert make.jl and fix GF docs --- GeneralisedFilters/docs/literate.jl | 3 --- GeneralisedFilters/docs/make.jl | 4 ++-- SSMProblems/docs/literate.jl | 3 --- SSMProblems/docs/make.jl | 4 ++-- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/GeneralisedFilters/docs/literate.jl b/GeneralisedFilters/docs/literate.jl index 56661e98..9e8fff11 100644 --- a/GeneralisedFilters/docs/literate.jl +++ b/GeneralisedFilters/docs/literate.jl @@ -122,9 +122,6 @@ function insert_colab_preamble(content) !startswith(file, "script") url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/$(GIT_REV)/$(PKG_NAME)/examples/$(EXAMPLE)/$(file)" push!(lines, "#nb download(\"$(url)\", \"$(file)\")") - if endswith(file, ".jl") - push!(lines, "#nb include(\"$(file)\")") - end end end diff --git a/GeneralisedFilters/docs/make.jl b/GeneralisedFilters/docs/make.jl index 4512667c..117d6cff 100644 --- a/GeneralisedFilters/docs/make.jl +++ b/GeneralisedFilters/docs/make.jl @@ -14,9 +14,9 @@ mkpath(EXAMPLES_OUT) examples = filter!(isdir, readdir(joinpath(@__DIR__, "..", "examples"); join=true)) above = joinpath(@__DIR__, "..") ssmproblems_path = joinpath(above, "..", "SSMProblems") -let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.develop(path=ARGS[2]); Pkg.develop(path=ARGS[3]); Pkg.instantiate()" +let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.develop(path=\"$(above)\"); Pkg.develop(path=\"$(ssmproblems_path)\"); Pkg.instantiate()" for example in examples - if !success(`$(Base.julia_cmd()) -e $script $example $above $ssmproblems_path`) + if !success(`$(Base.julia_cmd()) -e $script $example`) error( "project environment of example ", basename(example), diff --git a/SSMProblems/docs/literate.jl b/SSMProblems/docs/literate.jl index e76621dc..d432c24b 100644 --- a/SSMProblems/docs/literate.jl +++ b/SSMProblems/docs/literate.jl @@ -121,9 +121,6 @@ function insert_colab_preamble(content) !startswith(file, "script") url = "https://raw.githubusercontent.com/TuringLang/SSMProblems.jl/$(GIT_REV)/$(PKG_NAME)/examples/$(EXAMPLE)/$(file)" push!(lines, "#nb download(\"$(url)\", \"$(file)\")") - if endswith(file, ".jl") - push!(lines, "#nb include(\"$(file)\")") - end end end diff --git a/SSMProblems/docs/make.jl b/SSMProblems/docs/make.jl index a337a791..2a130b14 100644 --- a/SSMProblems/docs/make.jl +++ b/SSMProblems/docs/make.jl @@ -13,9 +13,9 @@ mkpath(EXAMPLES_OUT) # Workaround for https://github.com/JuliaLang/Pkg.jl/issues/2219 examples = filter!(isdir, readdir(joinpath(@__DIR__, "..", "examples"); join=true)) above = joinpath(@__DIR__, "..") -let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.develop(path=ARGS[2]); Pkg.instantiate()" +let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.develop(path=\"$(above)\"); Pkg.instantiate()" for example in examples - if !success(`$(Base.julia_cmd()) -e $script $example $above`) + if !success(`$(Base.julia_cmd()) -e $script $example`) error( "project environment of example ", basename(example),