This repository hosts the unified TypeDoc reference documentation for Sanity JavaScript libraries. It provides a consistent, searchable interface for developers to access API documentation across all Sanity packages.
- Unified Documentation: Single source of truth for all Sanity JavaScript API references
- TypeScript-Powered: Leverages TypeDoc to generate accurate, type-based documentation
- Versioned Documentation: Access documentation for specific package versions
- Cross-Referenced: Navigate between related libraries and functions
- Searchable: Full-text search across all API documentation
This reference site automatically receives documentation updates through a GitHub Action workflow when new package versions are released. The process works as follows:
- TypeDoc generates JSON output from library source code
- A GitHub Action uploads this structured data to Sanity's content platform
- This reference site renders the documentation in a user-friendly format
To add your library to this reference documentation site:
- Add TypeDoc to your project:
npm install --save-dev typedoc
- Add a documentation build script to your package.json:
"scripts": { "docs": "typedoc --json docs/typedoc.json" }
Warning
You might have to add --tsconfig /path/to/tsconfig.json
for monorepo projects.
- Add the upload GitHub Action to your workflow:
name: Upload Docs
on:
# Build on pushes to the main branch
push:
branches:
- main
# Or when a new release is published
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm' # or 'pnpm' or 'yarn'
- name: Install dependencies
run: npm ci # or pnpm install or yarn install
- name: Build Docs
run: npm run docs
- name: Upload Docs
uses: sanity-io/reference-api-typedoc/.github/actions/typedoc-upload@latest
with:
packageName: "Your npm package name" # for example: @sanity/client
version: "${{ github.event.release.tag_name || '0.0.0' }}" # make sure it's the "next" and not current version being published
typedocJsonPath: "docs/typedoc.json"
env:
SANITY_DOCS_API_TOKEN: ${{ secrets.SANITY_DOCS_API_TOKEN }} # this will be available org wide
- Ensure your code is properly documented using TS/JSDoc comments
For optimal API reference documentation, include the following for all public API surfaces:
- Status indicators (
@public
,@beta
,@internal
) - Clear titles and descriptions
- Parameter documentation (name, type, purpose)
- Return value documentation
- Practical examples
- When possible, include
@throws
,@remarks
, and@see/@link
references
Contributions to improve this reference documentation system are welcome. Please see our contributing guidelines for more information.
This project is licensed under the MIT License.