chore: add theme types docs (#2737)

Release Notes:

- Added documentation about theme types generation
This commit is contained in:
Nate Butler 2023-07-27 13:21:31 -04:00 committed by GitHub
commit 27931663d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

29
docs/theme/generating-theme-types.md vendored Normal file
View File

@ -0,0 +1,29 @@
[⬅ Back to Index](../index.md)
# Generating Theme Types
## How to generate theme types:
Run a script
```bash
./script/build-theme-types
```
Types are generated in `styles/src/types/zed.ts`
## How it works:
1. Rust types
The `crates/theme` contains theme types.
Crate `schemars` used to generate a JSON schema from the theme structs.
Every struct that represent theme type has a `#[derive(JsonSchema)]` attribute.
Task lotaked at `crates/xtask/src/main.rs` generates a JSON schema from the theme structs.
2. TypeScript types
Script `npm run build-types` from `styles` package generates TypeScript types from the JSON schema and saves them to `styles/src/types/zed.ts`.