docs: Improve docs to use variable version from toml. (#1603)

This commit is contained in:
Jason Lee 2025-11-14 16:10:48 +08:00 committed by GitHub
parent 37d1678b6f
commit 2a98628b5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 90 additions and 26 deletions

View file

@ -2,7 +2,6 @@ name: CI
on:
pull_request:
paths:
- "**"
- "!docs/**"
push:
branches:

View file

@ -4,6 +4,7 @@ import { generateSidebar } from "vitepress-sidebar";
import llmstxt from "vitepress-plugin-llms";
import tailwindcss from "@tailwindcss/vite";
import { lightTheme, darkTheme } from "./language";
import { ViteToml } from "vite-plugin-toml";
/**
* https://github.com/jooy2/vitepress-sidebar
@ -46,7 +47,7 @@ const config: UserConfig = {
],
],
vite: {
plugins: [llmstxt(), tailwindcss()],
plugins: [llmstxt(), tailwindcss(), ViteToml()],
},
themeConfig: {
logo: {

View file

@ -4,6 +4,7 @@ import type { Theme } from "vitepress";
import DefaultTheme from "vitepress/theme";
import "./style.css";
import GitHubStar from "./components/GitHubStar.vue";
import config from "../../../crates/ui/Cargo.toml";
/** @type {import('vitepress').Theme} */
export default {
@ -16,5 +17,8 @@ export default {
enhanceApp({ app, router, siteData }) {
// ...
app.component("GitHubStar", GitHubStar);
app.config.globalProperties.GPUI_VERSION = "0.2.2";
app.config.globalProperties.VERSION = config.package.version;
},
} satisfies Theme;

15
docs/README.md Normal file
View file

@ -0,0 +1,15 @@
# gpui-component-docs
To install dependencies:
```bash
bun install
```
To run:
```bash
bun run dev
```
This project was created using `bun init` in bun v1.2.23. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.

View file

@ -1,5 +1,6 @@
{
"lockfileVersion": 1,
"configVersion": 0,
"workspaces": {
"": {
"dependencies": {
@ -10,13 +11,18 @@
"markdown-it-mathjax3": "^4",
"postcss": "^8.5.6",
"tailwindcss": "^4.1.15",
"vite-plugin-toml": "^0.8.5",
},
"devDependencies": {
"@types/bun": "^1.3.2",
"sass": "^1",
"vitepress": "^2.0.0-alpha.12",
"vitepress-plugin-llms": "^1.8.0",
"vitepress-sidebar": "^1.18.0",
},
"peerDependencies": {
"typescript": "^5",
},
},
},
"packages": {
@ -138,6 +144,8 @@
"@rolldown/pluginutils": ["@rolldown/pluginutils@1.0.0-beta.29", "", {}, "sha512-NIJgOsMjbxAXvoGq/X0gD7VPMQ8j9g0BiDaNjVNVjvl+iKXxL3Jre0v31RmBYeLEmkbj2s02v8vFTbUXi5XS2Q=="],
"@rollup/pluginutils": ["@rollup/pluginutils@5.3.0", "", { "dependencies": { "@types/estree": "^1.0.0", "estree-walker": "^2.0.2", "picomatch": "^4.0.2" }, "peerDependencies": { "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" }, "optionalPeers": ["rollup"] }, "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q=="],
"@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.52.5", "", { "os": "android", "cpu": "arm" }, "sha512-8c1vW4ocv3UOMp9K+gToY5zL2XiiVw3k7f1ksf4yO1FlDFQ1C2u72iACFnSOceJFsWskc2WZNqeRhFRPzv+wtQ=="],
"@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.52.5", "", { "os": "android", "cpu": "arm64" }, "sha512-mQGfsIEFcu21mvqkEKKu2dYmtuSZOBMmAl5CFlPGLY94Vlcm+zWApK7F/eocsNzp8tKmbeBP8yXyAbx0XHsFNA=="],
@ -230,6 +238,8 @@
"@tailwindcss/vite": ["@tailwindcss/vite@4.1.15", "", { "dependencies": { "@tailwindcss/node": "4.1.15", "@tailwindcss/oxide": "4.1.15", "tailwindcss": "4.1.15" }, "peerDependencies": { "vite": "^5.2.0 || ^6 || ^7" } }, "sha512-B6s60MZRTUil+xKoZoGe6i0Iar5VuW+pmcGlda2FX+guDuQ1G1sjiIy1W0frneVpeL/ZjZ4KEgWZHNrIm++2qA=="],
"@types/bun": ["@types/bun@1.3.2", "", { "dependencies": { "bun-types": "1.3.2" } }, "sha512-t15P7k5UIgHKkxwnMNkJbWlh/617rkDGEdSsDbu+qNHTaz9SKf7aC8fiIlUdD5RPpH6GEkP0cK7WlvmrEBRtWg=="],
"@types/debug": ["@types/debug@4.1.12", "", { "dependencies": { "@types/ms": "*" } }, "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ=="],
"@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
@ -246,6 +256,10 @@
"@types/ms": ["@types/ms@2.1.0", "", {}, "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA=="],
"@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="],
"@types/react": ["@types/react@19.2.4", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-tBFxBp9Nfyy5rsmefN+WXc1JeW/j2BpBHFdLZbEVfs9wn3E3NRFxwV0pJg8M1qQAexFpvz73hJXFofV0ZAu92A=="],
"@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
"@types/web-bluetooth": ["@types/web-bluetooth@0.0.21", "", {}, "sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA=="],
@ -308,6 +322,8 @@
"braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="],
"bun-types": ["bun-types@1.3.2", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-i/Gln4tbzKNuxP70OWhJRZz1MRfvqExowP7U6JKoI8cntFrtxg7RJK3jvz7wQW54UuvNC8tbKHHri5fy74FVqg=="],
"ccount": ["ccount@2.0.1", "", {}, "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="],
"character-entities": ["character-entities@2.0.2", "", {}, "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ=="],
@ -376,6 +392,8 @@
"escape-string-regexp": ["escape-string-regexp@5.0.0", "", {}, "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw=="],
"eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="],
"esm": ["esm@3.2.25", "", {}, "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA=="],
"esprima": ["esprima@4.0.1", "", { "bin": { "esparse": "./bin/esparse.js", "esvalidate": "./bin/esvalidate.js" } }, "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="],
@ -686,6 +704,8 @@
"tokenx": ["tokenx@1.2.0", "", {}, "sha512-x4bRrL23b22H+EqW2pbhIkkt3ouj27ZGmAS1QoIqpocEO4m0sAl2H1M4L1UzKqleikY4U9lz/TbEw4jeG8tm2A=="],
"toml-eslint-parser": ["toml-eslint-parser@0.10.0", "", { "dependencies": { "eslint-visitor-keys": "^3.0.0" } }, "sha512-khrZo4buq4qVmsGzS5yQjKe/WsFvV8fGfOjDQN0q4iy9FjRfPWRgTFrU8u1R2iu/SfWLhY9WnCi4Jhdrcbtg+g=="],
"tr46": ["tr46@0.0.3", "", {}, "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="],
"trim-lines": ["trim-lines@3.0.1", "", {}, "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg=="],
@ -694,8 +714,12 @@
"tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
"uc.micro": ["uc.micro@2.1.0", "", {}, "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A=="],
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
"unified": ["unified@11.0.5", "", { "dependencies": { "@types/unist": "^3.0.0", "bail": "^2.0.0", "devlop": "^1.0.0", "extend": "^3.0.0", "is-plain-obj": "^4.0.0", "trough": "^2.0.0", "vfile": "^6.0.0" } }, "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA=="],
"unist-util-is": ["unist-util-is@6.0.1", "", { "dependencies": { "@types/unist": "^3.0.0" } }, "sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g=="],
@ -718,6 +742,8 @@
"vite": ["vite@7.1.11", "", { "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-uzcxnSDVjAopEUjljkWh8EIrg6tlzrjFUfMcR1EVsRDGwf/ccef0qQPRyOrROwhrTDaApueq+ja+KLPlzR/zdg=="],
"vite-plugin-toml": ["vite-plugin-toml@0.8.5", "", { "dependencies": { "@rollup/pluginutils": "^5.3.0", "toml-eslint-parser": "^0.10.0" }, "peerDependencies": { "rollup": "^4.0.0" } }, "sha512-ioAxi6GG2IyrRngCRYG81779spz3jSEhn1iRhz6dtXZ81NaKgORo4A/MWAYMtza7tp946g+2SNvHQFpt+yu3fg=="],
"vitepress": ["vitepress@2.0.0-alpha.12", "", { "dependencies": { "@docsearch/css": "^4.0.0-beta.7", "@docsearch/js": "^4.0.0-beta.7", "@iconify-json/simple-icons": "^1.2.47", "@shikijs/core": "^3.9.2", "@shikijs/transformers": "^3.9.2", "@shikijs/types": "^3.9.2", "@types/markdown-it": "^14.1.2", "@vitejs/plugin-vue": "^6.0.1", "@vue/devtools-api": "^8.0.0", "@vue/shared": "^3.5.18", "@vueuse/core": "^13.6.0", "@vueuse/integrations": "^13.6.0", "focus-trap": "^7.6.5", "mark.js": "8.11.1", "minisearch": "^7.1.2", "shiki": "^3.9.2", "vite": "^7.1.2", "vue": "^3.5.18" }, "peerDependencies": { "markdown-it-mathjax3": "^4", "oxc-minify": "^0.82.1", "postcss": "^8" }, "optionalPeers": ["markdown-it-mathjax3", "oxc-minify", "postcss"], "bin": { "vitepress": "bin/vitepress.js" } }, "sha512-yZwCwRRepcpN5QeAhwSnEJxS3I6zJcVixqL1dnm6km4cnriLpQyy2sXQDsE5Ti3pxGPbhU51nTMwI+XC1KNnJg=="],
"vitepress-plugin-llms": ["vitepress-plugin-llms@1.8.0", "", { "dependencies": { "gray-matter": "^4.0.3", "markdown-it": "^14.1.0", "markdown-title": "^1.0.2", "mdast-util-from-markdown": "^2.0.2", "millify": "^6.1.0", "minimatch": "^10.0.3", "path-to-regexp": "^8.3.0", "picocolors": "^1.1.1", "pretty-bytes": "^7.0.1", "remark": "^15.0.1", "remark-frontmatter": "^5.0.0", "tokenx": "^1.1.0", "unist-util-remove": "^4.0.0", "unist-util-visit": "^5.0.0" } }, "sha512-JQR2j+4OpB0GlmXSJCdTHYIx4AcOZ0LVLRwQVId1wvNRRRGTVs17S5YkBNV0oj8t0zTgJ+TE61f58CJC8CTe4w=="],

View file

@ -17,10 +17,10 @@ The [gpui-component-assets] crate provides a default bundled assets implementati
To use the default bundled assets, you need to add the `gpui-component-assets` crate as a dependency in your `Cargo.toml`:
```toml
```toml-vue
[dependencies]
gpui-component = "*"
gpui-component-assets = "*"
gpui-component = "{{ VERSION }}"
gpui-component-assets = "{{ VERSION }}"
```
Then we need call the `with_assets` method when creating the GPUI application to register the asset source:

View file

@ -11,9 +11,9 @@ The WebView component provides a native web browser control that can display web
WebView requires the optional `webview` feature to be enabled:
```toml
```toml-vue
[dependencies]
gpui-component = { version = "...", features = ["webview"] }
gpui-component = { version = "{{ VERSION }}", features = ["webview"] }
```
## Import

View file

@ -10,12 +10,12 @@ order: -2
Add dependencies to your `Cargo.toml`:
```toml
```toml-vue
[dependencies]
gpui = "0.2"
gpui-component = "0.4.0-preview2"
gpui = "{{ GPUI_VERSION }}"
gpui-component = "{{ VERSION }}"
# Optional, for default bundled assets
gpui-component-assets = "0.4.0-preview2"
gpui-component-assets = "{{ VERSION }}"
```
:::tip

View file

@ -27,10 +27,10 @@ GPUI Component is a comprehensive UI component library for building fantastic de
Add `gpui` and `gpui-component` to your `Cargo.toml`:
```toml
```toml-vue
[dependencies]
gpui = "0.2"
gpui-component = "0.4.0-preview2"
gpui = "{{ VERSION }}"
gpui-component = "{{ VERSION }}"
```
Then create a simple "Hello, World!" application with a button:

View file

@ -41,7 +41,7 @@ We use Rust programming language to build the `gpui-component` library. Make sur
To install the `gpui-component` library, you can use Cargo, the Rust package manager. Add the following line to your `Cargo.toml` file under the `[dependencies]` section:
```toml
gpui = "0.2"
gpui-component = "0.4.0-preview2"
```toml-vue
gpui = "{{ GPUI_VERSION }}"
gpui-component = "{{ VERSION }}"
```

View file

@ -24,9 +24,9 @@ Button::new("ok")
Add the following to your `Cargo.toml`:
```toml
gpui = "0.2"
gpui-component = "0.4.0-preview2"
```toml-vue
gpui = "{{ GPUI_VERSION }}"
gpui-component = "{{ VERSION }}"
```
:::warning

View file

@ -10,6 +10,12 @@
<a href="docs/getting-started" class="btn-primary">Get Started</a>
<a href="docs/components"><Blocks /> Components</a>
</div>
<div class="version">
Version:
<a href="https://crates.io/crates/gpui-component" target="_blank">{{
VERSION
}}</a>
</div>
</div>
<div class="features">
<div class="feature-card">
@ -107,16 +113,16 @@ import {
@reference "./.vitepress/theme/style.css";
.banner {
@apply -mt-20 py-12 xl:py-30 text-center border border-b-0 border-dashed border-(--border);
@apply flex flex-col gap-2 lg:gap-4 -mt-20 py-12 xl:py-30 text-center border border-b-0 border-dashed border-(--border);
h1 {
@apply mt-20 text-3xl xl:text-5xl font-bold mb-2 text-(--primary);
}
.banner-description {
@apply text-lg xl:text-2xl text-(--muted-foreground) mt-2 xl:mt-4;
@apply text-lg xl:text-2xl text-(--muted-foreground);
}
.actions {
@apply mt-4 flex gap-4 justify-center text-sm;
@apply flex justify-center text-sm;
a {
@apply flex items-center h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5 no-underline
bg-(--secondary) hover:bg-(--secondary)/70 text-(--secondary-foreground);
@ -130,6 +136,12 @@ import {
}
}
}
.version {
@apply text-sm text-(--muted-foreground);
a {
@apply text-(--muted-foreground) no-underline hover:underline;
}
}
}
.features {

View file

@ -1,4 +1,5 @@
{
"name": "gpui-component-docs",
"dependencies": {
"@tailwindcss/postcss": "^4.1.15",
"@tailwindcss/vite": "^4.1.15",
@ -6,17 +7,23 @@
"lucide-vue-next": "^0.546.0",
"markdown-it-mathjax3": "^4",
"postcss": "^8.5.6",
"tailwindcss": "^4.1.15"
"tailwindcss": "^4.1.15",
"vite-plugin-toml": "^0.8.5"
},
"devDependencies": {
"@types/bun": "^1.3.2",
"sass": "^1",
"vitepress": "^2.0.0-alpha.12",
"vitepress-plugin-llms": "^1.8.0",
"vitepress-sidebar": "^1.18.0",
"sass": "^1"
"vitepress-sidebar": "^1.18.0"
},
"scripts": {
"dev": "vitepress dev",
"build": "vitepress build",
"preview": "vitepress preview"
},
"private": true,
"peerDependencies": {
"typescript": "^5"
}
}