tlienart / Xranklin.jl

Experimental repo for a refactoring of Franklin.jl
https://tlienart.github.io/Xranklin.jl
MIT License
40 stars 1 forks source link

Make it easier to activate dedicated envs for literate files #197

Closed tlienart closed 1 year ago

tlienart commented 1 year ago

Pre-existing stuff

At any point in a file, a user can do \activate{...} which will try to activate+instantiate and code run after that will be in that project (unless changed). E.g.:

foo.md:

\activate{bar/baz}
```!
using Pkg
Pkg.project().path  # will show [folderpath]/bar/baz/Project.toml

This folder is deactivated after resolving the page (going back to whatever "parent" project was used before)

### New stuff

Literate can explicitly add a `project=...`, accepted syntax:

\literate{path/to/script.jl; project=.} # activate folder 'path/to' \literate{path/to/script.jl; project="."} # same, quotes are not mandatory \literate{path/to/script.jl; project="./foo"} # activate folder 'path/to/foo' (relative) \literate{path/to/script.jl; project="foo/bar"} # activate folder 'foo/bar' (absolute with respect to folder path)


Example:

Folder `notebooks` with

* `Project.toml`
* `script.jl`

Main folder with file `index.md`

**Project.toml**:

[deps] StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"


**script.jl**

abc

using StableRNGs rand(StableRNG(0))

def


**index.md**

Calling a literate script:

\literate{notebooks/script.jl; project=.}

github-actions[bot] commented 1 year ago

Preview should be up in a couple of mins at https://tlienart.github.io/Xranklin.jl/previews/PR197 (if you get a 404, wait 30s then refresh).

github-actions[bot] commented 1 year ago

Preview should be up in a couple of mins at https://tlienart.github.io/Xranklin.jl/previews/PR197 (if you get a 404, wait 30s then refresh).