Skip to content

Commit f92923e

Browse files
authored
docs(fern): finalize preview workflow and nav cleanup (#784)
1 parent ddb85b1 commit f92923e

40 files changed

+538
-232
lines changed

.agents/skills/update-docs/SKILL.md

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Scan recent git history for commits that affect user-facing behavior and draft d
1010
## Prerequisites
1111

1212
- You must be in the OpenShell git repository.
13-
- The `docs/` directory must exist with the current doc set.
14-
- Read `docs/CONTRIBUTING.md` before writing any content. It contains the style guide and formatting rules.
13+
- The published docs tree must exist under `fern/pages/`.
14+
- Read `fern/pages/CONTRIBUTING.mdx` before writing any content. It contains the current style guide and formatting rules.
1515

1616
## When to Use
1717

@@ -48,16 +48,16 @@ For each relevant commit, determine which doc page(s) it affects. Use this mappi
4848

4949
| Code area | Likely doc page(s) |
5050
|---|---|
51-
| `crates/openshell-cli/` (gateway commands) | `docs/sandboxes/manage-gateways.md` |
52-
| `crates/openshell-cli/` (sandbox commands) | `docs/sandboxes/manage-sandboxes.md` |
53-
| `crates/openshell-cli/` (provider commands) | `docs/sandboxes/manage-providers.md` |
54-
| `crates/openshell-cli/` (new top-level command) | May need a new page or `docs/reference/` entry |
55-
| `crates/openshell-proxy/` or policy code | `docs/sandboxes/policies.md`, `docs/reference/policy-schema.md` |
56-
| `crates/openshell-inference/` | `docs/inference/configure.md` |
57-
| `python/` (SDK changes) | `docs/reference/` or `docs/get-started/quickstart.md` |
58-
| `proto/` (API changes) | `docs/reference/` |
59-
| `deploy/` (Dockerfile, Helm) | `docs/sandboxes/manage-gateways.md`, `docs/about/architecture.md` |
60-
| Community sandbox definitions | `docs/sandboxes/community-sandboxes.md` |
51+
| `crates/openshell-cli/` (gateway commands) | `fern/pages/sandboxes/manage-gateways.mdx` |
52+
| `crates/openshell-cli/` (sandbox commands) | `fern/pages/sandboxes/manage-sandboxes.mdx` |
53+
| `crates/openshell-cli/` (provider commands) | `fern/pages/sandboxes/manage-providers.mdx` |
54+
| `crates/openshell-cli/` (new top-level command) | May need a new page or `fern/pages/reference/` entry |
55+
| Proxy or policy code | `fern/pages/sandboxes/policies.mdx`, `fern/pages/reference/policy-schema.mdx` |
56+
| Inference code | `fern/pages/inference/configure.mdx` |
57+
| `python/` (SDK changes) | `fern/pages/reference/` or `fern/pages/get-started/quickstart.mdx` |
58+
| `proto/` (API changes) | `fern/pages/reference/` |
59+
| `deploy/` (Dockerfile, Helm) | `fern/pages/sandboxes/manage-gateways.mdx`, `fern/pages/about/architecture.mdx` |
60+
| Community sandbox definitions | `fern/pages/sandboxes/community-sandboxes.mdx` |
6161

6262
If a commit does not map to any existing page but introduces a user-visible concept, flag it as needing a new page.
6363

@@ -88,16 +88,22 @@ Identify where the new content should go. Follow the page's existing structure.
8888

8989
## Step 5: Draft the Update
9090

91-
Write the doc update following the rules in `docs/CONTRIBUTING.md`. Key reminders:
91+
Write the doc update following the rules in `fern/pages/CONTRIBUTING.mdx`. Key reminders:
9292

9393
- **Active voice, present tense, second person.**
9494
- **No unnecessary bold.** Reserve bold for UI labels and parameter names.
9595
- **No em dashes** unless used sparingly. Prefer commas or separate sentences.
9696
- **Start sections with an introductory sentence** that orients the reader.
9797
- **No superlatives.** Say what the feature does, not how great it is.
98-
- **Code examples use `console` language** with `$` prompt prefix.
98+
- **Code examples use `shell` language** for copyable commands, with no `$` prompt prefix.
99+
- **Use `text` fences** for transcripts, logs, or shell sessions that should not be copied verbatim.
99100
- **Include the SPDX header** if creating a new page.
100-
- **Match existing frontmatter format** if creating a new page.
101+
- **Match existing Fern frontmatter format** if creating a new page, including `sidebar-title`, `keywords`, `tags`, and `position` when they are relevant. Use frontmatter `slug` only for folder-discovered pages or absolute URL overrides.
102+
- **Use `sidebar-title` for short nav labels**. For explicit navbar entries, keep relative `slug` values in `fern/versions/latest.yml` instead of page frontmatter.
103+
- **Keep explicit `page:` entries in `fern/versions/latest.yml`**. Fern still requires them. If the page defines `sidebar-title`, set `page:` to that value. Otherwise set `page:` to the page frontmatter `title`.
104+
- **Use `skip-slug: true` in `fern/versions/latest.yml`** when a child page should live at the parent section path.
105+
- **Use `keywords` as a comma-separated string**. When migrating a page from `docs/`, combine the legacy `topics` and `tags` into `keywords` and preserve the legacy `tags` array when it is still useful.
106+
- **Do not add a duplicate H1**. Fern renders the page title from frontmatter.
101107
- **Always write NVIDIA in all caps.** Wrong: Nvidia, nvidia.
102108
- **Always capitalize OpenShell correctly.** Wrong: openshell, Openshell, openShell.
103109
- **Do not number section titles.** Wrong: "Section 1: Deploy a Gateway" or "Step 3: Verify." Use plain descriptive titles.
@@ -112,8 +118,8 @@ When updating an existing page:
112118

113119
When creating a new page:
114120

115-
- Follow the frontmatter template from `docs/CONTRIBUTING.md`.
116-
- Add the page to the appropriate `toctree` in `docs/index.md`.
121+
- Follow the frontmatter template from `fern/pages/CONTRIBUTING.mdx`.
122+
- Add the page to the appropriate section in `fern/versions/latest.yml`.
117123

118124
## Step 6: Present the Results
119125

@@ -123,8 +129,8 @@ After drafting all updates, present a summary to the user:
123129
## Doc Updates from Commits
124130
125131
### Updated pages
126-
- `docs/sandboxes/manage-gateways.md`: Added `--gpu` flag documentation (from commit abc1234).
127-
- `docs/reference/policy-schema.md`: Updated network policy schema for new `tls_inspect` field (from commit def5678).
132+
- `fern/pages/sandboxes/manage-gateways.mdx`: Added `--gpu` flag documentation (from commit abc1234).
133+
- `fern/pages/reference/policy-schema.mdx`: Updated network policy schema for new `tls_inspect` field (from commit def5678).
128134
129135
### New pages needed
130136
- None (or list any new pages created).
@@ -136,23 +142,29 @@ After drafting all updates, present a summary to the user:
136142

137143
## Step 7: Build and Verify
138144

139-
After making changes, build the docs locally:
145+
After making changes, validate the Fern docs locally:
140146

141147
```bash
142-
mise run docs
148+
fern check
149+
```
150+
151+
If a human needs to inspect rendering while iterating, they can also run:
152+
153+
```bash
154+
fern docs dev
143155
```
144156

145157
Check for:
146158

147-
- Build warnings or errors.
159+
- Validation warnings or errors.
148160
- Broken cross-references.
149-
- Correct rendering of new content.
161+
- Correct rendering of new content in the PR preview when available.
150162

151163
## Tips
152164

153165
- When in doubt about whether a commit needs a doc update, check if the commit message references a CLI flag, config option, or user-visible behavior.
154166
- Group related commits that touch the same doc page into a single update rather than making multiple small edits.
155-
- If a commit is a breaking change, add a note at the top of the relevant section using a `:::{warning}` admonition.
167+
- If a commit is a breaking change, add a note at the top of the relevant section using a Fern `<Warning>` callout.
156168
- PRs that are purely internal refactors with no behavior change do not need doc updates, even if they touch high-signal directories.
157169

158170
## Example Usage
@@ -165,4 +177,4 @@ User says: "Catch up the docs for everything merged since v0.2.0."
165177
4. Read the commit diffs and current doc pages.
166178
5. Draft updates following the style guide.
167179
6. Present the summary.
168-
7. Build with `mise run docs` to verify.
180+
7. Run `fern check` to verify.

.github/workflows/branch-docs.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Branch Docs Preview
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "fern/**"
7+
- ".github/workflows/branch-docs.yml"
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
jobs:
14+
preview:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Check Fern preview availability
21+
id: fern-preview
22+
env:
23+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
24+
run: |
25+
if [ -n "$FERN_TOKEN" ]; then
26+
echo "enabled=true" >> "$GITHUB_OUTPUT"
27+
else
28+
echo "enabled=false" >> "$GITHUB_OUTPUT"
29+
echo "::notice::Skipping Fern docs preview because FERN_TOKEN is unavailable. This is expected for fork PRs and repos without Fern preview credentials configured."
30+
fi
31+
32+
- name: Setup Node.js
33+
if: ${{ steps.fern-preview.outputs.enabled == 'true' }}
34+
uses: actions/setup-node@v6
35+
with:
36+
node-version: "24"
37+
38+
- name: Install Fern CLI
39+
if: ${{ steps.fern-preview.outputs.enabled == 'true' }}
40+
run: npm install -g fern-api
41+
42+
- name: Generate preview URL
43+
if: ${{ steps.fern-preview.outputs.enabled == 'true' }}
44+
id: generate-docs
45+
env:
46+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
47+
PREVIEW_ID: pr-${{ github.event.pull_request.number }}
48+
working-directory: ./fern
49+
run: |
50+
OUTPUT=$(fern generate --docs --preview --id "$PREVIEW_ID" 2>&1)
51+
echo "$OUTPUT"
52+
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')
53+
if [ -z "$URL" ]; then
54+
echo "::error::Failed to generate preview URL. See fern output above."
55+
exit 1
56+
fi
57+
echo "preview_url=$URL" >> "$GITHUB_OUTPUT"
58+
59+
- name: Post or update PR comment
60+
if: ${{ steps.fern-preview.outputs.enabled == 'true' }}
61+
env:
62+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
PR_NUMBER: ${{ github.event.pull_request.number }}
64+
PREVIEW_URL: ${{ steps.generate-docs.outputs.preview_url }}
65+
run: |
66+
BODY=":herb: **Preview your docs:** <${PREVIEW_URL}>"
67+
MARKER="<!-- preview-docs -->"
68+
BODY="${BODY}
69+
70+
${MARKER}"
71+
72+
COMMENT_ID=$(gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" \
73+
--jq ".[] | select(.body | contains(\"${MARKER}\")) | .id" | head -1)
74+
75+
if [ -n "$COMMENT_ID" ]; then
76+
gh api "repos/${{ github.repository }}/issues/comments/${COMMENT_ID}" \
77+
-X PATCH -f body="$BODY"
78+
else
79+
gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" \
80+
-f body="$BODY"
81+
fi

.github/workflows/release-tag.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,30 @@ jobs:
383383
release/*.whl
384384
release/openshell-checksums-sha256.txt
385385
386+
publish-fern-docs:
387+
name: Publish Fern Docs
388+
needs: [release]
389+
runs-on: ubuntu-latest
390+
timeout-minutes: 15
391+
steps:
392+
- uses: actions/checkout@v4
393+
with:
394+
ref: ${{ inputs.tag || github.ref }}
395+
396+
- name: Setup Node.js
397+
uses: actions/setup-node@v6
398+
with:
399+
node-version: "24"
400+
401+
- name: Install Fern CLI
402+
run: npm install -g fern-api
403+
404+
- name: Publish Fern docs
405+
env:
406+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
407+
working-directory: ./fern
408+
run: fern generate --docs
409+
386410
trigger-wheel-publish:
387411
name: Trigger Wheel Publish
388412
needs: [compute-versions, build-python-wheels, release]

AGENTS.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ These pipelines connect skills into end-to-end workflows. Individual skill files
4343
| `python/openshell/` | Python SDK | Python bindings and CLI packaging |
4444
| `proto/` | Protobuf definitions | gRPC service contracts |
4545
| `deploy/` | Docker, Helm, K8s | Dockerfiles, Helm chart, manifests |
46+
| `fern/` | Published docs | Fern site config, navigation, components, and MDX pages |
47+
| `docs/` | Legacy docs source | Sphinx/MyST source retained for migration, comparison, and legacy build tasks |
4648
| `.agents/skills/` | Agent skills | Workflow automation for development |
4749
| `.agents/agents/` | Agent personas | Sub-agent definitions (e.g., reviewer, doc writer) |
4850
| `architecture/` | Architecture docs | Design decisions and component documentation |
@@ -185,8 +187,10 @@ ocsf_emit!(event);
185187
## Documentation
186188

187189
- When making changes, update the relevant documentation in the `architecture/` directory.
188-
- When changes affect user-facing behavior, also update the relevant pages under `docs/`.
189-
- Follow the style guide in [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md): active voice, no unnecessary bold, no em dash overuse, no filler introductions.
190+
- When changes affect user-facing behavior, update the relevant published docs pages under `fern/pages/` and navigation in `fern/versions/latest.yml`.
191+
- `docs/` is retained for legacy Sphinx build tasks and migration/reference work. Do not update it unless the user explicitly asks.
192+
- Follow the docs style guide in [fern/pages/CONTRIBUTING.mdx](fern/pages/CONTRIBUTING.mdx): active voice, minimal formatting, no filler introductions, `shell` fences for copyable commands, and no duplicate body H1.
193+
- Fern PR previews run through `.github/workflows/branch-docs.yml`, and production publish runs through the `publish-fern-docs` job in `.github/workflows/release-tag.yml`.
190194
- Use the `update-docs` skill to scan recent commits and draft doc updates.
191195

192196
## Security

CONTRIBUTING.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ These are the primary `mise` tasks for day-to-day development:
173173
| `mise run test` | Default test suite |
174174
| `mise run e2e` | Default end-to-end test lane |
175175
| `mise run ci` | Full local CI checks (lint, compile/type checks, tests) |
176-
| `mise run docs` | Build and serve documentation locally |
176+
| `mise run docs` | Build legacy Sphinx docs locally |
177177
| `mise run clean` | Clean build artifacts |
178178

179179
## Project Structure
@@ -185,9 +185,10 @@ These are the primary `mise` tasks for day-to-day development:
185185
| `proto/` | Protocol buffer definitions |
186186
| `tasks/` | `mise` task definitions and build scripts |
187187
| `deploy/` | Dockerfiles, Helm chart, Kubernetes manifests |
188+
| `fern/` | Published Fern docs site and MDX pages |
189+
| `docs/` | Legacy Sphinx/MyST docs retained during transition |
188190
| `architecture/` | Architecture docs and plans |
189191
| `rfc/` | Request for Comments proposals |
190-
| `docs/` | User-facing documentation (Sphinx/MyST) |
191192
| `.agents/` | Agent skills and persona definitions |
192193

193194
## RFCs
@@ -196,19 +197,30 @@ For cross-cutting architectural decisions, API contract changes, or process prop
196197

197198
## Documentation
198199

199-
If your change affects user-facing behavior (new flags, changed defaults, new features, bug fixes that contradict existing docs), update the relevant pages under `docs/` in the same PR.
200+
If your change affects user-facing behavior (new flags, changed defaults, new features, bug fixes that contradict existing docs), update the relevant pages under `fern/pages/` in the same PR and adjust `fern/versions/latest.yml` if navigation changes. For explicit navbar entries, keep `page:` aligned with `sidebar-title` when present and put relative `slug:` values in `fern/versions/latest.yml`. Reserve frontmatter `slug` for folder-discovered pages or absolute URL overrides.
200201

201202
To ensure your doc changes follow NVIDIA documentation style, use the `update-docs` skill.
202-
It scans commits, identifies doc pages that need updates, and drafts content that follows the style guide in `docs/CONTRIBUTING.md`.
203+
It scans commits, identifies doc pages that need updates, and drafts content that follows the style guide in `fern/pages/CONTRIBUTING.mdx`.
203204

204-
To build and preview docs locally:
205+
To preview Fern docs locally:
205206

206207
```bash
207-
mise run docs # to build the docs locally
208-
mise run docs:serve # to serve locally and automatically rebuild on changes
208+
fern docs dev
209209
```
210210

211-
See [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md) for more details.
211+
To run non-interactive validation:
212+
213+
```bash
214+
fern check
215+
```
216+
217+
PRs that touch `fern/**` also get a preview from `.github/workflows/branch-docs.yml` when `FERN_TOKEN` is available to the workflow.
218+
219+
Fern docs publishing is handled by the `publish-fern-docs` job in `.github/workflows/release-tag.yml` when a release tag is created.
220+
221+
`docs/` and `mise run docs` / `mise run docs:serve` are still kept for the legacy Sphinx build during the transition, but they are no longer the primary published docs workflow.
222+
223+
See [fern/pages/CONTRIBUTING.mdx](fern/pages/CONTRIBUTING.mdx) for the current docs authoring guide.
212224

213225
## Pull Requests
214226

0 commit comments

Comments
 (0)