Skip to content

Update to new Pollen template #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 13 additions & 35 deletions .github/workflows/pollenbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,32 @@ name: pollenbuild

on:
push:
branches: ['pollen']
branches: ['master', 'main']

jobs:
pollen:
name: "Pollen documentation build"
name: "Pollen - build documentation data"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: pollen
path: data
- uses: actions/checkout@v2
with:
ref: "gh-pages"
path: "pages"
- uses: actions/checkout@v2
ref: pollen
path: pollen
- uses: julia-actions/setup-julia@latest
with:
repository: lorenzoh/pollenjl-frontend
path: frontend
ref: main
- name: Move Pollen data to static folder
version: '1.7'
- name: "Install package and docs dependencies"
run: |
ls
rm -rf data/.git
cp -r data/ frontend/static/
- uses: actions/setup-node@v2
- name: Install dependencies
run: |
cd frontend
npm install
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();'
- name: Build
run: |
cd frontend
npm run build
- name: Build search index
run: |
cd frontend
cat static/data/dev/documents.json | node buildindex.cjs > ../data/dev/searchindex.json
- name: Deploy changes
julia --color=yes --project=./docs ./docs/make.jl ./pollen/dev/
- name: Deploy
run: |
ls -lt
rm -r frontend/build/data
cp -r frontend/build/** pages
cp -r data pages/
cd pages
cd pollen
git config user.name github-actions
git config user.email github-actions@github.com
git add -f .
git commit -m "Deploy documentation (Pollen.jl)"
git add .
git commit -m "Build documentation data (Pollen.jl)"
git push

33 changes: 0 additions & 33 deletions .github/workflows/pollenexport.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/pollenstatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: pollenstatic

on:
push:
branches: ['pollen']
workflow_run:
workflows: ['pollenbuild']
types:
- completed

jobs:
pollen:
name: "Pollen - Prerender static frontend and deploy"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: pollen
path: data
- uses: actions/checkout@v2
with:
ref: "gh-pages"
path: pages
- uses: actions/checkout@v2
with:
repository: lorenzoh/pollenjl-frontend
path: frontend
ref: main
- name: Move Pollen data to static folder
run: |
ls
rm -rf data/.git
cp -r data/ frontend/static/
- uses: actions/setup-node@v2
- name: Install dependencies
run: |
cd frontend
npm install
- name: Build
run: |
cd frontend
npm run build
- name: Build search index
run: |
cd frontend
cat static/data/dev/documents.json | node buildindex.cjs > ../data/dev/searchindex.json
- name: Deploy changes
run: |
ls -lt
rm -r frontend/build/data
cp -r frontend/build/** pages
cp -r data pages/
cd pages
git config user.name github-actions
git config user.email github-actions@github.com
git add -f .
git commit -m "Deploy documentation (Pollen.jl)"
git push
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
DataAugmentation = "88a5189c-e7ff-4f85-ac6b-e6158070f02e"
FastAI = "5d0beca9-ade8-49ae-ad0b-a3cf890e669f"
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
FluxTraining = "7bf95e4d-ca32-48da-9824-f0dc5310474f"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
ImageShow = "4e3cecfd-b093-5904-9786-8bbb286a6a31"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
JuliaSyntax = "70703baa-626e-46a2-a12c-08ffd08c73b4"
ModuleInfo = "3c3ff5e7-c68c-4a09-80d1-9526a1e9878a"
Pollen = "c88717ad-5130-4874-a664-5a9aba5ec443"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Expand Down
24 changes: 14 additions & 10 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
ENV["DATADEPS_ALWAYS_ACCEPT"] = "true"
using Pkg
using Pollen
"""
This script builds the Pollen.jl documentation so that it can be loaded
by the frontend. It accepts one argument: the path where the generated
files should be stored.

> julia docs/make.jl DIR

Use `./serve.jl` for interactive development.
"""

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


# Create Project
project = include("project.jl")


@info "Rewriting documents..."
Pollen.rewritesources!(project)

@info "Writing to disk at \"$DIR\"..."
builder = Pollen.FileBuilder(
Pollen.JSONFormat(),
DIR,
)
Pollen.build(
builder,
FileBuilder(
JSONFormat(),
DIR,
),
project,
)
19 changes: 9 additions & 10 deletions docs/project.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ ms = [
m,
]


project = Project(
Pollen.Rewriter[
Pollen.DocumentFolder(pkgdir(m), prefix = "documents"),
Pollen.ParseCode(),
Pollen.ExecuteCode(),
Pollen.PackageDocumentation(ms),
Pollen.StaticResources(),
Pollen.DocumentGraph(),
Pollen.SearchIndex(),
Pollen.SaveAttributes((:title,)),
Pollen.LoadFrontendConfig(pkgdir(m))
DocumentFolder(Pkg.pkgdir(m), prefix = "documents"),
ParseCode(),
ExecuteCode(),
PackageDocumentation(ms),
StaticResources(),
DocumentGraph(),
SearchIndex(),
SaveAttributes((:title,)),
LoadFrontendConfig(Pkg.pkgdir(m))
],
)
27 changes: 20 additions & 7 deletions docs/serve.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
using Pollen
"""
This script serves the Pollen.jl documentation on a local file server
so that it can be loaded by the frontend in development mode.
files should be stored.

# using MyPackage
> julia docs/serve.jl

Use `./make.jl` to export the generated documents to disk.

# Create Project
project = include("project.jl")
There are two modes for interactive development: Lazy and Regular.
In lazy mode, each document will be built only if it is requested in
the frontend, while for Regular mode, each document will be built
once before serving.
"""

using Pollen

project = include("project.jl")

@info "Rewriting documents..."
Pollen.rewritesources!(project)

Pollen.serve(project, lazy=get(ENV, "POLLEN_LAZY", "false") == "true", format = Pollen.JSONFormat())
Pollen.serve(
project;
lazy = get(ENV, "POLLEN_LAZY", "false") == "true",
port = Base.parse(Int, get(ENV, "POLLEN_PORT", "8000")),
format = JSONFormat()
)