Skip to content
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
57 changes: 12 additions & 45 deletions .github/workflows/update-cslib-docs.yaml
Original file line number Diff line number Diff line change
@@ -1,72 +1,40 @@
name: Update cslib documentation
name: Build and deploy website

on:
push:
branches:
- main
pull_request:
workflow_dispatch:
schedule:
- cron: '0 */12 * * *'

# env:
# LAKE_NO_CACHE: true

jobs:

build-docs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout cslib-community.github.io
- name: Checkout
uses: actions/checkout@v6

- name: Checkout cslib
uses: actions/checkout@v6
- name: Install Lean and build
uses: leanprover/lean-action@v1
with:
repository: leanprover/cslib
path: cslib

- name: Install elan
run: |
set -o pipefail
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- --default-toolchain none -y
echo "$HOME/.elan/bin" >> $GITHUB_PATH

- name: Set up elan for website
run: |
elan default $(cat lean-toolchain)
build-args: --wfail
test: false
lint: false

- name: Build website
- name: Generate website
run: |
lake run generate

# - name: Set up elan for cslib docs
# working-directory: cslib/docs
# run: |
# elan default $(cat lean-toolchain)

# - name: Get cache
# working-directory: cslib/docs
# run: |
# lake exe cache get

# - name: Build cslib docs
# working-directory: cslib/docs
# run: |
# env LEAN_ABORT_ON_PANIC=1 lake build Cslib:docs

# - name: Prepare docs in api folder
# run: |
# mkdir -p _cslib.org/api
# cp -r cslib/docs/doc/* _cslib.org/api/

- name: Upload pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: '_cslib.org'

deploy:
needs: build-docs
needs: build
if: github.ref == 'refs/heads/main'

permissions:
pages: write
Expand All @@ -80,6 +48,5 @@ jobs:

steps:
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
id: deployment
uses: actions/deploy-pages@v5
37 changes: 18 additions & 19 deletions Lang/Components/ArchiveEntry.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import Verso.Doc.Html
import VersoBlog
import Lang.Components.Icon

open Verso.Output Html
open Verso.Output
open Verso.Genre.Blog Template

namespace Lang
namespace Components

private def extractText (html : Html) : String :=
match html with
| Html.text _ content => content
| Html.tag _ _ contents => extractText contents
| Html.seq contents =>
| .text content | .raw content => content
| .element _ _ contents => extractText contents
| .seq contents =>
contents.foldl (fun acc h => acc ++ extractText h) ""

private def htmlTextLength (html : Html) : Nat :=
Expand All @@ -35,40 +35,39 @@ private def truncateHtml (html : Html) (maxLength : Nat) : Html :=
else acc ++ "..."
else buildResult newAcc rest
let truncatedText := buildResult "" words
Html.text false truncatedText
Lean.Html.raw truncatedText

def archiveEntry (target : String) (metadata : Option Post.PartMetadata) (title : String) (summary : Option Html) (image : Option (String × String)) : Html :=
{{
html%{
<li>
{{ image.map (fun x => {{<img src={{x.fst}} alt={{x.snd}} />}}) }}
{image.map (fun x => html%{<img src={x.fst} alt={x.snd}/>})}

<div class="archive-content">

{{ match metadata with
{match metadata with
| none => Html.empty
| some md => {{
| some md => html%{
<div class="metadata">
{{(md : Post.PartMetadata).authors.map ({{<div class="author">{{Html.text true ·}}</div>}}) |>.toArray}}
{(md : Post.PartMetadata).authors.map (html%{<div class="author">{Lean.Html.text ·}</div>}) |>.toArray}
<div class="date">
{{md.date.toIso8601String}}
{md.date.toIso8601String}
</div>
</div>
}}
}}

<a href={{target}} class="title">
<span class="name">{{title}}</span>
<a href={target} class="title">
<span class="name">{title}</span>
</a>

{{truncateHtml summary 200}}
{truncateHtml summary 200}

<a href={{target}} class="read-more">
"Read more"
{{ Icon.arrowForward (width := "20px") (fill := "#000") }}
<a href={target} class="read-more">
Read more
{Icon.arrowForward (width := "20px") (fill := "#000")}
</a>
</div>
</li>
}}
}

end Components
end Lang
8 changes: 4 additions & 4 deletions Lang/Components/Aside.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Verso.Doc.Html
import VersoBlog
import Lang.Components.Icon

open Verso.Output Html
open Verso.Output
open Verso.Genre.Blog Template

namespace Lang
Expand All @@ -12,13 +12,13 @@ namespace Components
The `aside` component is used to create a sidebar with a title and content.
-/
def aside (_title : String) (content : Html): Html :=
{{
html%{
<aside>
<nav class="post-index">
{{ content }}
{content}
</nav>
</aside>
}}
}

end Components
end Lang
9 changes: 2 additions & 7 deletions Lang/Components/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Verso.Doc.Html
import VersoBlog

open Verso.Genre.Blog
open Verso.Output Html
open Verso.Output
open Verso.Doc Html
open Verso ArgParse
open Verso.Genre
Expand Down Expand Up @@ -40,12 +40,7 @@ partial defmethod Array.chunk (array : Array α) (size : Nat) : Array (Array α)
Sets or updates the given attribute on the first HTML tag node.
-/
def setAttribute (attr : String) (value : String) (html : Html) : Html :=
match html with
| .tag name attrs children =>
match attrs.findIdx? ((· == attr) ∘ Prod.fst) with
| none => .tag name (attrs.push (attr, value)) children
| some i => .tag name (attrs.set! i (attr, value)) children
| _ => html
html.setAttribute attr value

/--
Sets an attribute on an HTML element only if the value is defined.
Expand Down
16 changes: 8 additions & 8 deletions Lang/Components/Citation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Lean.Elab
import VersoBlog

open Verso Genre
open Verso.Output Html
open Verso.Output

namespace Lang
namespace Components
Expand All @@ -19,15 +19,15 @@ deriving Lean.ToJson, Lean.FromJson
This is a method of grouping things inside of a `.seq` inside a Page or Post.
-/
def citation (citation : Citation) : Html :=
{{
html%{
<div class="citation-item" id="author2023">
<span class="citation-authors">{{ citation.authors }}</span>
<span class="citation-title">{{ citation.title }}</span>
<span class="citation-venue">{{ citation.venue }}</span>
<span class="citation-year">{{ citation.date }} </span>
<span class="citation-pages">{{ citation.pages }}</span>
<span class="citation-authors">{citation.authors}</span>
<span class="citation-title">{citation.title}</span>
<span class="citation-venue">{citation.venue}</span>
<span class="citation-year">{citation.date}</span>
<span class="citation-pages">{citation.pages}</span>
</div>
}}
}

end Components
end Lang
40 changes: 20 additions & 20 deletions Lang/Components/CodeBlock.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Lean
import Lang.Components.Icon

open Lean Elab Term
open Verso.Output Html
open Verso.Output
open Lang Components Icon
open Verso Genre Blog ArgParse Doc Elab

Expand All @@ -23,48 +23,48 @@ block_component codeGallery where
let chunks := content.chunk 4

let tabs ← chunks.mapIdxM fun idx chunk => do
return {{
<div class=s!"hero-code-tab{if idx == 0 then " active" else ""}" role="tab" aria-selected={{if idx = 0 then "true" else "false"}}>
{{ ← goB <| chunk[0]! }}
return html%{
<div class={s!"hero-code-tab{if idx == 0 then " active" else ""}"} role="tab" aria-selected={if idx = 0 then "true" else "false"}>
{← goB <| chunk[0]!}
</div>
}}
}

let snippets ← chunks.mapIdxM fun idx chunk => do
return {{
<div class=s!"hero-code-snippet{if idx == 0 then " visible-code" else ""}">
{{ ← goB <| chunk[1]! }}
return html%{
<div class={s!"hero-code-snippet{if idx == 0 then " visible-code" else ""}"}>
{← goB <| chunk[1]!}
</div>
}}
}

let tips ← chunks.mapIdxM fun idx chunk => do
return {{
<div class=s!"hero-code-tip{if idx == 0 then " active" else ""}">
return html%{
<div class={s!"hero-code-tip{if idx == 0 then " active" else ""}"}>
<span>
{{ ← goB <| chunk[2]! }}
{← goB <| chunk[2]!}
</span>
<a class="hero-code-run" href={{extractBlock chunk[3]! |>.getD ""}}>
{{ Icon.arrowRight (fill := "#386EE0") (width := "25px") }}
<a class="hero-code-run" href={extractBlock chunk[3]! |>.getD ""}>
{Icon.arrowRight (fill := "#386EE0") (width := "25px")}
</a>
</div>
}}
}

return {{
return html%{
<div class="hero-code-box">
<div class="hero-code-tabs" role="tablist">
{{ tabs}}
{tabs}
<div class="hero-code-tab filler"></div>
<div class="hero-code-tab-border"></div>
</div>
<div class="hero-code-content" tabindex="-1">
{{ snippets}}
{snippets}
</div>
<div class="hero-code-footer">
<div class="hero-footer-left">
{{ tips }}
{tips}
</div>
</div>
</div>
}}
}

end Components
end Lang
2 changes: 1 addition & 1 deletion Lang/Components/Container.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Lean.Elab
import VersoBlog

open Verso Genre
open Verso.Output Html
open Verso.Output

namespace Lang
namespace Components
Expand Down
12 changes: 6 additions & 6 deletions Lang/Components/Feature.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Lean
import Lang.Components.Icon

open Lean Elab Term
open Verso.Output Html
open Verso.Output
open Lang Components Icon
open Verso Genre Blog ArgParse Doc Elab

Expand All @@ -32,19 +32,19 @@ def features : Array Feature := #[

block_component feature (feature : Feature) where
toHtml _ _ _ _ _ := do
return {{
return html%{
<article class="hero-feature">
<header class="hero-feature-title">
<figure class="feature-icon">
<span class="feature-icon">{{Icon.render feature.icon}}</span>
<span class="feature-icon">{Icon.render feature.icon}</span>
</figure>
<h3 class="feature-text">{{feature.title}}</h3>
<h3 class="feature-text">{feature.title}</h3>
</header>
<p class="hero-feature-description">
{{feature.desc}}
{feature.desc}
</p>
</article>
}}
}

end Components
end Lang
Loading
Loading