Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/actions/validate-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Validate docs
description: Run documentation and browser checks on the checked-out revision.
inputs:
fern-token:
description: Fern token for authenticated checks, when available.
required: false

runs:
using: composite
steps:
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
cache-dependency-path: |
package-lock.json
tests/browser/package-lock.json

- name: Install dependencies
shell: bash
run: npm ci

- name: Validate documentation
shell: bash
run: npm run check
env:
FERN_TOKEN: ${{ inputs.fern-token }}

- name: Install browser regression dependencies
shell: bash
run: npm ci --prefix tests/browser --ignore-scripts

- name: Install regression browsers
shell: bash
working-directory: tests/browser
# CI launches Chromium headlessly without a channel. WebKit is still installed.
run: npm run install:browsers -- --with-deps --only-shell

- name: Verify browser interactions
shell: bash
run: npm run browser:check
28 changes: 3 additions & 25 deletions .github/workflows/docs-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,7 @@ jobs:
- name: Check out repository
uses: actions/checkout@v5

- name: Set up Node.js
uses: actions/setup-node@v6
- name: Validate docs and browser interactions
uses: ./.github/actions/validate-docs
with:
node-version: 22
cache: npm
cache-dependency-path: |
package-lock.json
tests/browser/package-lock.json

- name: Install dependencies
run: npm ci

- name: Validate documentation
run: npm run check
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}

- name: Install browser regression dependencies
run: npm ci --prefix tests/browser --ignore-scripts

- name: Install regression browsers
working-directory: tests/browser
run: npm run install:browsers -- --with-deps

- name: Verify browser interactions
run: npm run browser:check
fern-token: ${{ secrets.FERN_TOKEN }}
28 changes: 3 additions & 25 deletions .github/workflows/docs-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,10 @@ jobs:
- name: Check out repository
uses: actions/checkout@v5

- name: Set up Node.js
uses: actions/setup-node@v6
- name: Validate docs and browser interactions
uses: ./.github/actions/validate-docs
with:
node-version: 22
cache: npm
cache-dependency-path: |
package-lock.json
tests/browser/package-lock.json

- name: Install dependencies
run: npm ci

- name: Validate documentation
run: npm run check
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}

- name: Install browser regression dependencies
run: npm ci --prefix tests/browser --ignore-scripts

- name: Install regression browsers
working-directory: tests/browser
run: npm run install:browsers -- --with-deps

- name: Verify browser interactions
run: npm run browser:check
fern-token: ${{ secrets.FERN_TOKEN }}

# Both gates above must pass; avoid repeating the local prepublish hook.
- name: Publish to Fern production
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ Documentation source files live under:
- `fern/docs.yml` for English navigation, tabs, redirects, and site configuration
- `fern/translations/<locale>/` for locales handled by Fern's native localization

List every English source page in `fern/docs.yml` navigation. Generation and
validation use that list directly when pages are added or retired.

English is the source of truth. If an English page changes, regenerate the affected
locales with `npm run translations:generate -- --locales=<locale>`. For a deliberate
manual translation, refresh its source hash with
`npm run translations:refresh-manifest -- --locales=<locale>`.

Incremental generation reuses an existing navigation overlay once its English
navigation has been cached. Review navigation changes when the English tabs or
sidebar change, or run `npm run translations:generate -- --labels-only --locales=<locale>`
to regenerate navigation labels explicitly.

After translation generation, run `npm run translations:polish`. The repository
checks verify all 20 public locales, canonical URLs, internal links, code
samples, and locale configuration.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ The public Trading Widget `v1` runtime was checked at version `1.8.0` on

English and Simplified Chinese are reviewed together. The other 18 locales use
machine-assisted translation with code, links, identifiers and structure checks;
these checks do not substitute for native-language editorial review. The current
navigation has 158 unique pages per locale.
these checks do not substitute for native-language editorial review. The English
navigation defines the page list for all locales.

## Local Development

Expand Down Expand Up @@ -160,9 +160,9 @@ On Linux, append `-- --with-deps` to the browser installation command to install
the required system packages. See [Playwright's CI setup](https://playwright.dev/docs/ci).
The regular `npm run check` remains available without downloading browsers.
The **Docs checks** workflow runs both documentation and browser checks for pull
requests and pushes to `main`, using the same Node.js version and browser commands
as the publication workflow. Documentation checks run first so a failure stops
the job before browser installation.
requests and pushes to `main`. It shares the [validation action](.github/actions/validate-docs/action.yml)
with the publication workflow. Documentation checks run first so a failure stops
the job before browser installation. CI installs Chromium Headless Shell and WebKit.

## Customer support integration

Expand Down
28 changes: 19 additions & 9 deletions fern/card-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
var languageGroups = ".sixmm-language-menu-enhanced .fern-language-selector-radio-group, .sixmm-mobile-language-dialog-options";
var groupSelector = ".fern-card-group, .sixmm-stat-grid, .fern-layout-footer .fern-footer-nav, " + languageGroups;
var cardSelector = ".fern-card, .sixmm-stat-grid > div";
var footerCardSelector = ".fern-layout-footer .fern-footer-nav > a";
var languageOptionSelector = ".sixmm-language-menu-enhanced .fern-language-dropdown-item, .sixmm-mobile-language-dialog-option";
// Native menus acquire their enhanced class in the language script's next
// frame, so discover their insertion before that class is present as well.
var addedTargetSelector = "article .fern-card, article .sixmm-stat-grid > div, " + footerCardSelector + ", " + languageOptionSelector + ", .fern-language-dropdown-content";
var registeredTargetSelector = ".sixmm-content-card, .sixmm-language-option-effect";
var groups = new Map();
var hover = window.matchMedia("(hover: hover) and (pointer: fine)");
var reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
Expand Down Expand Up @@ -62,10 +68,8 @@
});
});
// Only the footer's page-switching cards opt in; feedback and edit controls do not.
document.querySelectorAll(".fern-layout-footer .fern-footer-nav > a").forEach(register);
document.querySelectorAll(
".sixmm-language-menu-enhanced .fern-language-dropdown-item, .sixmm-mobile-language-dialog-option"
).forEach(function (option) { register(option, "sixmm-language-option-effect"); });
document.querySelectorAll(footerCardSelector).forEach(register);
document.querySelectorAll(languageOptionSelector).forEach(function (option) { register(option, "sixmm-language-option-effect"); });
groups.forEach(function (cards) {
// Compact private group lists without allocating replacements on every scan.
var count = 0;
Expand Down Expand Up @@ -109,7 +113,7 @@
function move(event) {
if (!enabled() || event.pointerType === "touch") { reset(); return; }
var target = event.target instanceof Element ? event.target : null;
var card = target && target.closest(".sixmm-content-card, .sixmm-language-option-effect");
var card = target && target.closest(registeredTargetSelector);
var group = target && (target.closest(groupSelector) || card);
if (!group || !groups.has(group)) { reset(); return; }
if (activeGroup !== group) { reset(); activeGroup = group; }
Expand All @@ -124,17 +128,23 @@
if (!frame) frame = requestAnimationFrame(render);
}

function containsElement(nodes) {
return Array.prototype.some.call(nodes, function (node) { return node.nodeType === 1; });
function containsTarget(nodes, selector) {
return Array.prototype.some.call(nodes, function (node) {
return node.nodeType === 1 && (node.matches(selector) || node.querySelector(selector));
});
}

function observeBody() {
if (observedBody === document.body) return;
if (bodyObserver) bodyObserver.disconnect();
else bodyObserver = new MutationObserver(function (records) {
// Text and comment changes cannot add or remove card targets.
// Search results, support messages and ordinary article markup do not
// change effect targets. Inspect only changed subtrees before scheduling
// a full scan. Removed targets retain their effect class even after losing
// the article/group ancestors needed by the discovery selectors.
if (records.some(function (record) {
return containsElement(record.addedNodes) || containsElement(record.removedNodes);
return containsTarget(record.addedNodes, addedTargetSelector) ||
containsTarget(record.removedNodes, registeredTargetSelector);
})) {
scheduleScan();
}
Expand Down
19 changes: 12 additions & 7 deletions fern/docs-interface.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion fern/language-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,29 @@
window.requestAnimationFrame(syncInterface);
}

function tuneStaticSidebarPrefetch(root) {
var sidebar = root && root.getElementById && root.getElementById("fern-sidebar-static");
if (!sidebar) return;
sidebar.querySelectorAll('a[data-astro-prefetch="viewport"], a[data-astro-prefetch="load"]').forEach(function (link) {
// Fern scans the static sidebar before the afterInteractive script runs.
// Leave React-owned links to the existing post-hydration bridge.
if (!link.closest("astro-island")) link.setAttribute("data-astro-prefetch", "hover");
});
}

// This script loads before interactive content. Set the pathname-derived
// locale immediately so standalone navigation tabs never flash on first paint.
syncLocaleTabs(currentRoute());
document.addEventListener("DOMContentLoaded", scheduleSync);
var parsingSidebar = document.readyState === "loading";
tuneStaticSidebarPrefetch(document);
document.addEventListener("DOMContentLoaded", function () {
parsingSidebar = false;
tuneStaticSidebarPrefetch(document);
scheduleSync();
});
document.addEventListener("astro:before-swap", function (event) {
tuneStaticSidebarPrefetch(event.newDocument);
});
document.addEventListener("fern:island-hydrated", scheduleSync);
document.addEventListener("astro:page-load", scheduleSync);
window.addEventListener("pageshow", function () {
Expand All @@ -685,6 +704,7 @@
if (!isMobileViewport()) closeMobileLocaleDialog(false);
});
new MutationObserver(function (records) {
if (parsingSidebar) tuneStaticSidebarPrefetch(document);
var controls = '.fern-language-selector, .fern-language-dropdown-content, .sixmm-theme-trigger, .fern-header-mobile-menu-button';
if (records.some(function (record) {
var target = record.target.nodeType === 1 ? record.target : record.target.parentElement;
Expand Down
Loading
Loading