Documenting APIs
The Lynx documentation relies on a structured system to ensure API references are accurate and consistent.
Compatibility Data (lynx-compat-data)
The source of truth for platform compatibility is stored in packages/lynx-compat-data. This is a JSON database similar to MDN's browser-compat-data.
Adding a New API
- Navigate to
packages/lynx-compat-data. - Find the appropriate JSON file (e.g.,
lynx-api/global/console/log.json). - Add your API definition following the schema.
Displaying API Tables
To display a compatibility table in your documentation, use the <APITable> component.
Using Frontmatter (Recommended)
It is recommended to define the api field in the frontmatter.
Then place <APITable /> in your MDX file. It will automatically read the api field.
Multiple Tables (Explicit Query)
When you need to display multiple tables on a single page, you can pass the query prop explicitly.
For example, in fetch, separate tables are used for Headers, Request, and Response:
LCD tables only load in the browser
You can verify valid queries using the Interactive Explorer below.
API Summary
For a high-level view of API groups (like methods, properties, events), use <APISummary>. Similar to <APITable>, it defaults to reading from the api frontmatter field.
Interactive Explorer
You can use the explorer below to find valid API queries and preview their tables.
LCD tables only load in the browser
Validating Documentation
We provide a script to ensure your API documentation matches the compatibility data.
This script (scripts/check_api_doc) checks for:
- Invalid
apifrontmatter keys. - Missing documentation for defined APIs.
TypeDoc Generation
API reference pages are automatically generated from TypeScript source code using TypeDoc.
- Config:
scripts/typedoc/ - Command:
pnpm run typedoc
Do not manually edit files generated by TypeDoc (usually in docs/en/api/...), as they will be overwritten. Edit the source comments instead.