Skip to content

Commit e08ca83

Browse files
authored
Add docs generation. (#109)
1 parent 8ccb0c7 commit e08ca83

File tree

9 files changed

+486
-4
lines changed

9 files changed

+486
-4
lines changed

.github/workflows/docs.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-22.04
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: true
24+
25+
- uses: ./.github/actions/setup
26+
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.x'
30+
31+
- uses: astral-sh/setup-uv@v6
32+
33+
- uses: actions/cache@v4
34+
with:
35+
path: |
36+
~/.cargo/bin/
37+
~/.cargo/registry/index/
38+
~/.cargo/registry/cache/
39+
~/.cargo/git/db/
40+
target/
41+
key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}
42+
restore-keys: |
43+
${{ runner.os }}-cargo-docs-
44+
${{ runner.os }}-cargo-
45+
46+
- name: Build extension and generate stubs
47+
run: |
48+
cd crates/processing_pyo3
49+
uv run maturin develop --release
50+
cd ../..
51+
cargo run --release -p generate_stubs
52+
53+
- name: Build docs
54+
run: uv run --project crates/processing_pyo3 --group docs mkdocs build
55+
56+
- uses: actions/upload-pages-artifact@v3
57+
with:
58+
path: site/
59+
60+
deploy:
61+
needs: build
62+
runs-on: ubuntu-latest
63+
environment:
64+
name: github-pages
65+
url: ${{ steps.deployment.outputs.page_url }}
66+
steps:
67+
- id: deployment
68+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/target/
2+
/site/
23
crates/processing_ffi/include/
4+
crates/processing_pyo3/mewnala/*.pyi
35
.DS_Store
46
.ipynb_checkpoints/

crates/processing_pyo3/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ Issues = "https://github.com/processing/libprocessing/issues"
3535

3636
[dependency-groups]
3737
dev = ["maturin>=1.10,<2.0"]
38+
docs = [
39+
"mkdocs-material>=9.6",
40+
"mkdocstrings[python]>=0.29",
41+
"mkdocs-gen-files>=0.5",
42+
]
3843

3944
[tool.maturin]
4045
manifest-path = "Cargo.toml"

crates/processing_pyo3/uv.lock

Lines changed: 307 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/processing_render/src/material/custom.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,13 @@ impl ErasedRenderAsset for CustomMaterial {
403403
let bind_group_layout =
404404
BindGroupLayoutDescriptor::new("custom_material_bind_group", &layout_entries);
405405

406-
let bindings =
407-
reflection.create_bindings(3, &source_asset.shader, render_device, gpu_images, gpu_buffers);
406+
let bindings = reflection.create_bindings(
407+
3,
408+
&source_asset.shader,
409+
render_device,
410+
gpu_images,
411+
gpu_buffers,
412+
);
408413

409414
let unprepared = UnpreparedBindGroup {
410415
bindings: BindingResources(bindings),

docs/gen_ref_pages.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from pathlib import Path
2+
3+
import mkdocs_gen_files
4+
5+
readme = Path("crates/processing_pyo3/README.md").read_text(encoding="utf-8")
6+
with mkdocs_gen_files.open("index.md", "w") as f:
7+
f.write(readme)
8+
9+
modules = {
10+
"reference/index.md": ("API Reference", "mewnala", {"show_submodules": False}),
11+
"reference/math.md": ("mewnala.math", "mewnala.math", {}),
12+
"reference/color.md": ("mewnala.color", "mewnala.color", {}),
13+
}
14+
15+
for path, (title, module, options) in modules.items():
16+
with mkdocs_gen_files.open(path, "w") as f:
17+
f.write(f"# {title}\n\n")
18+
if options:
19+
opts = "\n".join(f" {k}: {v}" for k, v in options.items())
20+
f.write(f"::: {module}\n options:\n{opts}\n")
21+
else:
22+
f.write(f"::: {module}\n")

justfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ py-jupyter file: py-build
2020
py-ipython: py-build
2121
cd crates/processing_pyo3; ipython
2222

23+
docs-serve: py-stubs
24+
uv run --project crates/processing_pyo3 --group docs mkdocs serve
25+
26+
docs-build: py-stubs
27+
uv run --project crates/processing_pyo3 --group docs mkdocs build
28+
2329
wasm-build:
2430
wasm-pack build crates/processing_wasm --target web --out-dir ../../target/wasm
2531

mkdocs.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
site_name: mewnala
2+
site_description: Mewnala, I choose you!
3+
site_url: https://processing.github.io/libprocessing/
4+
repo_url: https://github.com/processing/libprocessing
5+
repo_name: processing/libprocessing
6+
7+
theme:
8+
name: material
9+
palette:
10+
- scheme: default
11+
primary: deep purple
12+
accent: pink
13+
toggle:
14+
icon: material/brightness-7
15+
name: Switch to dark mode
16+
- scheme: slate
17+
primary: deep purple
18+
accent: pink
19+
toggle:
20+
icon: material/brightness-4
21+
name: Switch to light mode
22+
features:
23+
- content.code.copy
24+
- navigation.sections
25+
- navigation.expand
26+
- search.highlight
27+
28+
plugins:
29+
- search
30+
- gen-files:
31+
scripts:
32+
- docs/gen_ref_pages.py
33+
- mkdocstrings:
34+
handlers:
35+
python:
36+
paths:
37+
- crates/processing_pyo3
38+
options:
39+
allow_inspection: false
40+
show_source: false
41+
show_root_heading: true
42+
show_root_full_path: false
43+
members_order: alphabetical
44+
docstring_style: google
45+
show_if_no_docstring: true
46+
filters:
47+
- "!^_"
48+
49+
nav:
50+
- Home: index.md
51+
- API Reference:
52+
- Overview: reference/index.md
53+
- Math: reference/math.md
54+
- Color: reference/color.md
55+
- Design:
56+
- Principles: principles.md
57+
- Internal API: api.md
58+
59+
markdown_extensions:
60+
- pymdownx.highlight:
61+
anchor_linenums: true
62+
- pymdownx.superfences
63+
- pymdownx.inlinehilite
64+
- admonition
65+
- pymdownx.details

tools/generate_stubs/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ fn main() {
4141

4242
eprintln!("Introspecting: {}", cdylib_path.display());
4343

44-
let module = introspect_cdylib(&cdylib_path, "mewnala").expect("Failed to introspect cdylib");
44+
let mut module =
45+
introspect_cdylib(&cdylib_path, "mewnala").expect("Failed to introspect cdylib");
46+
47+
module.incomplete = false;
4548

4649
let stubs = module_stub_files(&module);
4750

0 commit comments

Comments
 (0)