You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -7,96 +7,160 @@ You've likely already seen how LiveServer could be used along with Documenter to
7
7
It is also easy to use LiveServer with both Documenter and [Literate.jl](https://github.com/fredrikekre/Literate.jl), a package for literate programming written by Fredrik Ekre that can convert julia script files into markdown.
8
8
This can be particularly convenient for documentation pages with a lot of code examples.
9
9
10
-
Only two steps are required to have this working (assuming you have already added Literate to your environment):
10
+
There are mainly two steps
11
11
12
-
1.pick a folder structure
13
-
1. modify the `docs/make.jl` file to contain a line calling Literate
12
+
1.have the `make.jl` file process the literate files to go from `.jl` to `.md` files,
13
+
2. call `servedocs` with appropriate keywords.
14
14
15
-
### Folder structure
16
-
17
-
There are effectively two recommended ways, pick whichever one you prefer.
18
-
In the first case, the script files `.jl` to be compiled by Literate are at the _same location_ as the output file so that you would have:
15
+
The function `LiveServer.servedocs_literate_example` generates a directory which has the right structure that you can copy for your package.
if you're happy with this, then you can jump to the [next step](#Modifying-the-make-file-1) to change the make file.
25
+
if youthen navigate to `localhost:8000` you should end up with
28
26
29
-
However you may not be happy with this, in particular if you have lots of such files and a mix of files which are generated by `Literate` and some which aren't, then typically you might prefer to keep all scripts in a separate folder.
30
-
You would just have to make sure that the output is properly redirected to `docs/src`.
31
-
Your folder structure would then look something like:
27
+

32
28
33
-
```
34
-
docs
35
-
├── lit
36
-
│ └── index.jl
37
-
└── src
38
-
└── index.md
39
-
```
29
+
if you modify `test_dir/docs/literate/man/pg1.jl` for instance writing `f(4)` it will be applied directly:
40
30
41
-
The only thing you have to do in this case is to specify to `servedocs` where the "literate folder" is; this is a keyword argument and for the example above we would have:
31
+

32
+
33
+
34
+
In the explanations below we assume you have defined
35
+
36
+
*`LITERATE_INPUT` the directory where the literate files are,
37
+
*`LITERATE_OUTPUT` the directory where the generated markdown files will be.
42
38
43
-
```julia
44
-
servedocs(literate_dir=joinpath("docs", "lit"))
45
-
```
46
39
47
-
### Modifying the make file
40
+
##Having the make file call Literate
48
41
49
-
The only thing you have to do here is add a few lines to specify which files should be compiled by `Literate`.
50
-
Assuming you have taken the second path in the situation above, your `make.jl` file should look like:
42
+
Here's a basic `make.jl` file which loops over the files in `LITERATE_INPUT`to generate files
43
+
in `LITERATE_OUTPUT`
51
44
52
45
```julia
53
46
using Documenter, Literate
54
47
55
-
src=joinpath(@__DIR__, "src")
56
-
lit=joinpath(@__DIR__, "lit")
48
+
LITERATE_INPUT=...
49
+
LITERATE_OUTPUT=...
57
50
58
-
for (root, _, files) ∈walkdir(lit), file ∈ files
51
+
for (root, _, files) ∈walkdir(LITERATE_INPUT), file ∈ files
0 commit comments