Skip to content

Documentation Publishing

Foundry documentation is built with MkDocs and published to a dedicated Cloudflare Pages project. The public URL is routed through the existing Dev Leader project-documentation Worker:

https://www.devleader.ca/projects/foundry/
        -> Cloudflare Worker
        -> https://nexuslabs-foundry.pages.dev/

No Cloudflare custom domain is required for the Pages project. The Worker owns the public path on www.devleader.ca.

Layout checks and review screenshots

The hosted Documentation workflow checks the actual built homepage at 375px and 1440px in both themes before its API build. It holds image responses, compares geometry before and after release, and requires separate 44px footer targets with 4px gaps. Regression checks use deliberately wide synthetic badges rather than depending on external badge services.

Manual feature-branch runs additionally capture real-image homepage loading states and footer screenshots for human review. Screenshots are evidence, never screenshot assertions or pixel-comparison baselines. The documentation-layout artifact retains bounded JSON and PNG evidence for one day, capped at 20 MiB per run; ordinary regression evidence is much smaller. Feature-branch runs do not merge or deploy published documentation.

Versioned API documentation

Foundry preserves the same API-documentation model as Needlr:

  • pushes to main regenerate /api/dev/;
  • releases generate immutable /api/v<version>/ archives and refresh /api/stable/;
  • gh-pages acts as the merge store so development and release workflows own separate URL slices without overwriting each other;
  • the API version switcher reads /api/versions.json;
  • Cloudflare receives a trimmed mirror containing main, development, stable, and the newest version archives.

Historical archives remain in gh-pages history even after older versions are trimmed from the Cloudflare deployment.

The Documentation and Release workflows only merge their owned slices into gh-pages. A separate Documentation Deployment workflow checks out the latest merged branch, trims old archives, and deploys that complete snapshot to Cloudflare. This latest-snapshot deployment prevents concurrent main and release builds from publishing partial or stale trees.

Documentation title maintenance

API browser, Open Graph, and Twitter titles include the project/namespace, type where applicable, and development, stable, or archived version context. The title hook changes only template metadata; page headings, navigation, canonical URLs, and API content remain unchanged. Guide and analyzer overview pages also receive distinct metadata titles.

Automatic documentation descriptions

The metadata hook preserves explicit nonempty descriptions. Otherwise it uses the qualified API identity and XML-backed introduction, or the guide title and first prose paragraph. Notes, code, navigation, tables, and member details are not introductions. Missing prose produces an identity-only fallback; the home page retains its existing override or configured project description.

Maintain ordinary XML API summaries and guide introductions rather than writing bespoke metadata. Generated summaries are shortened at word boundaries. Source metadata stays plain text, with escaping applied only when rendering HTML and social tags; structured data uses safe JSON serialization.

This policy applies to newly built pages. Existing stable and archived output is not backfilled. The title-only maintenance script continues to leave descriptions and all content untouched.

API structured data

Newly built API pages emit one APIReference entity using the same qualified title and XML-derived description as their page metadata. Its @id and url match the public canonical URL: slashless, with each path segment URI-escaped once. Existing stable and archived snapshots are not rewritten. Guide schemas and the home-page project entity retain their existing behavior.

Published title refresh

The Documentation titles workflow validates rendered fixtures, demonstrates that generic baseline metadata fails those assertions, and previews every stable/archive HTML page and the API, guide, and analyzer overviews in the complete current gh-pages snapshot without writing it. The preview receipt includes page hashes and per-version counts.

After merging a title correction, explicitly dispatch Documentation titles from main with refresh_published_titles=true to update existing stable and archived and overview metadata without rebuilding historical APIs. Every page is validated before any write. Only the browser, Open Graph, and Twitter title values change; a second preview must report zero changes. Attempt-specific receipts are retained for one day. A normal non-force push rejects concurrent changes to gh-pages.

Development publication, release publication, title maintenance, and Cloudflare deployment share a non-cancelling publication lock. Maintenance updates the merge store; explicitly dispatch Documentation Deployment after successful maintenance to update the canonical mirror. Read-only title previews never deploy. The existing deployment workflow remains the sole Cloudflare publisher and retains its deployment enablement gate and newest 20-version mirror limit. No package or release publication is involved.

Safe-by-default deployment

The Documentation workflow always builds and uploads the generated site as a GitHub Actions artifact. Deployment remains disabled until the repository variable DOCS_DEPLOY_ENABLED is set to true.

This allows documentation changes to merge before Cloudflare credentials or routing are configured without breaking CI or creating public infrastructure.

One-time Cloudflare setup

These steps require explicit approval because they create public infrastructure:

  1. Create the Pages project:
npx wrangler pages project create nexuslabs-foundry --production-branch main
  1. Create a protected GitHub environment named documentation and add these environment secrets:

  2. CLOUDFLARE_API_TOKEN

  3. CLOUDFLARE_ACCOUNT_ID

  4. Set the repository variable:

DOCS_DEPLOY_ENABLED=true
  1. Run the Documentation workflow from main with deploy=true, or merge a subsequent documentation change to main.

Dev Leader routing

The public path requires changes in ncosentino/devleader-blog:

  1. Add "foundry": "nexuslabs-foundry.pages.dev" to the project router's PROJECT_MAP.
  2. Deploy the devleader-router Worker.
  3. Add Foundry to the /projects catalog and FAQ.
  4. Add https://www.devleader.ca/projects/foundry/sitemap.xml to robots.txt.
  5. Extend the project-page, robots, and live documentation tests.

Adding Foundry to ncosentino/homebase is optional. It only controls whether Foundry appears on links.devleader.ca; it is not involved in documentation routing.

Verification

Verify each layer in order:

  1. python -m mkdocs build --strict
  2. https://nexuslabs-foundry.pages.dev/
  3. https://www.devleader.ca/projects/foundry/
  4. https://www.devleader.ca/projects/foundry/sitemap.xml
  5. https://www.devleader.ca/projects/foundry/llms.txt

The public route should preserve canonical URLs, social metadata, sitemap locations, and internal links under /projects/foundry.