diff --git a/Makefile b/Makefile index 052e5638d..e83917146 100644 --- a/Makefile +++ b/Makefile @@ -472,6 +472,8 @@ DOCS_PYTHON ?= .venv/bin/python DOCS_JUPYTEXT ?= .venv/bin/jupytext FERN_VERSION ?= $(shell jq -r .version fern/fern.config.json) FERN ?= npx -y fern-api@$(FERN_VERSION) +FERN_ORG ?= $(shell jq -r .organization fern/fern.config.json) +FERN_GLOBAL_THEME ?= $(shell awk '/^global-theme:/ { print $$2; exit }' fern/docs.yml) # Route urllib/requests/httpx through certifi's CA bundle. Necessary when uv # resolves $(DOCS_PYTHON_VERSION) to a python.org installer build, which ships without @@ -506,10 +508,34 @@ check-fern-docs-locally: @$(MAKE) check-fern-docs @echo "✅ Fern docs check complete" +check-fern-theme-access: + @if [ -n "$(FERN_GLOBAL_THEME)" ]; then \ + cd fern && $(FERN) docs theme list --org $(FERN_ORG) --json >/dev/null || { \ + echo ""; \ + echo "Unable to access Fern global theme '$(FERN_GLOBAL_THEME)' for org '$(FERN_ORG)'."; \ + echo "Fix: sign in to https://dashboard.buildwithfern.com, then run:"; \ + echo " cd fern && $(FERN) login"; \ + echo "If it still fails, export a privileged DOCS_FERN_TOKEN as FERN_TOKEN."; \ + exit 1; \ + }; \ + fi + serve-fern-docs-locally: @$(MAKE) install-docs-deps @$(MAKE) prepare-fern-docs - cd fern && PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true $(FERN) docs dev + @$(MAKE) serve-fern-docs-dev + +serve-fern-docs-dev: + @if $(MAKE) check-fern-theme-access >/dev/null 2>&1; then \ + cd fern && PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true $(FERN) docs dev; \ + else \ + echo "Unable to access Fern global theme '$(FERN_GLOBAL_THEME)' for org '$(FERN_ORG)'."; \ + echo "Serving with the local NVIDIA-style fallback. Run 'make check-fern-theme-access' for auth details."; \ + $(MAKE) serve-fern-docs-local-theme; \ + fi + +serve-fern-docs-local-theme: + @PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true $(DOCS_PYTHON) fern/scripts/serve-local-docs-preview.py --root fern -- $(FERN) docs dev convert-execute-notebooks: ifeq ($(USE_CACHE),1) @@ -720,7 +746,7 @@ clean-test-coverage: .PHONY: bench-cli-startup bench-cli-startup-verbose \ build build-config build-engine build-interface \ check-all check-all-fix check-config check-engine check-interface \ - check-fern-docs check-fern-docs-locally check-fern-release-version check-license-headers \ + check-fern-docs check-fern-docs-locally check-fern-release-version check-fern-theme-access check-license-headers \ clean clean-dist clean-notebooks clean-pycache clean-test-coverage \ convert-execute-notebooks \ coverage coverage-config coverage-engine coverage-interface \ @@ -729,7 +755,7 @@ clean-test-coverage: generate-colab-notebooks generate-fern-notebooks generate-fern-notebooks-with-outputs help \ install install-dev install-dev-notebooks install-dev-recipes install-docs-deps \ lint lint-config lint-engine lint-fix lint-fix-config lint-fix-engine lint-fix-interface lint-interface \ - perf-import perf-import-runtime prepare-fern-docs prepare-fern-release publish serve-fern-docs-locally show-versions \ + perf-import perf-import-runtime prepare-fern-docs prepare-fern-release publish serve-fern-docs-dev serve-fern-docs-local-theme serve-fern-docs-locally show-versions \ health-checks \ test test-config test-config-isolated test-e2e test-engine test-engine-isolated \ test-interface test-interface-isolated test-isolated \ diff --git a/fern/README.md b/fern/README.md index f7f5ffdc7..ef0abd74c 100644 --- a/fern/README.md +++ b/fern/README.md @@ -43,6 +43,7 @@ make serve-fern-docs-locally ``` `serve-fern-docs-locally` generates notebook artifacts before starting `fern docs dev`. It does not publish. +It uses the real NVIDIA global theme when Fern auth can access it. Without that access, it serves from a temporary local preview config with a close NVIDIA-style fallback. ## CI and publishing @@ -146,6 +147,10 @@ render-time guard (`document.getElementById`, a module flag) would risk an SSR hydration mismatch. If per-instance duplication ever matters, revisit once Fern supports React's `