Documentation development

The repository has one DocFX site in Docs/. API pages come from the current first-party C# source. Unity, package and vendor assemblies supply references; they are not documentation targets.

Build and preview

Install PowerShell 7.2 or newer and .NET SDKs 8 and 10. The repository pins DocFX in dotnet-tools.json; Build.ps1 restores that tool automatically.

./Docs/Build.ps1
./Docs/Build.ps1 -Serve

The script reports reference restoration, API extraction and HTML generation times separately. To preview an existing build:

dotnet docfx serve Docs/_site

Export Unity compilation inputs

Use a checkout with Unity's dependencies imported, successful script compilation, and freshly regenerated IDE project files. Exporting reads those project files through MSBuild; it does not launch Unity or build the game.

Only first-party IDE projects are required. External packages are referenced through their compiled DLLs in Library/ScriptAssemblies; the exporter reads their CLR dependency metadata without loading package IDE projects. If an explicit project reference has a different filename from its assembly name, its project may still be needed to resolve that name.

./Docs/Export-UnityReferences.ps1

The export creates portable project templates in Docs/Unity/Projects, records compilation inputs in Docs/Unity/compilation.json, and writes Docs/Unity/editor-references.json and Docs/Unity/references.lock.json. Commit these text files together. On each build, the templates are materialized in the ignored cache with the current tracked source membership. Existing assembly assignments come from Unity; additions and moves are resolved using the nearest .asmdef/.asmref and Unity predefined assembly rules.

Stock editor DLLs under Managed are restored separately from the exact Unity version: locally from Unity Hub (or UNITY_EDITOR_DATA), and on CI from a cached UnityCI image using crane to stream the managed files directly from the registry. No full image is downloaded to disk, unpacked into container storage, or run. The editor reference cache is saved before DocFX runs. Tracked plug-in DLLs are referenced in place. The private ZIP contains only the remaining references, including compiled packages and the patched URP.

The external dependency ZIP is written to the ignored path Docs/.cache/unity-references.zip. Open the release URL printed by the exporter, attach that ZIP, and publish the prerelease in this private repository. A draft release is not sufficient for CI. Keep each existing pinned release asset intact. The workflow downloads the exact asset using its own GITHUB_TOKEN and checks the SHA256 in the lock file. No GitHub CLI or additional repository secret is needed. The ZIP is never included in the website.

An existing local ZIP can be used without GitHub authentication. A clean local checkout needs the ZIP from the locked private release placed at that path, or an authorized GITHUB_TOKEN in the build process environment.

Change Export required?
Edit code or XML comments in an included first-party file No
Edit Markdown or site styling No
Add, delete or move first-party C# files within existing exported assemblies No
Add source to an external or previously unexported assembly Yes
Change assembly definitions, references, symbols or compiler settings Yes
Update Unity, a package, a plugin, or the URP patch Yes
Change vendor source compiled into a bundled dependency Yes

The build rejects stale dependency or compiler inputs before generating documentation. Regenerate Unity project files before exporting after a dependency or assembly configuration change. First-party source must be tracked by Git. A new export is not needed for normal source changes in existing assemblies. If a refresh produces the same ZIP SHA256, reuse its existing release; no upload is needed.

Ownership and authoring

Ownership.json controls excluded directories and assemblies. filterConfig.yml excludes engine, vendor and test namespaces from API pages. Compilation can still require vendor source inside a default Unity assembly; excluding its API pages does not remove its types from the compilation.

Follow the documentation guide for source comments, page placement, visualizations, and commit rules. Run Check-DocumentationLayout.ps1 before committing documentation; the documentation workflow runs the same check.

Generated API YAML, HTML, downloaded references and build output are ignored. The site publishes public API members using DocFX's default visibility filter. Each component guide links to a generated API landing page. Its TOC nests DocFX's generated namespace and type TOC. The API Reference tab is a hub for all components that produce API metadata. Use directory references in the root TOC to keep top-level navigation separate from the sidebars.

GitHub Actions and Cloudflare

The workflow uses a GitHub-hosted Ubuntu runner, with .NET Windows targeting enabled for desktop projects. It restores dependencies, builds once and publishes that output to the existing Cloudflare Pages project on main when DOCS_DEPLOY_ENABLED is true.

The documentation environment retains the existing Cloudflare configuration:

  • Secret CLOUDFLARE_API_TOKEN
  • Secret CLOUDFLARE_ACCOUNT_ID
  • Variable CLOUDFLARE_PROJECT_NAME
  • Variable DOCS_DEPLOY_ENABLED

Automatic builds run only for relevant pushes to main. Manual runs on other branches validate documentation without deploying and use the documentation-validation environment. The stock managed editor references and private dependency ZIP are cached separately; API pages are regenerated from the checked-out source on every documentation build.

Cloudflare's Git-connected build should remain disabled when this workflow owns publication. robots.txt and _headers remain part of the generated site.

Script tests

The focused tests exercise export, freshness checks and reference restoration using temporary fixtures. Run them when changing the documentation scripts; normal documentation builds do not run them. They require Git, PowerShell and the .NET 8 SDK.

Get-ChildItem ./Docs/Tests/*.Tests.ps1 | ForEach-Object { & $_.FullName }

These tests do not establish that an exported Dizzy context is complete. The first real export must also pass Build.ps1 from a clean checkout using only the portable projects and dependency ZIP.