Skip to content

Commit f791d45

Browse files
authored
improve local docs workflow (#31)
1 parent dc08226 commit f791d45

File tree

6 files changed

+48
-14
lines changed

6 files changed

+48
-14
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
with:
5252
version: '1'
5353
- name: Install dependencies
54-
run: julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();'
54+
run: julia --project=docs docs/setup.jl
5555
- name: Build and deploy
5656
env:
5757
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
66
ImageFiltering = "6a3955dd-da59-5b1f-98d4-e7296123deb5"
77
ImageShow = "4e3cecfd-b093-5904-9786-8bbb286a6a31"
88
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
9+
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
910
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1011
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990"
1112

@@ -14,5 +15,6 @@ DocThemeIndigo = "0.1.3"
1415
ImageCore = "0.9.4"
1516
ImageFiltering = "0.7.3"
1617
Literate = "2.14"
18+
LiveServer = "1.2.7"
1719
Plots = "1.38"
1820
TestImages = "1.7"

docs/liveserver.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Pkg
2+
3+
Pkg.activate(@__DIR__)
4+
5+
using LiveServer
6+
7+
servedocs(; literate_dir = joinpath("docs", "src", "literate"),
8+
skip_dirs = [
9+
joinpath("docs", "src", "notebooks"),
10+
joinpath("docs", "src", "tutorials"),
11+
joinpath("docs", "src", "applications"),
12+
],
13+
skip_files = [
14+
joinpath("docs", "src", "api", "logical.md"),
15+
joinpath("docs", "src", "api", "memberships.md"),
16+
joinpath("docs", "src", "assets", "indigo.css"),
17+
],
18+
launch_browser = true,
19+
verbose = true)

docs/make.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ ENV["GKSwstype"] = "100"
33
const IS_CI = get(ENV, "CI", "false") == "true"
44

55
import Pkg
6-
7-
if !IS_CI
8-
Pkg.activate(@__DIR__)
9-
Pkg.instantiate()
10-
end
11-
12-
Pkg.add(Pkg.PackageSpec(name = "Documenter", rev = "30baed5")) # TODO remove once Documenter 0.28 is released
6+
Pkg.activate(@__DIR__)
137

148
using Documenter
159
using DocThemeIndigo
@@ -182,6 +176,4 @@ makedocs(;
182176
# DEPLOY #
183177
##########
184178

185-
if IS_CI
186-
deploydocs(; repo = "github.com/lucaferranti/FuzzyLogic.jl", push_preview = true)
187-
end
179+
IS_CI && deploydocs(; repo = "github.com/lucaferranti/FuzzyLogic.jl", push_preview = true)

docs/setup.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Pkg
2+
3+
Pkg.activate(@__DIR__)
4+
Pkg.develop(Pkg.PackageSpec(path = joinpath(@__DIR__, "..")))
5+
Pkg.instantiate()
6+
7+
# TODO remove once Documenter 0.28 is released
8+
# this is to get both the edit link and a the github link
9+
Pkg.add(Pkg.PackageSpec(name = "Documenter", rev = "30baed5"))

docs/src/contributing.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,25 @@ include("test/runtests.jl")
110110

111111
## Working on the documentation
112112

113-
* You can build the documentation locally with
113+
### Local setup
114+
The first time you start working on the documentation locally, you will need to install all needed dependencies. To do so, run
114115

115116
```
116-
julia --project=docs docs/make.jl
117+
julia docs/setup.jl
117118
```
118119

119-
* Tutorials and applications are written using [Literate.jl](https://github.com/fredrikekre/Literate.jl), hence if working on those, you should edit the source file under the `literate` folder and not directly the markdown.
120+
This needs to be done only the fist time (if you don't have `docs/Manifest.toml`) or any time the Manifest becomes outdated.
121+
122+
Next, you can build the documentation locally by running
123+
124+
```
125+
julia docs/liveserver.jl
126+
```
127+
128+
This will open a preview of the documentation in your browser and watch the documentation source files, meaning the preview will automatically update on every documentation change.
129+
130+
### Working with literate.
131+
* Tutorials and applications are written using [Literate.jl](https://github.com/fredrikekre/Literate.jl). Hence, do not directly edit the markdown files under `docs/src/tutorials` and `docs/src/applications`, edit instead the corresponding julia files under `docs/src/literate`.
120132

121133
## Further reading
122134

0 commit comments

Comments
 (0)