Skip to content

Commit 9ec7604

Browse files
committed
update doc
1 parent 2c548fd commit 9ec7604

File tree

17 files changed

+260
-103
lines changed

17 files changed

+260
-103
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# GenUI Book
22

3-
🥳 GenUI v0.1.0 has been released
3+
🥳 GenUI v0.1.1 has been released
44

5-
- [GenUI](https://github.com/Privoce/GenUI/releases/tag/v0.1.0)
6-
- [Ract](https://github.com/Privoce/ract/releases/tag/v0.1.1)
7-
- [GenUI Builtin Component](https://github.com/Privoce/GenUI-Builtin-Component/releases/tag/v0.2.0)
5+
- [GenUI](https://github.com/Privoce/GenUI/releases/tag/v0.1.1)
6+
- [Ract](https://github.com/Privoce/ract/releases/tag/v0.1.6)
7+
- [GenUI Builtin Component](https://github.com/Privoce/GenUI-Builtin-Component/releases/tag/v0.2.1)
88
- [GenUI Book](https://privoce.github.io/GenUI.github.io)
99

1010
## Contact & Feedback

docs/v0.1.0/en/doc/config/env.mdx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Tab, Tabs } from 'rspress/theme';
1+
import { Tab, Tabs } from "rspress/theme";
22

33
# Env
44

@@ -52,21 +52,22 @@ Take `Ract` installed using `cargo` as an example:
5252
🔸 env: Set the `path` for the chain env.toml file
5353
🔸 chain_env_toml: Set the rust dependency for GenUI toolchain
5454

55-
? Which env file do you want to config?
55+
? Which env file do you want to config?
5656
> env
5757
chain_env_toml
5858
# ---
59-
? Get or Set Config?
59+
? Get or Set Config?
6060
get
6161
> set
6262
```
6363
</Tab>
6464
<Tab label="Manual Configuration">
6565
You need to find the installation address of ract, for example, if you use `cargo` to install it, the address is: `~/.cargo/bin/.env`
66-
```shell
66+
```shell
6767
vim ~/.cargo/bin/.env
6868
```
6969
</Tab>
70+
7071
</Tabs>
7172

7273
## `env.toml`(chain_env_toml)
@@ -78,16 +79,31 @@ Take `Ract` installed using `cargo` as an example:
7879
Only `[dependencies]` in the `env.toml` file points to the dependency location
7980

8081
```toml title="env.toml"
82+
version = "0.1.6"
83+
is_latest = true
84+
auto_update = true
85+
check = { auto = true, last_time = 1741547846, frequency = 172800 }
86+
8187
[dependencies]
8288
makepad-widgets = "~/.cargo/bin/chain/makepad"
8389
gen_components = "~/.cargo/bin/chain/gen_components"
8490
```
8591

86-
|key|value type|description|
87-
|---|-----|---|
88-
|`makepad-widgets`|`String`|`makepad-widgets` dependency address|
89-
|`gen_components`|`String`|`gen_components`(GenUI Builtin Components) dependency address|
92+
| key | value type | description |
93+
| ----------------- | ---------- | ---------------------------------------------------------------- |
94+
| `version` | `String` | `ract` version number |
95+
| `is_latest` | `bool` | Is it the latest version |
96+
| `auto_update` | `bool` | Automatic update |
97+
| `check` | `Check` | Detection |
98+
| `makepad-widgets` | `String` | Dependency address of `makepad-widgets` |
99+
| `gen_components` | `String` | Dependency address of `gen_components`(GenUI Builtin Components) |
100+
101+
| key | value type | description |
102+
| ----------------- | ---------- | ---------------------------------------------------------------- |
103+
| `auto` | `bool` | Automatic detection |
104+
| `last_time` | `u64` | Timestamp of the latest detection (s) |
105+
| `frequency` | `u64` | Detection frequency (s) |
90106

91107
### Set Config
92108

93-
The modification method of `env.toml` is the same as `.env`. You only need to select `chain_env_toml` when `Ract` asks you.
109+
The modification method of `env.toml` is the same as `.env`. You only need to select `chain_env_toml` when `Ract` asks you.

docs/v0.1.0/en/doc/config/ract_toml.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ import { Tab, Tabs } from "rspress/theme";
3232
| `target` | `FrameworkType` | Project type |
3333
| `members` | `Option<Vec<Member>>` | Project members |
3434
| `compiles` | `Option<Vec<usize>>` | Projects to be compiled. If not set, compile the first project in the member |
35+
|`resources`|`Resource`|Package resource pointer|
3536

3637
> - [`FrameworkType`](/doc/config/types#frameworktype)
3738
> - [`Member`](/doc/config/types#member)
39+
> - [`Resource`](/doc/config/types#resources)
3840
3941
### Source Code `.ract`
4042

@@ -62,5 +64,6 @@ pub struct RactToml {
6264
/// - if compiles length is 1, compile the project in the members by index
6365
/// - if compiles length is more than 1, use multiple threads to compile the projects
6466
pub compiles: Option<Vec<usize>>,
67+
pub resources: Vec<Resource>,
6568
}
6669
````

docs/v0.1.0/en/doc/config/types.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ pub struct Member {
3737
}
3838
```
3939

40+
41+
### Resource
42+
43+
- `String`: resource path
44+
- `Obj`:
45+
- `src`: source resource path
46+
- `target`: `target path`
47+
48+
#### Source Code
49+
50+
```
51+
#[derive(Debug, Clone)]
52+
pub enum Resource {
53+
String(String),
54+
Obj { src: PathBuf, target: String },
55+
}
56+
```
57+
4058
## `gen_ui.toml`
4159

4260
### CompilerConf

docs/v0.1.0/en/doc/tutorial/quick-start.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This is a quick start example, through which you can quickly understand the deve
99
| Name | Version |
1010
| ---- | ------- |
1111
| Mac | - |
12-
| Ract | 0.1.0+ |
12+
| Ract | 0.1.6+ |
1313

1414
> [!TIP]
1515
>
@@ -19,9 +19,9 @@ This is a quick start example, through which you can quickly understand the deve
1919

2020
`Ract` is the first step in your journey to GenUI, please choose the latest version to download
2121

22-
> Releases: https://github.com/Privoce/ract/releases
22+
> 👍 crates.io: https://crates.io/crates/ract
2323
>
24-
> cratio: https://crates.io/crates/ract
24+
> Releases: https://github.com/Privoce/ract/releases
2525
2626
> [!WARNING]
2727
>

docs/v0.1.0/en/doc/tutorial/script.mdx

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,53 @@ The script part of `GenUI` uses the Rust language and is wrapped in the `<script
66
>
77
> This document only briefly describes the use of the script part. For specific documents, please refer to: [API](/zh/api/index)
88
9+
## Define components
10+
11+
For custom components, we need to use the `#[component]` macro to declare the component's properties, but not all types are allowed. Types that can be used in properties need to implement the `Default` trait.
12+
Custom structs and enums need to be annotated with `#[prop]`.
13+
14+
```rust
15+
<script>
16+
#[component]
17+
pub struct MyView{
18+
name: String
19+
}
20+
</script>
21+
```
22+
923
## Define component properties
1024

11-
For custom components, we need to use the `#[prop]` macro to declare the component's properties, but not all types are allowed. The types that can be used in the properties need to implement the `Default` trait.
25+
When you want to build a custom struct or enum in a component, you need to use `#[prop]` to annotate it and implement the `Default` trait
1226

1327
```rust
1428
<script>
15-
#[prop]
29+
#[component]
1630
pub struct MyView{
31+
user: User,
32+
auth: Auth
33+
}
34+
35+
#[prop]
36+
#[derive(Debug, Clone)]
37+
pub struct User{
1738
name: String
1839
}
40+
41+
impl Default for User{
42+
fn default() -> Self{
43+
Self{ name: "John" }
44+
}
45+
}
46+
47+
#[prop]
48+
#[derive(Default, Clone, Copy, Debug)]
49+
pub enum Auth{
50+
#[default]
51+
Custom,
52+
User,
53+
Remote,
54+
Other
55+
}
1956
</script>
2057
```
2158

@@ -54,25 +91,26 @@ In this example, we define the value of the `text` property of `label` in `MyVie
5491
</template>
5592

5693
<script>
57-
#[prop]
94+
#[component]
5895
pub struct MyView{
5996
txt: String
6097
}
6198

62-
let mut prop = default_prop!{
63-
MyView{
64-
txt: "Hello".to_string()
99+
impl Default for MyView{
100+
fn default() -> Self{
101+
Self{
102+
txt: "Hello".to_string()
103+
}
65104
}
66-
};
105+
}
67106
</script>
68107
```
69108

70109
In this code, the `get_txt` and `set_txt` methods are automatically generated.
71110

72111
## Methods and callbacks
73112

74-
For methods and callbacks, use `fn` or `closure` to declare them. In the following example, we define the `change_txt` method as the callback method for button clicks.
75-
113+
Methods and callbacks need to be defined in the component structure using `impl`. In the following example, we define the `change_txt` method as the callback method for button clicks.
76114
```rust
77115
<template>
78116
<component name="MyView">
@@ -82,27 +120,23 @@ For methods and callbacks, use `fn` or `closure` to declare them. In the followi
82120
</template>
83121

84122
<script>
85-
#[prop]
123+
#[component]
86124
pub struct MyView{
87125
txt: String
88126
}
89127

90-
let mut prop = default_prop!{
91-
MyView{
92-
txt: "Hello".to_string()
128+
impl Default for MyView{
129+
fn default() -> Self{
130+
Self{
131+
txt: "Hello".to_string()
132+
}
93133
}
94-
};
134+
}
95135

96-
fn change_txt(){
97-
prop.set_txt("World".to_string());
136+
impl MyView{
137+
fn change_txt(&mut self){
138+
self.set_txt("World".to_string());
139+
}
98140
}
99141
</script>
100-
```
101-
102-
The above method can also be rewritten using `closure`
103-
104-
```rust
105-
let mut change_txt = ||{
106-
prop.set_txt("World".to_string());
107-
};
108142
```

docs/v0.1.0/en/doc/tutorial/template/sugar_syntax.mdx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,31 @@ The followings are details:
2828
2929
### Examples
3030

31+
> [!DANGER]
32+
>
33+
> When using syntax sugar, you need to bind the id just like the bind type
34+
>
35+
> We plan to introduce an automatic id strategy in the `v0.1.3` version (automatically generate an id for each component that does not have an id added during static compilation)
36+
3137
#### Single for
3238

3339
```html
34-
<label :for="item in label_list" :text="item"></label>
40+
<label id="mv_label" :for="item in label_list" :text="item"></label>
3541
```
3642

3743
#### Nested use
3844

3945
```html
40-
<view :for="item in label_list">
41-
<label :text="item"></label>
46+
<view id="my_view" :for="item in label_list">
47+
<label id="mv_label" :text="item"></label>
4248
</view>
4349
```
4450

4551
#### Nested for
4652

4753
```html
48-
<view :for="(index, item) in label_list">
49-
<label :for="item1 in item[index]" :text="item1"></label>
54+
<view id="mv_view" :for="(index, item) in label_list">
55+
<label id="mv_label" :for="item1 in item[index]" :text="item1"></label>
5056
</view>
5157
```
5258

docs/v0.1.0/en/doc/tutorial/template/template_type.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Component Type
22

3-
The component types here only refer to static components and custom components
3+
The component types here only refer to builtin components and custom components
44

5-
## Static Components
5+
## Builtin Components
66

7-
Static components refer to the underlying components that can be used directly during development without the need for secondary development. These underlying components are provided by [GenUI Builtin Components](/zh/components/index).
7+
Built-in components refer to the underlying components that can be used directly during development without the need to develop them yourself. These underlying components are provided by [GenUI Builtin Components](/components/index).
88

9-
All static component properties and callbacks are immutable and have built-in types
9+
All builtin component properties and callbacks are immutable and have built-in types
1010

1111
## Custom Components
1212

@@ -15,7 +15,7 @@ Custom components refer to components that are secondary developed based on exis
1515
To put it simply, any component wrapped with `<component name="SpecialName"></component>` is a custom component.
1616

1717
1. The `name` of a custom component indicates the component name when the component is referenced externally
18-
2. Custom components can also have an `id` attribute. `id` and `name` are independent of each other. For custom components, `id` is only valid internally, and `name` is valid externally. That is: [Inside-outside principle](/zh/doc/tutorial/template/basic#Inside-outside principle)
18+
2. Custom components can also have an `id` attribute. `id` and `name` are independent of each other. For custom components, `id` is only valid internally, and `name` is valid externally. That is: [Inside-outside principle](/doc/tutorial/template/basic#internal-and-external-principles)
1919
3. The `<component>` tag has no meaning, it only represents the declaration of the custom component
2020
4. Custom components inherit the `view` component by default, so the properties of the `view` component can also be used by custom components
2121
5. Custom components do not inherit the callbacks of the `view` component, only the properties

0 commit comments

Comments
 (0)