Skip to content

Commit 55c94ed

Browse files
satraclaude
andauthored
Docs PR preview + 7 doc.md files + README fixes (#479)
* Docs PR preview workflow + 7 doc.md files + README fixes New workflow: - docs-preview.yaml: auto-builds docs preview on PR open/update, deploys to pr-{number}/ subdirectory, posts comment with link, cleans up on PR close/merge Documentation coverage: - 7 missing doc.md files: preprocessing, input_output, plotting, quality_control, ssl_embeddings, speaker_diarization_evaluation, text/embeddings_extraction README fixes: - Documentation URL: sensein.group → sensein.github.io - tutorials/README.md: added 3 new tutorials Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix docs workflow: use --all-extras (articulatory extra removed) Both docs.yaml and docs-preview.yaml referenced --extra articulatory which no longer exists. Use --all-extras instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix docs build: install FFmpeg, guard ffmpeg-python import - docs-preview.yaml: add FFmpeg system install step - video/tasks/input_output.py: guard ffmpeg import with try/except (ffmpeg-python was never in pyproject.toml dependencies) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix docs URLs to use canonical sensein.group/senselab GitHub Pages CNAME is sensein.group (confirmed via gh api pages). Updated: docs-preview.yaml comment URL, README.md badge + link, pyproject.toml Documentation URL. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add doc.md include directives to __init__.py + fix URLs to sensein.group - 7 __init__.py files updated with """.. include:: ./doc.md""" so pdoc renders the doc.md content in generated documentation - All docs URLs standardized to sensein.group/senselab (the canonical CNAME confirmed via GitHub Pages API) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Use deployment environment for docs preview URL instead of PR comment The preview URL now shows as a "View deployment" button in the PR checks UI via GitHub deployment environments. Each PR gets its own environment (docs-preview-pr-{number}) which is cleaned up on close. Removed PR comment posting — the deployment link in the checks UI is cleaner and doesn't spam the PR thread. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5cc1ff6 commit 55c94ed

26 files changed

Lines changed: 465 additions & 12 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Docs Preview
2+
3+
permissions:
4+
contents: write
5+
pull-requests: write
6+
deployments: write
7+
8+
on:
9+
pull_request:
10+
types: [opened, synchronize, reopened, closed]
11+
12+
jobs:
13+
build-and-deploy:
14+
if: github.event.action != 'closed'
15+
runs-on: ubuntu-latest
16+
environment:
17+
name: docs-preview-pr-${{ github.event.pull_request.number }}
18+
url: https://sensein.group/senselab/pr-${{ github.event.pull_request.number }}/
19+
steps:
20+
- uses: actions/checkout@v5
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
- uses: actions/setup-python@v6
24+
with:
25+
python-version: '3.12'
26+
- name: Install FFmpeg
27+
run: bash scripts/install-ffmpeg.sh
28+
- name: Install dependencies
29+
run: uv sync --all-extras --group dev --group docs
30+
- name: Build docs
31+
env:
32+
PDOC_ALLOW_EXEC: '1'
33+
run: |
34+
APP_MODULE_NAME=$(ls -1 src | sort | head -1)
35+
uv run pdoc src/"$APP_MODULE_NAME" -o docs -t docs_style/pdoc-theme --docformat google --favicon https://readthedocs.org/favicon.ico
36+
touch docs/.nojekyll
37+
- name: Deploy preview
38+
uses: JamesIves/github-pages-deploy-action@v4
39+
with:
40+
folder: docs
41+
branch: docs
42+
target-folder: pr-${{ github.event.pull_request.number }}
43+
clean: false
44+
45+
cleanup:
46+
if: github.event.action == 'closed'
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v5
50+
with:
51+
ref: docs
52+
fetch-depth: 0
53+
- name: Remove preview
54+
run: |
55+
PR_NUM=${{ github.event.pull_request.number }}
56+
if [ -d "pr-${PR_NUM}" ]; then
57+
git rm -rf "pr-${PR_NUM}"
58+
git config user.name "github-actions[bot]"
59+
git config user.email "github-actions[bot]@users.noreply.github.com"
60+
git commit -m "Remove docs preview for PR #${PR_NUM}"
61+
git push origin docs
62+
fi
63+
- name: Delete environment
64+
uses: strumwolf/delete-deployment-environment@v3
65+
with:
66+
token: ${{ secrets.GITHUB_TOKEN }}
67+
environment: docs-preview-pr-${{ github.event.pull_request.number }}

.github/workflows/docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
python-version: ${{ matrix.python-version }}
3636
- name: Install dependencies with uv
3737
run: |
38-
uv sync --extra articulatory --extra text --extra video --extra senselab-ai --group dev --group docs
38+
uv sync --all-extras --group dev --group docs
3939
shell: bash
4040
- name: Build docs
4141
env:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Python Version](https://img.shields.io/pypi/pyversions/senselab)](https://pypi.org/project/senselab)
77
[![License](https://img.shields.io/pypi/l/senselab)](https://opensource.org/licenses/Apache-2.0)
88

9-
[![pages](https://img.shields.io/badge/api-docs-blue)](https://sensein.github.io/senselab)
9+
[![pages](https://img.shields.io/badge/api-docs-blue)](https://sensein.group/senselab)
1010
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/sensein/senselab)
1111

1212
# ```senselab```
@@ -36,7 +36,7 @@ print(transcript)
3636
# ➡️ "The quick brown fox jumps over the lazy dog."
3737
```
3838

39-
For more detailed information, check out our [**Documentation**](https://sensein.group/senselab/senselab.html) and our [**Tutorials**](https://github.com/sensein/senselab/blob/main/tutorials/audio/00_getting_started.ipynb).
39+
For more detailed information, check out our [**Documentation**](https://sensein.group/senselab) and our [**Tutorials**](https://github.com/sensein/senselab/blob/main/tutorials/audio/00_getting_started.ipynb).
4040

4141
💡 **Tip**: Many tutorials include Google Colab badges and you can try them instantly without installing anything on your local machine.
4242

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ senselab-ai = [
8282
[project.urls]
8383
Homepage = "https://github.com/sensein/senselab"
8484
Repository = "https://github.com/sensein/senselab"
85-
Documentation = "https://sensein.github.io/senselab"
85+
Documentation = "https://sensein.group/senselab"
8686

8787
[project.scripts]
8888
senselab-ai = "senselab.agentic_interface.launcher:senselab_ai"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Specification Quality Checklist: Docs PR Preview + Coverage Audit
2+
3+
**Purpose**: Validate specification completeness and quality before proceeding to planning
4+
**Created**: 2026-04-24
5+
**Feature**: [spec.md](../spec.md)
6+
7+
## Content Quality
8+
9+
- [x] No implementation details (languages, frameworks, APIs)
10+
- [x] Focused on user value and business needs
11+
- [x] Written for non-technical stakeholders
12+
- [x] All mandatory sections completed
13+
14+
## Requirement Completeness
15+
16+
- [x] No [NEEDS CLARIFICATION] markers remain
17+
- [x] Requirements are testable and unambiguous
18+
- [x] Success criteria are measurable
19+
- [x] Success criteria are technology-agnostic (no implementation details)
20+
- [x] All acceptance scenarios are defined
21+
- [x] Edge cases are identified
22+
- [x] Scope is clearly bounded
23+
- [x] Dependencies and assumptions identified
24+
25+
## Feature Readiness
26+
27+
- [x] All functional requirements have clear acceptance criteria
28+
- [x] User scenarios cover primary flows
29+
- [x] Feature meets measurable outcomes defined in Success Criteria
30+
- [x] No implementation details leak into specification
31+
32+
## Notes
33+
34+
- All items pass validation. Spec is ready for `/speckit.plan`.
35+
- Specific missing doc.md files identified: preprocessing, input_output, plotting, quality_control, ssl_embeddings, speaker_diarization_evaluation, text/embeddings_extraction
36+
- README URL inconsistency: line 39 uses sensein.group, should be sensein.github.io
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Implementation Plan: Docs PR Preview + Coverage Audit
2+
3+
**Branch**: `20260424-232054-docs-pr-preview` | **Date**: 2026-04-24 | **Spec**: [spec.md](spec.md)
4+
5+
## Summary
6+
7+
Add PR docs preview workflow (build + deploy on PR, cleanup on close), fill 7 missing doc.md files, fix README URL inconsistency, and verify tutorials/README.md accuracy.
8+
9+
## Technical Context
10+
11+
**Language/Version**: YAML (GitHub Actions), Markdown
12+
**Primary Dependencies**: pdoc, JamesIves/github-pages-deploy-action@v4, peter-evans/create-or-update-comment
13+
**Storage**: GitHub Pages (`docs` branch)
14+
**Testing**: Open a test PR and verify preview appears
15+
**Target Platform**: GitHub Actions CI
16+
**Project Type**: CI/CD workflow + documentation
17+
**Constraints**: Must not break existing release-triggered docs deployment
18+
19+
## Constitution Check
20+
21+
| Principle | Status | Notes |
22+
|-----------|--------|-------|
23+
| I. UV-Managed Python | PASS | Docs build uses `uv run pdoc` |
24+
| II. Encapsulated Testing | PASS | CI builds docs in isolated runner |
25+
| III. Commit Early and Often | PASS | Incremental changes |
26+
| IV. CI Must Stay Green | PASS | New workflow, doesn't modify existing |
27+
| VII. Simplicity First | PASS | Uses existing GitHub Pages infrastructure |
28+
29+
## Project Structure
30+
31+
```text
32+
.github/workflows/
33+
├── docs.yaml # EXISTING (release docs) — unchanged
34+
└── docs-preview.yaml # NEW (PR preview + cleanup)
35+
36+
src/senselab/audio/tasks/
37+
├── preprocessing/doc.md # NEW
38+
├── input_output/doc.md # NEW
39+
├── plotting/doc.md # NEW
40+
├── quality_control/doc.md # NEW
41+
├── ssl_embeddings/doc.md # NEW
42+
└── speaker_diarization_evaluation/doc.md # NEW
43+
44+
src/senselab/text/tasks/
45+
└── embeddings_extraction/doc.md # NEW
46+
47+
README.md # UPDATED (fix URL)
48+
tutorials/README.md # VERIFIED (add new tutorials if missing)
49+
```
50+
51+
## Implementation Phases
52+
53+
### Phase 1: Create PR Docs Preview Workflow
54+
55+
Create `.github/workflows/docs-preview.yaml` with two jobs:
56+
57+
**Job 1: build-and-deploy** (triggers on PR opened/synchronize/reopened)
58+
1. Build docs with pdoc (same command as release workflow)
59+
2. Deploy to `docs` branch under `pr-{PR_NUMBER}/` subdirectory
60+
3. Post/update PR comment with preview URL
61+
62+
**Job 2: cleanup** (triggers on PR closed)
63+
1. Remove `pr-{PR_NUMBER}/` from docs branch
64+
2. Update PR comment to note preview was removed
65+
66+
### Phase 2: Add Missing doc.md Files
67+
68+
Create 7 doc.md files with 3-5 sentence descriptions.
69+
70+
### Phase 3: Fix README and Verify
71+
72+
1. Fix README.md line 39 URL
73+
2. Verify tutorials/README.md lists all 20 tutorials including new ones
74+
3. Verify all feature descriptions match codebase
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Quickstart: Docs PR Preview + Coverage
2+
3+
## Build docs locally
4+
```bash
5+
uv run pdoc src/senselab -t docs_style/pdoc-theme --docformat google
6+
```
7+
8+
## Check doc.md coverage
9+
```bash
10+
for dir in src/senselab/audio/tasks/*/; do
11+
[ -f "$dir/doc.md" ] && echo "$(basename $dir)" || echo "$(basename $dir)"
12+
done
13+
```
14+
15+
## Test PR preview workflow
16+
Open a PR with a docstring change and verify the preview comment appears.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Research: Docs PR Preview + Coverage Audit
2+
3+
**Date**: 2026-04-24
4+
5+
## R1: PR Docs Preview Approach
6+
7+
**Decision**: Use GitHub Pages with subdirectory-based PR previews on the `docs` branch. Each PR gets deployed to `docs/pr-{number}/`, and cleanup removes that directory on PR close/merge.
8+
9+
**Rationale**: The existing docs infrastructure uses `JamesIves/github-pages-deploy-action@v4` deploying to the `docs` branch. PR previews as subdirectories keep everything in one place — no external services, no secrets, no additional costs.
10+
11+
**Alternatives considered**:
12+
- Netlify Deploy Previews: Requires Netlify account and secret token
13+
- Surge.sh: Requires account and CI token
14+
- GitHub Environments: More complex, designed for staging/production, overkill for docs previews
15+
- Separate gh-pages branch per PR: Branch pollution
16+
17+
## R2: PR Preview Workflow Design
18+
19+
**Decision**: Two workflow triggers:
20+
1. `pull_request: [opened, synchronize, reopened]` → build docs and deploy to `pr-{number}/` subdirectory
21+
2. `pull_request: [closed]` → delete `pr-{number}/` directory from docs branch
22+
23+
The build step posts/updates a PR comment with the preview URL using `peter-evans/create-or-update-comment`.
24+
25+
**Rationale**: The `synchronize` trigger ensures rebuilds on new commits. The `closed` trigger covers both merged and abandoned PRs. Comment posting gives reviewers a direct link.
26+
27+
## R3: Missing doc.md Files
28+
29+
**Decision**: Create doc.md files for these 7 modules:
30+
1. `src/senselab/audio/tasks/preprocessing/doc.md` — resample, downmix, normalize, chunk
31+
2. `src/senselab/audio/tasks/input_output/doc.md` — read/write audio files
32+
3. `src/senselab/audio/tasks/plotting/doc.md` — waveform, spectrogram, play_audio, plot_aligned_panels
33+
4. `src/senselab/audio/tasks/quality_control/doc.md` — QC framework, metrics, checks
34+
5. `src/senselab/audio/tasks/ssl_embeddings/doc.md` — self-supervised learning embeddings
35+
6. `src/senselab/audio/tasks/speaker_diarization_evaluation/doc.md` — DER metrics
36+
7. `src/senselab/text/tasks/embeddings_extraction/doc.md` — text embeddings
37+
38+
Each doc.md should be 3-5 sentences: what the module does, when to use it, and a usage pointer.
39+
40+
## R4: README URL Fix
41+
42+
**Decision**: Standardize all documentation URLs to `https://sensein.github.io/senselab` (the canonical GitHub Pages URL). Fix README line 39 which currently points to `https://sensein.group/senselab/senselab.html`.
43+
44+
**Rationale**: pyproject.toml and the badge both use `sensein.github.io`. The `sensein.group` URL may be an old redirect or alternate domain.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Feature Specification: Docs PR Preview + Coverage Audit
2+
3+
**Feature Branch**: `20260424-232054-docs-pr-preview`
4+
**Created**: 2026-04-24
5+
**Status**: Draft
6+
**Input**: Review the docs generation GitHub workflow and update it so PR previews are generated and then deleted after a PR is merged or closed. Check the generated docs page to make sure all aspects of senselab are covered and it's easy for a user to navigate. Also check any readme or other docs for consistency with the current codebase.
7+
8+
## User Scenarios & Testing *(mandatory)*
9+
10+
### User Story 1 - Developer Previews Docs Changes in PR (Priority: P1)
11+
12+
A developer opens a PR that modifies code with docstrings, tutorials, or doc.md files. A docs preview is automatically built and deployed to a temporary URL. The PR comment includes a link to the preview. When the PR is merged or closed, the preview is automatically cleaned up.
13+
14+
**Why this priority**: Docs changes are currently only visible after a release is published. Developers and reviewers have no way to preview how documentation will look, leading to formatting issues and broken links reaching production.
15+
16+
**Independent Test**: Open a PR that modifies a docstring, verify a preview link appears as a PR comment, click the link and see the rendered docs, then merge/close the PR and verify the preview is removed.
17+
18+
**Acceptance Scenarios**:
19+
20+
1. **Given** a PR is opened with code changes, **When** CI runs, **Then** a docs preview is built and a comment with the preview URL is posted on the PR.
21+
2. **Given** a docs preview exists for a PR, **When** the PR is merged, **Then** the preview deployment is automatically deleted within minutes.
22+
3. **Given** a docs preview exists for a PR, **When** the PR is closed without merging, **Then** the preview deployment is automatically deleted.
23+
4. **Given** a PR is updated with new commits, **When** CI runs again, **Then** the preview is rebuilt with the latest changes (same URL).
24+
25+
---
26+
27+
### User Story 2 - All Modules Have Documentation (Priority: P2)
28+
29+
A user browsing the docs site can find documentation for every module in senselab. No module is missing from the generated documentation. Each module has a doc.md providing context beyond auto-generated API docs.
30+
31+
**Why this priority**: 6 core audio modules currently lack doc.md files. Users looking for preprocessing, plotting, quality control, or I/O documentation find gaps.
32+
33+
**Independent Test**: Generate docs locally and verify every module under audio/tasks/, video/tasks/, text/tasks/, and utils/ appears with meaningful content.
34+
35+
**Acceptance Scenarios**:
36+
37+
1. **Given** the docs are generated, **When** a user navigates to the plotting module, **Then** they find documentation for `plot_aligned_panels` and other plotting functions with usage examples.
38+
2. **Given** the docs are generated, **When** a user navigates to any audio task module, **Then** every module has a doc.md with context about what it does and when to use it.
39+
3. **Given** new functions were added (SPARC decode/convert, PPG phoneme analysis, SpeechBrain SER, plot_aligned_panels), **When** docs are generated, **Then** these functions appear with complete docstrings.
40+
41+
---
42+
43+
### User Story 3 - README and Docs Are Consistent (Priority: P2)
44+
45+
A user reading the README finds accurate installation instructions, feature descriptions, and links that all point to the correct documentation site. No dead links or outdated references.
46+
47+
**Why this priority**: The README currently has inconsistent documentation URLs (sensein.group vs sensein.github.io) and the feature list may not reflect all recent additions.
48+
49+
**Independent Test**: Review README links, verify they resolve, and compare feature descriptions against the actual codebase.
50+
51+
**Acceptance Scenarios**:
52+
53+
1. **Given** the README, **When** a user clicks any documentation link, **Then** they reach the correct, live documentation page.
54+
2. **Given** the README feature list, **When** compared to the codebase, **Then** every major capability (including SPARC decode/convert, PPG phoneme analysis, SpeechBrain SER, plot_aligned_panels, recording widgets) is mentioned or its category is represented.
55+
3. **Given** the tutorials/README.md, **When** compared to actual tutorial files, **Then** all tutorials are listed with correct names and descriptions.
56+
57+
---
58+
59+
### Edge Cases
60+
61+
- What happens if the docs build fails on a PR? (The preview comment should indicate failure, not post a broken link.)
62+
- What happens if a PR has no docs-relevant changes? (Preview should still build — all code has docstrings.)
63+
- What happens if multiple PRs are open simultaneously? (Each gets its own isolated preview URL.)
64+
65+
## Requirements *(mandatory)*
66+
67+
### Functional Requirements
68+
69+
- **FR-001**: The CI system MUST build a docs preview for every non-draft PR and post a comment with the preview URL.
70+
- **FR-002**: The CI system MUST delete the docs preview when the PR is merged or closed.
71+
- **FR-003**: Every module under `audio/tasks/`, `video/tasks/`, `text/tasks/`, and `utils/` MUST have a `doc.md` file with a brief description of the module's purpose and typical use cases.
72+
- **FR-004**: The README.md MUST have consistent documentation links pointing to the canonical docs URL (sensein.github.io/senselab).
73+
- **FR-005**: The tutorials/README.md MUST list all current tutorials with accurate names and descriptions matching the actual notebook files.
74+
- **FR-006**: All new public functions added in recent PRs (SPARC decode/convert, PPG phoneme analysis, SpeechBrain SER, plot_aligned_panels) MUST have complete Google-style docstrings that render correctly in pdoc.
75+
- **FR-007**: The docs preview for a given PR MUST be updated when new commits are pushed to that PR.
76+
77+
## Success Criteria *(mandatory)*
78+
79+
### Measurable Outcomes
80+
81+
- **SC-001**: 100% of open PRs with code changes get a docs preview comment with a working link within the CI run time.
82+
- **SC-002**: 100% of merged/closed PRs have their preview deleted within 5 minutes.
83+
- **SC-003**: 0 modules under the task directories lack a doc.md file.
84+
- **SC-004**: 0 broken links in README.md or tutorials/README.md.
85+
- **SC-005**: All 7 missing doc.md files are created with meaningful content (not just placeholders).
86+
87+
## Assumptions
88+
89+
- GitHub Pages is used for docs deployment (already configured on the `docs` branch).
90+
- PR previews can be deployed as subdirectories under the docs branch (e.g., `pr-123/`) or use a separate deployment mechanism (e.g., Netlify, Surge.sh, or GitHub Pages environments).
91+
- pdoc is the documentation generator (already configured with custom theme).
92+
- The docs workflow currently triggers only on releases; the new PR preview workflow triggers on pull_request events.
93+
- Preview cleanup triggers on pull_request closed event (covers both merged and abandoned PRs).

0 commit comments

Comments
 (0)