Skip to content

Commit 9b9584d

Browse files
authored
Update to new Pollen template (#222)
1 parent 7c0842f commit 9b9584d

File tree

7 files changed

+116
-95
lines changed

7 files changed

+116
-95
lines changed

.github/workflows/pollenbuild.yml

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,32 @@ name: pollenbuild
22

33
on:
44
push:
5-
branches: ['pollen']
5+
branches: ['master', 'main']
66

77
jobs:
88
pollen:
9-
name: "Pollen documentation build"
9+
name: "Pollen - build documentation data"
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
with:
14-
ref: pollen
15-
path: data
1613
- uses: actions/checkout@v2
1714
with:
18-
ref: "gh-pages"
19-
path: "pages"
20-
- uses: actions/checkout@v2
15+
ref: pollen
16+
path: pollen
17+
- uses: julia-actions/setup-julia@latest
2118
with:
22-
repository: lorenzoh/pollenjl-frontend
23-
path: frontend
24-
ref: main
25-
- name: Move Pollen data to static folder
19+
version: '1.7'
20+
- name: "Install package and docs dependencies"
2621
run: |
27-
ls
28-
rm -rf data/.git
29-
cp -r data/ frontend/static/
30-
- uses: actions/setup-node@v2
31-
- name: Install dependencies
32-
run: |
33-
cd frontend
34-
npm install
22+
julia --color=yes --project=./docs -e 'using Pkg; Pkg.add([Pkg.PackageSpec(path="."), Pkg.PackageSpec(url="https://github.com/c42f/JuliaSyntax.jl"), Pkg.PackageSpec(url="https://github.com/lorenzoh/ModuleInfo.jl"), Pkg.PackageSpec(url="https://github.com/lorenzoh/Pollen.jl", rev="main")]); Pkg.instantiate();'
3523
- name: Build
3624
run: |
37-
cd frontend
38-
npm run build
39-
- name: Build search index
40-
run: |
41-
cd frontend
42-
cat static/data/dev/documents.json | node buildindex.cjs > ../data/dev/searchindex.json
43-
- name: Deploy changes
25+
julia --color=yes --project=./docs ./docs/make.jl ./pollen/dev/
26+
- name: Deploy
4427
run: |
45-
ls -lt
46-
rm -r frontend/build/data
47-
cp -r frontend/build/** pages
48-
cp -r data pages/
49-
cd pages
28+
cd pollen
5029
git config user.name github-actions
5130
git config user.email [email protected]
52-
git add -f .
53-
git commit -m "Deploy documentation (Pollen.jl)"
31+
git add .
32+
git commit -m "Build documentation data (Pollen.jl)"
5433
git push
55-

.github/workflows/pollenexport.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/pollenstatic.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: pollenstatic
2+
3+
on:
4+
push:
5+
branches: ['pollen']
6+
workflow_run:
7+
workflows: ['pollenbuild']
8+
types:
9+
- completed
10+
11+
jobs:
12+
pollen:
13+
name: "Pollen - Prerender static frontend and deploy"
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
ref: pollen
19+
path: data
20+
- uses: actions/checkout@v2
21+
with:
22+
ref: "gh-pages"
23+
path: pages
24+
- uses: actions/checkout@v2
25+
with:
26+
repository: lorenzoh/pollenjl-frontend
27+
path: frontend
28+
ref: main
29+
- name: Move Pollen data to static folder
30+
run: |
31+
ls
32+
rm -rf data/.git
33+
cp -r data/ frontend/static/
34+
- uses: actions/setup-node@v2
35+
- name: Install dependencies
36+
run: |
37+
cd frontend
38+
npm install
39+
- name: Build
40+
run: |
41+
cd frontend
42+
npm run build
43+
- name: Build search index
44+
run: |
45+
cd frontend
46+
cat static/data/dev/documents.json | node buildindex.cjs > ../data/dev/searchindex.json
47+
- name: Deploy changes
48+
run: |
49+
ls -lt
50+
rm -r frontend/build/data
51+
cp -r frontend/build/** pages
52+
cp -r data pages/
53+
cd pages
54+
git config user.name github-actions
55+
git config user.email [email protected]
56+
git add -f .
57+
git commit -m "Deploy documentation (Pollen.jl)"
58+
git push

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
44
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
55
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
66
DataAugmentation = "88a5189c-e7ff-4f85-ac6b-e6158070f02e"
7+
FastAI = "5d0beca9-ade8-49ae-ad0b-a3cf890e669f"
78
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
89
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
910
FluxTraining = "7bf95e4d-ca32-48da-9824-f0dc5310474f"
1011
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
1112
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
1213
ImageShow = "4e3cecfd-b093-5904-9786-8bbb286a6a31"
1314
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
15+
JuliaSyntax = "70703baa-626e-46a2-a12c-08ffd08c73b4"
1416
ModuleInfo = "3c3ff5e7-c68c-4a09-80d1-9526a1e9878a"
1517
Pollen = "c88717ad-5130-4874-a664-5a9aba5ec443"
1618
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

docs/make.jl

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
ENV["DATADEPS_ALWAYS_ACCEPT"] = "true"
2-
using Pkg
3-
using Pollen
1+
"""
2+
This script builds the Pollen.jl documentation so that it can be loaded
3+
by the frontend. It accepts one argument: the path where the generated
4+
files should be stored.
5+
6+
> julia docs/make.jl DIR
7+
8+
Use `./serve.jl` for interactive development.
9+
"""
410

511
# Create target folder
12+
isempty(ARGS) && error("Please pass a file path to make.jl:\n\t> julia docs/make.jl DIR ")
613
DIR = abspath(mkpath(ARGS[1]))
714

8-
915
# Create Project
1016
project = include("project.jl")
1117

12-
1318
@info "Rewriting documents..."
1419
Pollen.rewritesources!(project)
1520

1621
@info "Writing to disk at \"$DIR\"..."
17-
builder = Pollen.FileBuilder(
18-
Pollen.JSONFormat(),
19-
DIR,
20-
)
2122
Pollen.build(
22-
builder,
23+
FileBuilder(
24+
JSONFormat(),
25+
DIR,
26+
),
2327
project,
2428
)

docs/project.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ ms = [
1414
m,
1515
]
1616

17-
1817
project = Project(
1918
Pollen.Rewriter[
20-
Pollen.DocumentFolder(pkgdir(m), prefix = "documents"),
21-
Pollen.ParseCode(),
22-
Pollen.ExecuteCode(),
23-
Pollen.PackageDocumentation(ms),
24-
Pollen.StaticResources(),
25-
Pollen.DocumentGraph(),
26-
Pollen.SearchIndex(),
27-
Pollen.SaveAttributes((:title,)),
28-
Pollen.LoadFrontendConfig(pkgdir(m))
19+
DocumentFolder(Pkg.pkgdir(m), prefix = "documents"),
20+
ParseCode(),
21+
ExecuteCode(),
22+
PackageDocumentation(ms),
23+
StaticResources(),
24+
DocumentGraph(),
25+
SearchIndex(),
26+
SaveAttributes((:title,)),
27+
LoadFrontendConfig(Pkg.pkgdir(m))
2928
],
3029
)

docs/serve.jl

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
using Pollen
1+
"""
2+
This script serves the Pollen.jl documentation on a local file server
3+
so that it can be loaded by the frontend in development mode.
4+
files should be stored.
25
3-
# using MyPackage
6+
> julia docs/serve.jl
47
8+
Use `./make.jl` to export the generated documents to disk.
59
6-
# Create Project
7-
project = include("project.jl")
10+
There are two modes for interactive development: Lazy and Regular.
11+
In lazy mode, each document will be built only if it is requested in
12+
the frontend, while for Regular mode, each document will be built
13+
once before serving.
14+
"""
815

16+
using Pollen
17+
18+
project = include("project.jl")
919

10-
@info "Rewriting documents..."
11-
Pollen.rewritesources!(project)
1220

13-
Pollen.serve(project, lazy=get(ENV, "POLLEN_LAZY", "false") == "true", format = Pollen.JSONFormat())
21+
Pollen.serve(
22+
project;
23+
lazy = get(ENV, "POLLEN_LAZY", "false") == "true",
24+
port = Base.parse(Int, get(ENV, "POLLEN_PORT", "8000")),
25+
format = JSONFormat()
26+
)

0 commit comments

Comments
 (0)