Skip to content

Commit 1a384fd

Browse files
DelevoXDGmaciektr
andcommitted
Add scarb-doc-generated corelib docs to GitHub Pages (#1658)
Closes #1381 Preview: - https://delevoxdg.github.io/scarb/corelib/index.html - https://delevoxdg.github.io/scarb/docs --------- Signed-off-by: maciektr <[email protected]> Co-authored-by: maciektr <[email protected]>
1 parent 3967bd4 commit 1a384fd

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.github/workflows/website-deploy.yml

+44
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,48 @@ concurrency:
1616
cancel-in-progress: true
1717

1818
jobs:
19+
build-corelib-docs:
20+
runs-on: ubuntu-latest
21+
env:
22+
MDBOOK_VERSION: 0.4.31
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: dtolnay/rust-toolchain@stable
26+
- uses: Swatinem/rust-cache@v2
27+
- name: Install mdBook
28+
run: cargo install --version ${MDBOOK_VERSION} mdbook
29+
- uses: software-mansion/setup-scarb@v1
30+
- name: Init Scarb to cache corelib
31+
id: scarb-init
32+
run: |
33+
mkdir -p $HOME/pkg
34+
pushd $HOME/pkg
35+
scarb init --no-vcs
36+
echo "CORELIB_PATH=$(scarb metadata --format-version 1 | jq -r '.packages[] | select(.name == "core") | .root')" >> $GITHUB_OUTPUT
37+
env:
38+
SCARB_INIT_TEST_RUNNER: cairo-test
39+
- name: Extract corelib from Scarb cache
40+
run: |
41+
mkdir -p core
42+
cp -r ${{ steps.scarb-init.outputs.CORELIB_PATH }}/* ./core
43+
- name: Generate and build corelib docs
44+
run: |
45+
scarb doc --all-features
46+
pushd target/doc/core
47+
mdbook build
48+
working-directory: ./core
49+
- name: Apply custom highlighting
50+
run: |
51+
curl -o highlight.js https://raw.githubusercontent.com/software-mansion/scarb/main/extensions/scarb-doc/theme/highlight.js
52+
cp highlight.js ./core/target/doc/core/highlight.js
53+
- uses: actions/upload-artifact@v4
54+
with:
55+
name: corelib-docs
56+
path: ./core/target/doc/core/book
57+
1958
build:
2059
runs-on: ubuntu-latest
60+
needs: build-corelib-docs
2161
defaults:
2262
run:
2363
working-directory: ./website
@@ -32,6 +72,10 @@ jobs:
3272
- uses: actions/configure-pages@v5
3373
- run: npm ci
3474
- run: npm run build
75+
- uses: actions/download-artifact@v4
76+
with:
77+
name: corelib-docs
78+
path: website/.vitepress/dist/corelib
3579
- name: Upload GitHub Pages artifact
3680
uses: actions/upload-pages-artifact@v3
3781
with:

website/.vitepress/config.mjs

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ const sidebar = {
6262
p("Scripts", "/docs/reference/scripts"),
6363
p("Specifying dependencies", "/docs/reference/specifying-dependencies"),
6464
p("Targets", "/docs/reference/targets"),
65+
p(
66+
"Corelib documentation",
67+
"https://docs.swmansion.com/scarb/corelib/index.html",
68+
),
6569
],
6670
},
6771
{

0 commit comments

Comments
 (0)