Skip to content

Commit 7d522fb

Browse files
committed
update doc
1 parent 19f7706 commit 7d522fb

File tree

10 files changed

+210
-32
lines changed

10 files changed

+210
-32
lines changed

src/SUMMARY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158
- [QuickStart](./gen/exmaple/quickstart.md)
159159
- [Video](./gen/exmaple/video.md)
160160
- [Tutorials]()
161+
- [GenUI Env](./gen/tutorials/env.md)
162+
- [GenUI Config Toml](./gen/tutorials/conf.md)
163+
- [GenUI Compiler](./gen/tutorials/compiler.md)
161164
- [GenUI Logger](./gen/tutorials/logger.md)
162165
- [GenUI Structure](./gen/tutorials/structure.md)
163166
- [GenUI Ignore](./gen/tutorials/ignore.md)

src/gen/exmaple/quickstart.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,28 +92,25 @@ pub mod root;
9292
- 设置目标入口文件的文件名字为`app`,这会让最终Makepad的入口为`app.rs`
9393
- 指定`E:/Rust/try/makepad/Gen-UI/examples/gen_makepad_simple/ui/views/root.gen`这个文件作为UI的根文件(通过这种方式,来切换多个UI根)
9494
- `add_dep()`方法将依赖添加到编译器中
95-
- 调用`compile()`方法进行编译
95+
- 调用`build()`方法进行编译
9696
- 调用`run()`方法启动编译器
9797

9898
```rust
99-
use gen_compiler::{app, DepType, RustDependence, Target};
99+
use gen_compiler::{app, Target, Builder};
100100

101101
fn main() {
102-
// set app and specify target
103-
let mut app = app(Target::Makepad);
104-
// add makepad widget dependence
105-
let mut makepad_widget = RustDependence::new("makepad-widgets");
106-
makepad_widget.set_ty(DepType::local(
107-
"E:/Rust/try/makepad/makepad/rik/makepad/widgets",
108-
));
109-
110-
// compile and run
111-
let _ = app
102+
let compiler = Target::makepad()
112103
.entry("app")
113104
.root("E:/Rust/try/makepad/Gen-UI/examples/gen_makepad_simple/ui/views/root.gen")
114-
.add_dep(makepad_widget)
115-
.compile();
105+
.add_dep("makepad-widgets")
106+
.local("E:/Rust/try/makepad/makepad/rik/makepad/widgets")
107+
.build()
108+
.build();
109+
110+
// set app and specify target
111+
let mut app = app(Some(Box::new(compiler))).build();
116112

117113
let _ = app.run();
118114
}
119-
```
115+
```
116+

src/gen/tutorials/compiler.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# GenUI Compiler
2+
GenUI Compiler is used to compile the current UI project into the underlying target project code
3+
4+
### Attention
5+
you should write from project root path as relative path
6+
### Example No `gen.toml`
7+
we can create a compiler without `gen.toml` file, but we need to specify the target and other configurations
8+
9+
compiler use `builder` pattern, so you can chain the method to build the compiler,
10+
and finally call `build` method to get the compiler.
11+
```rust
12+
use gen_compiler::{app, Target, Builder};
13+
14+
fn main() {
15+
let compiler = Target::makepad()
16+
.entry("app")
17+
.root("E:/Rust/try/makepad/Gen-UI/examples/gen_makepad_simple/ui/views/root.gen")
18+
.add_dep("makepad-widgets")
19+
.local("E:/Rust/try/makepad/makepad/rik/makepad/widgets")
20+
.build()
21+
.wasm() // do not use if you don't need wasm
22+
.build()
23+
.build();
24+
25+
// set app and specify target
26+
let mut app = app(Some(Box::new(compiler))).build();
27+
28+
let _ = app.run();
29+
}
30+
31+
```
32+
---
33+
### Example With `gen.toml`
34+
if you have a `gen.toml` file, you can create a compiler without specifying the target and other configurations
35+
the `gen.toml` file should be in the project root path, such as:
36+
```text
37+
hello
38+
├── src_gen
39+
├────── // ....
40+
├── ui
41+
├────── src
42+
├────── gen.toml
43+
```
44+
#### gen.toml
45+
```toml
46+
[compiler]
47+
target = "makepad"
48+
log_level = "info"
49+
logo = true
50+
51+
[makepad]
52+
entry = "app"
53+
root = "E:/Rust/try/makepad/Gen-UI/examples/gen_makepad_simple/ui/views/root.gen"
54+
[makepad.dependencies]
55+
makepad-widgets = { path = "E:/Rust/try/makepad/makepad/rik/makepad/widgets" }
56+
```
57+
#### main.rs
58+
gen compiler will read the `gen.toml` file and create, so you do not need to pass the compiler
59+
60+
If you pass the compiler, the compiler will be used instead of the `gen.toml` file
61+
```rust
62+
use gen_compiler::{app, Builder};
63+
64+
fn main() {
65+
let mut app = app(None).build();
66+
let _ = app.run();
67+
}
68+
```

src/gen/tutorials/conf.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# GenUI Config Toml
2+
3+
## Priority
4+
5+
Compiler > Env > Conf
6+
7+
> Although Conf Toml has lowest level, it is the most recommended!
8+
9+
## Toml Description
10+
11+
```toml
12+
[compiler]
13+
target = "makepad"
14+
log_level = "info"
15+
logo = true
16+
17+
[makepad]
18+
entry = "app"
19+
root = "E:/Rust/try/makepad/Gen-UI/examples/gen_makepad_simple/ui/views/root.gen"
20+
[makepad.dependencies]
21+
makepad-widgets = { path = "E:/Rust/try/makepad/makepad/rik/makepad/widgets" }
22+
[wasm]
23+
check = false
24+
fresh = true
25+
port = 8016
26+
```
27+
28+
### `[compiler]` Args
29+
30+
|Name|Type|Options|Default Value|
31+
|--|--|--|--|
32+
|target|String|1. "makepad"|"makepad"|
33+
|log_level|String|1. `error`<br />2. `warn`<br />3. `info`<br />4. `debug`<br />5. `trace`|"info"|
34+
|logo|bool|1. true<br />2. false|true|
35+
36+
- `target`: Set GenUI Compiler target
37+
- `logo`: Set Logo is print or not
38+
- `logo_level`: Set GenUI Log Level
39+
40+
### `[makepad]` Args
41+
42+
|Name|Type|Options|Default Value|
43+
|--|--|--|--|
44+
|entry|String|-|"app"|
45+
|root|PathBuf|-|-|
46+
47+
- `entry`: makepad entry app rs file
48+
- `root`: your ui dir root gen file
49+
50+
#### `[makepad.dependencies]`
51+
52+
required now!
53+
54+
format: `makepad-widgets = { path = "the/latest/makepad-widget/package/path" }`
55+
56+
recommand: `makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "rik" }`
57+
58+
#### `[makepad.wasm]`
59+
60+
not required
61+
62+
|Name|Type|Options|Default Value|
63+
|--|--|--|--|
64+
|check|bool|1. true<br />2. false|false|
65+
|fresh|bool|1. true<br />2. false|false|
66+
|port|u16|0~65535|8010|

src/gen/tutorials/env.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# GenUI Env
2+
Environment variables used by the compiler.
3+
4+
- `GENUI_TARGET`: Set GenUI Compiler target
5+
- `GENUI_LOGO`: Set Logo is print or not
6+
- `GENUI_LOG_LEVEL`: Set GenUI Log Level
7+
8+
## Details
9+
10+
|Env Name|Default Value|Type|Option Values|
11+
|--|--|--|--|
12+
|`GENUI_TARGET`|`makepad`|`String`|1. `makepad`|
13+
|`GENUI_LOGO`|`true`|`Bool`|1. `true`<br /> 2. `false`|
14+
|`GENUI_LOG_LEVEL`|`info`|`String`|1. `error`<br />2. `warn`<br />3. `info`<br />4. `debug`<br />5. `trace`|
15+
16+
## How to Set Env Variable
17+
18+
### Windows
19+
20+
```bash
21+
setx GENUI_TARGET makepad
22+
```
23+
24+
### Mac/Linux
25+
26+
```bash
27+
export GENUI_TARGET=makepad
28+
```
29+
30+
## Use Place
31+
32+
- [`GENUI_TARGET`](./compiler.md)
33+
- [`GENUI_LOGO`](./logger.md)
34+
- [`GENUI_LOG_LEVEL`](./logger.md)

src/gen/tutorials/logger.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
## Logo
44

5-
![](../../static/gen/tutorials/logo.png)
5+
You can control whether the logo is printed using the system environment variable `GENUI_LOGO` or through the configuration file in TOML format.
6+
7+
- For more details, see [GenUI Environment Setup](https://palpus-rs.github.io/Gen-UI.github.io/gen/tutorials/env.html).
8+
- For configuration, see [GenUI Config TOML](https://palpus-rs.github.io/Gen-UI.github.io/gen/tutorials/conf.html).
9+
10+
Example:
611

712
```rust
813
GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>>
@@ -12,23 +17,27 @@ GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>>
1217
_/ _/_/ _/_/_/ _/ _/ _/ _/ _/ _/
1318
_/ _/ _/ _/ _/_/ _/ _/ _/
1419
_/_/_/ _/_/_/_/ _/ _/ _/_/ _/_/_/
15-
20+
1621
```
1722

1823
## Services
1924

25+
The GenUI Logger provides detailed information about the state of various services. Here are some log examples:
26+
2027
```rust
21-
GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>> 🔧 Log Service is starting... you can get log after app event::Change happened!
22-
GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>> 🔧 Source Generator Service start success!
23-
GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>> ✅ Cache Service: write cache file success!
28+
GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>> 🔧 Log Service is starting... Log entries will be available after the `app event::Change` occurs!
29+
GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>> 🔧 Source Generator Service started successfully!
30+
GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>> ✅ Cache Service: Cache file written successfully!
2431
GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>> 🔧 App is running...
25-
GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>> 🔧 Watcher Service start success!
32+
GenUI-Compiler :: [2024-06-29T08:53:57Z] :: INFO >>> 🔧 Watcher Service started successfully!
2633
```
2734

28-
## Timing Compile
35+
## Compile Timing
36+
37+
The logger also tracks and displays compile timings, helping you monitor the compilation process:
2938

3039
```rust
31-
GenUI-Compiler :: [2024-06-28T19:09:24Z] :: INFO >>> file "E:\\Rust\\try\\makepad\\Gen-UI\\examples\\gen_makepad_simple\\ui\\views\\root.gen" is compiled successfully.
32-
GenUI-Compiler :: [2024-06-28T19:09:24Z] :: INFO >>> ✅ Cache Service: write cache file success!
33-
GenUI-Compiler :: [2024-06-28T19:09:24Z] :: INFO >>> file "E:\\Rust\\try\\makepad\\Gen-UI\\examples\\gen_makepad_simple\\ui\\views\\root.gen" is compiled successfully.
40+
GenUI-Compiler :: [2024-06-28T19:09:24Z] :: INFO >>> File "E:\\Rust\\try\\makepad\\Gen-UI\\examples\\gen_makepad_simple\\ui\\views\\root.gen" compiled successfully.
41+
GenUI-Compiler :: [2024-06-28T19:09:24Z] :: INFO >>> ✅ Cache Service: Cache file written successfully!
42+
GenUI-Compiler :: [2024-06-28T19:09:24Z] :: INFO >>> File "E:\\Rust\\try\\makepad\\Gen-UI\\examples\\gen_makepad_simple\\ui\\views\\root.gen" compiled successfully.
3443
```

src/gen/tutorials/structure.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# GenUI Structure
22

3-
- src_gen: 编译后makepad原始代码目录
4-
- ui: GenUI代码目录
5-
- src/main.rs: 主入口文件
6-
- static: 静态文件目录
7-
- views: .gen文件目录(当然这个名字可以是任意的)
8-
- .gen_cache: GenUI缓存文件
9-
- .gen_ignore: GenUI忽略的编译文件
3+
- `src_gen`: 编译后makepad原始代码目录
4+
- `ui`: GenUI代码目录
5+
- `src/main.rs`: 主入口文件
6+
- `resources`: 静态文件目录
7+
- `views`: .gen文件目录(当然这个名字可以是任意的)
8+
- `.gen_cache`: GenUI缓存文件
9+
- `.gen_ignore`: GenUI忽略的编译文件
10+
- `gen.toml`: GenUI项目配置文件
1011

1112
![](../../static/gen/tutorials/struct.png)

src/static/gen/tutorials/compare.png

93.4 KB
Loading

src/static/gen/tutorials/logo.png

-6.73 KB
Binary file not shown.

src/static/gen/tutorials/struct.png

14.5 KB
Loading

0 commit comments

Comments
 (0)