Skip to content

Commit bb5516a

Browse files
authored
Merge pull request #14 from torusJKL/add-docstrings
- Add docstrings for all public functions - Use Staple to generate documentation pages
2 parents c7fd787 + 1cb9761 commit bb5516a

100 files changed

Lines changed: 5301 additions & 16 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
docs:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Install system dependencies
15+
run: |
16+
sudo apt-get update
17+
sudo apt-get install -y cmake g++ sbcl curl just libfreetype-dev libx11-dev libfontconfig-dev libgl1-mesa-dev
18+
19+
- name: Install Quicklisp
20+
run: |
21+
curl -O https://beta.quicklisp.org/quicklisp.lisp
22+
sbcl --load quicklisp.lisp \
23+
--eval "(quicklisp-quickstart:install)" \
24+
--quit
25+
26+
- name: Get OCCT version
27+
run: |
28+
echo "OCCT_VERSION=$(grep -oP '(?<=occt-version := ")[^"]+' justfile)" >> $GITHUB_ENV
29+
30+
- name: Cache OCCT build
31+
id: cache-occt
32+
uses: actions/cache@v4
33+
with:
34+
path: .local
35+
key: occt-${{ env.OCCT_VERSION }}-visual
36+
37+
- name: Build OCCT (cache miss)
38+
if: steps.cache-occt.outputs.cache-hit != 'true'
39+
run: |
40+
just setup 2>&1 | tail -500
41+
exit ${PIPESTATUS[0]}
42+
43+
- name: Build C wrapper
44+
run: just wrap
45+
46+
- name: Generate Staple docs
47+
run: just docs
48+
49+
- name: Deploy to GitHub Pages
50+
uses: peaceiris/actions-gh-pages@v4
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
publish_dir: ./docs
54+
publish_branch: gh-pages

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ lib/
33
*.step
44
*.fasl
55
*.fas
6+
docs/

justfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ default:
1717
@echo " wrap Compile C wrapper → lib/libocctwrap.so"
1818
@echo " start Launch SBCL REPL with cl-occt loaded (via Quicklisp)"
1919
@echo " repl Launch SBCL REPL with cl-occt loaded (standalone)"
20+
@echo " docs Generate Staple HTML documentation into docs/"
2021
@echo " test-core Run ~200 core tests (geometry, I/O, DAG) — no X display needed"
2122
@echo " test-viewer Run ~80 viewer tests (rendering, AIS, camera) — needs xvfb-run"
2223
@echo " test-all Run all 288 tests under xvfb-run"
@@ -72,6 +73,18 @@ repl:
7273
clean:
7374
rm -rf {{occt-build}} {{occt-src}} {{occt-tarball}}
7475

76+
docs:
77+
# Generate Staple HTML documentation
78+
mkdir -p {{root-dir}}/docs
79+
LD_LIBRARY_PATH={{root-dir}}/lib:{{occt-install}}/lib \
80+
{{sbcl}} --load ~/quicklisp/setup.lisp \
81+
--eval "(push \"{{root-dir}}/\" asdf:*central-registry*)" \
82+
--eval "(ql:quickload :staple)" \
83+
--eval "(ql:quickload :staple-markdown)" \
84+
--eval "(ql:quickload :cl-occt)" \
85+
--eval "(staple:generate :cl-occt :if-exists :supersede :output-directory #p\"{{root-dir}}/docs/\")" \
86+
--quit
87+
7588
test-core:
7689
# Run core tests (geometry, I/O, DAG, colors, text shapes) — no X display needed
7790
LD_LIBRARY_PATH={{root-dir}}/lib:{{occt-install}}/lib \
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
schema: spec-driven
2+
created: 2026-05-23
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Context
2+
3+
Six files span geometry algorithms (projection, intersection, interpolation), physical properties (volume, area, center of mass), shape validity checking, shape fixing/healing, and NURBS rebuild. These are the most mathematically complex functions in cl-occt.
4+
5+
## Goals / Non-Goals
6+
7+
**Goals:**
8+
- Every public function gets docstring with example
9+
- Parameter descriptions for functions with many parameters (e.g., `interpolate-points`, `substitute-shape`)
10+
- `See also:` linking between related functions (`shape-volume``shape-area``shape-center-of-mass`)
11+
12+
**Non-Goals:**
13+
- No functional or API changes
14+
15+
## Decisions
16+
17+
- **Geometry algorithm examples** should use simple known shapes (box, sphere) as test inputs
18+
- **Mass properties examples** should show `gprops` object accessors
19+
- **Shape fix examples** can use `shape-check` to demonstrate validation before/after fix
20+
- **Shape rebuild examples** should show degree reduction and continuity upgrade on a known shape
21+
22+
## Risks / Trade-offs
23+
24+
- **Interpolation and NURBS conversion** examples are inherently long — maintain readability
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Why
2+
3+
The geometry analysis, mass properties, shape analysis, shape fix, shape healing, and shape rebuild functions are powerful but opaque. Users need docstrings to understand parameters for operations like point projection, curve intersection, shape distance, volume/area calculation, shape fixing, and NURBS conversion.
4+
5+
## What Changes
6+
7+
- Add docstrings with `Example:` blocks to all public functions across 6 analysis/healing files
8+
- No functional or API changes — documentation only
9+
10+
Files modified: `src/core/geom-algorithms.lisp`, `src/core/mass-properties.lisp`, `src/core/shape-analysis.lisp`, `src/core/shape-fix.lisp`, `src/core/shape-process.lisp`, `src/core/shape-rebuild.lisp`
11+
12+
## Capabilities
13+
14+
### New Capabilities
15+
16+
None — documentation enhancement only.
17+
18+
### Modified Capabilities
19+
20+
None — no spec-level behavior changes.
21+
22+
## Impact
23+
24+
- `src/core/geom-algorithms.lisp`: 11 functions — `project-point-on-curve`, `project-point-on-surface`, `intersect-curves`, `intersect-curve-surface`, `intersect-surfaces`, `extrema-curve-curve`, `extrema-curve-surface`, `intersect-curves-2d`, `project-point-on-curve-2d`, `points-to-bspline`, `interpolate-points`
25+
- `src/core/mass-properties.lisp`: 5 functions — `shape-gprops`, `shape-volume`, `shape-area`, `shape-center-of-mass`, `shape-inertia`
26+
- `src/core/shape-analysis.lisp`: 7 functions — `shape-distance`, `shape-distance-extrema`, `point-in-solid-p`, `classify-point-in-solid`, `shape-valid-p`, `shape-check`, `intersect-curve-shape`
27+
- `src/core/shape-fix.lisp`: 9 functions — `fix-shape`, `fix-wire`, `fix-solid`, `fix-edge`, `fix-face`, `shape-analysis-free-edges`, `shape-analysis-check-intersections`, `shape-analysis-wire-contains-p`, `shape-analysis-contents`
28+
- `src/core/shape-process.lisp`: 3 functions — `apply-shape-process`, `apply-healing-pipeline`, `heal-shape`
29+
- `src/core/shape-rebuild.lisp`: 6 functions — `substitute-shape`, `shape-to-nurbs`, `shape-reduce-degree`, `shape-to-rational-bspline`, `shape-split-u`, `shape-upgrade-continuity`
30+
- All existing tests should pass unchanged
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This change is documentation-only. No spec-level behavior changes.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
## 1. Geometry algorithms (`geom-algorithms.lisp`)
2+
3+
- [x] 1.1 Add docstring + example to `project-point-on-curve`
4+
- [x] 1.2 Add docstring + example to `project-point-on-surface`
5+
- [x] 1.3 Add docstring + example to `intersect-curves`
6+
- [x] 1.4 Add docstring + example to `intersect-curve-surface`
7+
- [x] 1.5 Add docstring + example to `intersect-surfaces`
8+
- [x] 1.6 Add docstring + example to `extrema-curve-curve`
9+
- [x] 1.7 Add docstring + example to `extrema-curve-surface`
10+
- [x] 1.8 Add docstring + example to `intersect-curves-2d`
11+
- [x] 1.9 Add docstring + example to `project-point-on-curve-2d`
12+
- [x] 1.10 Add docstring + example to `points-to-bspline`
13+
- [x] 1.11 Add docstring + example to `interpolate-points`
14+
15+
## 2. Mass properties (`mass-properties.lisp`)
16+
17+
- [x] 2.1 Add docstring + example to `shape-gprops`
18+
- [x] 2.2 Add docstring + example to `shape-volume`
19+
- [x] 2.3 Add docstring + example to `shape-area`
20+
- [x] 2.4 Add docstring + example to `shape-center-of-mass`
21+
- [x] 2.5 Add docstring + example to `shape-inertia`
22+
23+
## 3. Shape analysis (`shape-analysis.lisp`)
24+
25+
- [x] 3.1 Add docstring + example to `shape-distance`
26+
- [x] 3.2 Add docstring + example to `shape-distance-extrema`
27+
- [x] 3.3 Add docstring + example to `point-in-solid-p`
28+
- [x] 3.4 Add docstring + example to `classify-point-in-solid`
29+
- [x] 3.5 Add docstring + example to `shape-valid-p`
30+
- [x] 3.6 Add docstring + example to `shape-check`
31+
- [x] 3.7 Add docstring + example to `intersect-curve-shape`
32+
33+
## 4. Shape fix (`shape-fix.lisp`)
34+
35+
- [x] 4.1 Add docstring + example to `fix-shape`
36+
- [x] 4.2 Add docstring + example to `fix-wire`
37+
- [x] 4.3 Add docstring + example to `fix-solid`
38+
- [x] 4.4 Add docstring + example to `fix-edge`
39+
- [x] 4.5 Add docstring + example to `fix-face`
40+
- [x] 4.6 Add docstring + example to `shape-analysis-free-edges`
41+
- [x] 4.7 Add docstring + example to `shape-analysis-check-intersections`
42+
- [x] 4.8 Add docstring + example to `shape-analysis-wire-contains-p`
43+
- [x] 4.9 Add docstring + example to `shape-analysis-contents`
44+
45+
## 5. Shape process (`shape-process.lisp`)
46+
47+
- [x] 5.1 Add docstring + example to `apply-shape-process`
48+
- [x] 5.2 Add docstring + example to `apply-healing-pipeline`
49+
- [x] 5.3 Add docstring + example to `heal-shape`
50+
51+
## 6. Shape rebuild (`shape-rebuild.lisp`)
52+
53+
- [x] 6.1 Add docstring + example to `substitute-shape`
54+
- [x] 6.2 Add docstring + example to `shape-to-nurbs`
55+
- [x] 6.3 Add docstring + example to `shape-reduce-degree`
56+
- [x] 6.4 Add docstring + example to `shape-to-rational-bspline`
57+
- [x] 6.5 Add docstring + example to `shape-split-u`
58+
- [x] 6.6 Add docstring + example to `shape-upgrade-continuity`
59+
60+
## 7. Verification
61+
62+
- [x] 7.1 Run `just test-core` to verify no breakage
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
schema: spec-driven
2+
created: 2026-05-23
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Context
2+
3+
The `cl-occt` package has 381 public API functions, none of which have docstrings with examples. This change targets 17 functions across 5 files that form the core geometric primitives, boolean operations, transforms, compounds, and shape predicate.
4+
5+
The user-provided `cut` example establishes the docstring convention:
6+
- Description line explaining what the function does
7+
- Parameter descriptions for complex functions
8+
- `Example:` block with REPL-style usage
9+
- `See also:` cross-references to related functions
10+
11+
## Goals / Non-Goals
12+
13+
**Goals:**
14+
- Every public function in the target files gets a docstring
15+
- Every non-trivial docstring includes a usage example
16+
- Trivial predicates (`shape-p`) get a docstring description without example
17+
- Cross-reference related functions via `See also:` where natural
18+
19+
**Non-Goals:**
20+
- No functional or API changes
21+
- No changes to internal (`%`-prefixed or `cl-occt.impl` package) functions
22+
- No changes to test files
23+
- No changes to existing specs
24+
25+
## Decisions
26+
27+
**Docstring format** — Loose template, not rigid:
28+
- Simple creators (`make-box`): description + brief example showing call with args
29+
- Boolean ops (`cut`/`fuse`/etc.): description + example showing `display` and `def` usage + `See also:`
30+
- Accessors (`compound-shape-p`): description + short example
31+
- Trivial predicates (`shape-p`): description only
32+
33+
**Example style** — REPL output is shown as comments. Examples should be self-contained where possible. For boolean ops, use `def` for intermediate shapes and `display` for result visualization (matching the user's `cut` example style).
34+
35+
**Cross-references**`See also:` with backtick-quoted function names. For related groups (booleans, primitives), list sibling functions.
36+
37+
**No specs needed** — This is a documentation-only change. No requirement behavior changes.
38+
39+
## Risks / Trade-offs
40+
41+
- **Inconsistency risk** → Multiple files touched, but following the established `cut` example as a style guide minimizes drift
42+
- **No automated validation** → Docstring correctness isn't testable. Manual review is the only check.

0 commit comments

Comments
 (0)