From 56d2693d472e604f92b30d39bfffef50b2543cdc Mon Sep 17 00:00:00 2001
From: chaoranz758 <2715584135@qq.com>
Date: Sun, 6 Aug 2023 11:49:28 +0800
Subject: [PATCH] docs: hz directory modification
---
.../framework-exten/response_writer.md | 2 +-
.../en/docs/hertz/tutorials/toolkit/_index.md | 2 +-
.../toolkit/{usage => }/annotation.md | 4 +-
.../tutorials/toolkit/{usage => }/cautions.md | 64 ++++++++---------
.../tutorials/toolkit/{usage => }/command.md | 4 +-
.../tutorials/toolkit/{usage => }/install.md | 12 ++--
.../tutorials/toolkit/{usage => }/layout.md | 2 +-
.../tutorials/toolkit/more-feature/_index.md | 2 +-
.../toolkit/{usage => }/usage-protobuf.md | 2 +-
.../toolkit/{usage => }/usage-thrift.md | 2 +-
.../tutorials/toolkit/{usage => }/usage.md | 0
.../hertz/tutorials/toolkit/usage/_index.md | 5 --
.../framework-exten/response_writer.md | 2 +-
.../zh/docs/hertz/tutorials/toolkit/_index.md | 2 +-
.../toolkit/{usage => }/annotation.md | 2 +
.../tutorials/toolkit/{usage => }/cautions.md | 70 +++++++++----------
.../tutorials/toolkit/{usage => }/command.md | 12 ++--
.../tutorials/toolkit/{usage => }/install.md | 16 ++---
.../tutorials/toolkit/{usage => }/layout.md | 2 +-
.../tutorials/toolkit/more-feature/_index.md | 2 +-
.../toolkit/{usage => }/usage-protobuf.md | 2 +-
.../toolkit/{usage => }/usage-thrift.md | 2 +-
.../tutorials/toolkit/{usage => }/usage.md | 0
.../hertz/tutorials/toolkit/usage/_index.md | 5 --
24 files changed, 106 insertions(+), 112 deletions(-)
rename content/en/docs/hertz/tutorials/toolkit/{usage => }/annotation.md (90%)
rename content/en/docs/hertz/tutorials/toolkit/{usage => }/cautions.md (60%)
rename content/en/docs/hertz/tutorials/toolkit/{usage => }/command.md (99%)
rename content/en/docs/hertz/tutorials/toolkit/{usage => }/install.md (94%)
rename content/en/docs/hertz/tutorials/toolkit/{usage => }/layout.md (96%)
rename content/en/docs/hertz/tutorials/toolkit/{usage => }/usage-protobuf.md (99%)
rename content/en/docs/hertz/tutorials/toolkit/{usage => }/usage-thrift.md (99%)
rename content/en/docs/hertz/tutorials/toolkit/{usage => }/usage.md (100%)
delete mode 100644 content/en/docs/hertz/tutorials/toolkit/usage/_index.md
rename content/zh/docs/hertz/tutorials/toolkit/{usage => }/annotation.md (93%)
rename content/zh/docs/hertz/tutorials/toolkit/{usage => }/cautions.md (52%)
rename content/zh/docs/hertz/tutorials/toolkit/{usage => }/command.md (92%)
rename content/zh/docs/hertz/tutorials/toolkit/{usage => }/install.md (89%)
rename content/zh/docs/hertz/tutorials/toolkit/{usage => }/layout.md (93%)
rename content/zh/docs/hertz/tutorials/toolkit/{usage => }/usage-protobuf.md (99%)
rename content/zh/docs/hertz/tutorials/toolkit/{usage => }/usage-thrift.md (99%)
rename content/zh/docs/hertz/tutorials/toolkit/{usage => }/usage.md (100%)
delete mode 100644 content/zh/docs/hertz/tutorials/toolkit/usage/_index.md
diff --git a/content/en/docs/hertz/tutorials/framework-exten/response_writer.md b/content/en/docs/hertz/tutorials/framework-exten/response_writer.md
index 108cfd8ccb..264c076318 100644
--- a/content/en/docs/hertz/tutorials/framework-exten/response_writer.md
+++ b/content/en/docs/hertz/tutorials/framework-exten/response_writer.md
@@ -34,7 +34,7 @@ Example:
h.GET("/hijack", func(c context.Context, ctx *app.RequestContext) {
// Hijack the writer of response
ctx.Response.HijackWriter(yourResponseWriter)
- }
+ })
```
## Supported Response Writer Extension
diff --git a/content/en/docs/hertz/tutorials/toolkit/_index.md b/content/en/docs/hertz/tutorials/toolkit/_index.md
index aff5460e33..497219a66e 100644
--- a/content/en/docs/hertz/tutorials/toolkit/_index.md
+++ b/content/en/docs/hertz/tutorials/toolkit/_index.md
@@ -1,5 +1,5 @@
---
-title: "Code Generation"
+title: "hz Code Generation"
weight: 6
description: >
diff --git a/content/en/docs/hertz/tutorials/toolkit/usage/annotation.md b/content/en/docs/hertz/tutorials/toolkit/annotation.md
similarity index 90%
rename from content/en/docs/hertz/tutorials/toolkit/usage/annotation.md
rename to content/en/docs/hertz/tutorials/toolkit/annotation.md
index dde6c3539e..660368828d 100644
--- a/content/en/docs/hertz/tutorials/toolkit/usage/annotation.md
+++ b/content/en/docs/hertz/tutorials/toolkit/annotation.md
@@ -6,12 +6,14 @@ description: >
---
**Supported api annotations**
-> Field annotation can be used for[parameter binding and validation](https://www.cloudwego.io/docs/hertz/tutorials/basic-feature/binding-and-validate/)
+> Field annotation can be used for [parameter binding and validation](https://www.cloudwego.io/docs/hertz/tutorials/basic-feature/binding-and-validate/)
>
> Method annotation can be used to generate code that related to route registration
## Supported api annotations
+Field annotation tag description can be referenced [supported-tags](https://www.cloudwego.io/docs/hertz/tutorials/basic-feature/binding-and-validate/#supported-tags).
+
| _Field annotation_ | |
| ---------------------------------------- | ------------------------------------------------------------------ |
| annotation | description |
diff --git a/content/en/docs/hertz/tutorials/toolkit/usage/cautions.md b/content/en/docs/hertz/tutorials/toolkit/cautions.md
similarity index 60%
rename from content/en/docs/hertz/tutorials/toolkit/usage/cautions.md
rename to content/en/docs/hertz/tutorials/toolkit/cautions.md
index bd8ac56e23..11a139fa57 100644
--- a/content/en/docs/hertz/tutorials/toolkit/usage/cautions.md
+++ b/content/en/docs/hertz/tutorials/toolkit/cautions.md
@@ -6,11 +6,11 @@ description: >
---
### Notes on using protobuf IDL
-hz currently supports the syntax of [proto2](https://developers.google.com/protocol-buffers/docs/proto) / [proto3](https://developers.google.com/protocol-buffers/docs/proto3)
+hz currently supports the syntax of [proto2](https://developers.google.com/protocol-buffers/docs/proto) / [proto3](https://developers.google.com/protocol-buffers/docs/proto3).
**We hope that users specify go_package when defining the protobuf IDL**, so that one is consistent with the semantics of protobuf and the location of the generated model can be determined by go_package. If the user does not specify go_package, hz will default the package of the proto file to go_package, which may have some unintended naming conflicts.
-For example, go_package can be defined like this
+For example, go_package can be defined like this:
```protobuf
option go_package = "hello.world"; // or hello/world
@@ -32,7 +32,7 @@ The router registration file will also take the last level of the go_package as
**hz has no special requirements for the definition of thrift IDL**, it only needs to comply with the grammar specification. The code generation path will be related to the thrift namespace
-For example, a namespace can be defined like this
+For example, a namespace can be defined like this:
```thrift
namespace go hello.world
@@ -54,52 +54,52 @@ The router registration file will also take namespace as the generation path, an
1. Notes on using custom path
-For the convenience of user, hz provides custom handler paths, model paths, templates, etc. However, hz does not save the current project information when creating a new project, so it can be considered as a stateless update when using the update command. Therefore, for the same set of IDL in new and update, using different custom information may result in duplicate code, for example, as follows:
+ For the convenience of user, hz provides custom handler paths, model paths, templates, etc. However, hz does not save the current project information when creating a new project, so it can be considered as a stateless update when using the update command. Therefore, for the same set of IDL in new and update, using different custom information may result in duplicate code, for example, as follows:
-Create a new project:
+ Create a new project:
-```bash
-hz new -idl demo.thrift
+ ```bash
+ hz new -idl demo.thrift
-// In this case, hz will generate the model under "biz/model"
-```
+ // In this case, hz will generate the model under "biz/model"
+ ```
-Update an existing project:
+ Update an existing project:
-```bash
-hz update -idl demo.thrift --model_dir=my_model
+ ```bash
+ hz update -idl demo.thrift --model_dir=my_model
-// In this case, hz will not update the model code under "biz/model", but under "my_model"; then the code under "biz/model" and "my_model" will be duplicated, and the new handler will depend on "my_model",while the previous handler will depend on "biz/model". In this case, you need to delete & change some code manually.
-```
+ // In this case, hz will not update the model code under "biz/model", but under "my_model"; then the code under "biz/model" and "my_model" will be duplicated, and the new handler will depend on "my_model",while the previous handler will depend on "biz/model". In this case, you need to delete & change some code manually.
+ ```
-Therefore, **we hope that user use the update command with custom paths "client_dir", "model_dir", "handler_dir", preferably same as new.**
+ Therefore, **we hope that user use the update command with custom paths "client_dir", "model_dir", "handler_dir", preferably same as new.**
2. Behavior of update handler
-hz will generate handlers based on default/custom template when creating a new project, where each service generates a file that contains all the handler code defined by the service; if IDL defines multiple services, each service will generate a file, and these files are in the same path; for example:
+ hz will generate handlers based on default/custom template when creating a new project, where each service generates a file that contains all the handler code defined by the service; if IDL defines multiple services, each service will generate a file, and these files are in the same path; for example:
-```thrift
-// demo.thrift
-namespace go hello.example
+ ```thrift
+ // demo.thrift
+ namespace go hello.example
-service Service1 {
- HelloResp Method1(1: HelloReq request) (api.get="/hello");
-}
+ service Service1 {
+ HelloResp Method1(1: HelloReq request) (api.get="/hello");
+ }
-service Service2 {
- HelloResp Method2(1: HelloReq request) (api.get="/new");
-}
+ service Service2 {
+ HelloResp Method2(1: HelloReq request) (api.get="/new");
+ }
-// Then the handler file generated by the IDL is as follows:
-${handler_dir}/${namespace}/service1.go -> method1
-${handler_dir}/${namespace}/service2.go -> method2
-```
+ // Then the handler file generated by the IDL is as follows:
+ ${handler_dir}/${namespace}/service1.go -> method1
+ ${handler_dir}/${namespace}/service2.go -> method2
+ ```
-**When a new method is added to the IDL, the handler template will be added at the end of the corresponding service file; note that the handler added here will use the default template, and the new service file will use a custom template if appropriate.**
+ **When a new method is added to the IDL, the handler template will be added at the end of the corresponding service file; note that the handler added here will use the default template, and the new service file will use a custom template if appropriate.**
3. Behavior of update router
-The router code generated by hz in new mainly includes the following three:
+ The router code generated by hz in new mainly includes the following three:
- biz/router/${namespace}/${idlName}.go: Each primary IDL generates a corresponding routing registration code file, which registers all the routes defined in the IDL in a routing group, and sets the default middleware.
@@ -111,7 +111,7 @@ The router code generated by hz in new mainly includes the following three:
- biz/router/register.go: This file is responsible for calling the route registration generated by different IDL; for example, if i define service in both IDL "demo1.thrift" and "demo2.thrift", then both files will generate the corresponding route registration code. register.go is responsible for calling the route registration functions of these two parts.
-Based on the above description, a description of the router's behavior during update is given:
+ Based on the above description, a description of the router's behavior during update is given:
- biz/${namespace}/${idlName}.go: Regenerate based on IDL every time, users should not change the code of this file, otherwise the code will be lost.
diff --git a/content/en/docs/hertz/tutorials/toolkit/usage/command.md b/content/en/docs/hertz/tutorials/toolkit/command.md
similarity index 99%
rename from content/en/docs/hertz/tutorials/toolkit/usage/command.md
rename to content/en/docs/hertz/tutorials/toolkit/command.md
index 5158cac64d..7fdc0c7262 100644
--- a/content/en/docs/hertz/tutorials/toolkit/usage/command.md
+++ b/content/en/docs/hertz/tutorials/toolkit/command.md
@@ -17,7 +17,7 @@ USAGE:
hz [global options] command [command options] [arguments...]
VERSION:
- 0.0.1
+ 0.x.x
COMMANDS:
new Generate a new Hertz project
@@ -63,7 +63,7 @@ OPTIONS:
--protoc value, -p value Specify arguments for the protoc. ({flag}={value}) (accepts multiple inputs)
--service value Specify the service name.
--snake_tag Use snake_case style naming for tags. (Only works for 'form', 'query', 'json') (default: false)
- --thriftgo value, -t value Specify arguments for the thriftgo. ({flag}={value}) (accepts mul
+ --thriftgo value, -t value Specify arguments for the thriftgo. ({flag}={value}) (accepts mul)
```
- client_dir: Specify the path to generate client-side code, if not specified, it will not be generated; currently generates a global client for each service, and will provide rich client code capabilities later
diff --git a/content/en/docs/hertz/tutorials/toolkit/usage/install.md b/content/en/docs/hertz/tutorials/toolkit/install.md
similarity index 94%
rename from content/en/docs/hertz/tutorials/toolkit/usage/install.md
rename to content/en/docs/hertz/tutorials/toolkit/install.md
index 1c9574d358..b4ede7d617 100644
--- a/content/en/docs/hertz/tutorials/toolkit/usage/install.md
+++ b/content/en/docs/hertz/tutorials/toolkit/install.md
@@ -11,15 +11,15 @@ hz is a tool provided by the Hertz framework for generating code. Currently, hz
1. Make sure the `GOPATH` environment variable has been defined correctly (eg `export GOPATH=~/go`) and add `$GOPATH/bin` to the PATH environment (eg `export PATH=$GOPATH/bin:$PATH`); do not set `GOPATH` to a directory that the current user does not have read/write access to.
2. Install hz:
-```bash
-go install github.com/cloudwego/hertz/cmd/hz@latest
-```
+ ```bash
+ go install github.com/cloudwego/hertz/cmd/hz@latest
+ ```
3. Verify that the installation was successful `hz -v`, if the following version message is displayed, the installation was successful
-```console
-hz version v0.1.0
-```
+ ```console
+ hz version v0.x.x
+ ```
**Note**,Since hz creates soft links to its own binary, make sure that the installation path of hz has writable permissions.
diff --git a/content/en/docs/hertz/tutorials/toolkit/usage/layout.md b/content/en/docs/hertz/tutorials/toolkit/layout.md
similarity index 96%
rename from content/en/docs/hertz/tutorials/toolkit/usage/layout.md
rename to content/en/docs/hertz/tutorials/toolkit/layout.md
index 63d9dd9720..213046d95f 100644
--- a/content/en/docs/hertz/tutorials/toolkit/usage/layout.md
+++ b/content/en/docs/hertz/tutorials/toolkit/layout.md
@@ -6,7 +6,7 @@ description: >
---
### The structure of the generated code
-The structure of the code generated by hz is similar. The following is an example of the structure of the code generated by the section "Create a project based on thrift IDL" to illustrate the meaning of the code generated by hz.
+The structure of the code generated by hz is similar. The following is an example of the structure of the code generated by the section [hz usage(thrift)](/docs/hertz/tutorials/toolkit/usage/usage-thrift/) to illustrate the meaning of the code generated by hz.
```bash
.
diff --git a/content/en/docs/hertz/tutorials/toolkit/more-feature/_index.md b/content/en/docs/hertz/tutorials/toolkit/more-feature/_index.md
index 2f410a883d..fbffd75b51 100644
--- a/content/en/docs/hertz/tutorials/toolkit/more-feature/_index.md
+++ b/content/en/docs/hertz/tutorials/toolkit/more-feature/_index.md
@@ -1,5 +1,5 @@
---
title: "more features"
-weight: 2
+weight: 9
description: >
---
diff --git a/content/en/docs/hertz/tutorials/toolkit/usage/usage-protobuf.md b/content/en/docs/hertz/tutorials/toolkit/usage-protobuf.md
similarity index 99%
rename from content/en/docs/hertz/tutorials/toolkit/usage/usage-protobuf.md
rename to content/en/docs/hertz/tutorials/toolkit/usage-protobuf.md
index b243217d6f..030b3d65d2 100644
--- a/content/en/docs/hertz/tutorials/toolkit/usage/usage-protobuf.md
+++ b/content/en/docs/hertz/tutorials/toolkit/usage-protobuf.md
@@ -226,7 +226,7 @@ description: >
Add new method under "biz/handler/hello/hello_service.go"
The file "new_service.go" and the corresponding "Method3" method have been added under "biz/handler/hello"
- Now let's develop the "Method2" interface
+ Now let's develop the "Method2" interface:
```go
// Method1 .
diff --git a/content/en/docs/hertz/tutorials/toolkit/usage/usage-thrift.md b/content/en/docs/hertz/tutorials/toolkit/usage-thrift.md
similarity index 99%
rename from content/en/docs/hertz/tutorials/toolkit/usage/usage-thrift.md
rename to content/en/docs/hertz/tutorials/toolkit/usage-thrift.md
index aade9c7b4e..ed6062fe56 100644
--- a/content/en/docs/hertz/tutorials/toolkit/usage/usage-thrift.md
+++ b/content/en/docs/hertz/tutorials/toolkit/usage-thrift.md
@@ -162,7 +162,7 @@ description: >
Add new method under "biz/handler/hello/example/hello_service.go"
The file "new_service.go" and the corresponding "NewMethod" method have been added under "biz/handler/hello/example"
- Now let's develop the "OtherMethod" interface
+ Now let's develop the "OtherMethod" interface:
```go
// HelloMethod .
diff --git a/content/en/docs/hertz/tutorials/toolkit/usage/usage.md b/content/en/docs/hertz/tutorials/toolkit/usage.md
similarity index 100%
rename from content/en/docs/hertz/tutorials/toolkit/usage/usage.md
rename to content/en/docs/hertz/tutorials/toolkit/usage.md
diff --git a/content/en/docs/hertz/tutorials/toolkit/usage/_index.md b/content/en/docs/hertz/tutorials/toolkit/usage/_index.md
deleted file mode 100644
index fc959245c7..0000000000
--- a/content/en/docs/hertz/tutorials/toolkit/usage/_index.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: "hz usages"
-weight: 1
-description: >
----
diff --git a/content/zh/docs/hertz/tutorials/framework-exten/response_writer.md b/content/zh/docs/hertz/tutorials/framework-exten/response_writer.md
index f0e40eb5c7..7a62754401 100644
--- a/content/zh/docs/hertz/tutorials/framework-exten/response_writer.md
+++ b/content/zh/docs/hertz/tutorials/framework-exten/response_writer.md
@@ -34,7 +34,7 @@ Hertz 在 `app.RequestContext` 中提供了 `Response.HijackWriter` 方法让用
h.GET("/hijack", func(c context.Context, ctx *app.RequestContext) {
// Hijack the writer of response
ctx.Response.HijackWriter(yourResponseWriter)
- }
+ })
```
## 已支持 Response 的 Writer 扩展
diff --git a/content/zh/docs/hertz/tutorials/toolkit/_index.md b/content/zh/docs/hertz/tutorials/toolkit/_index.md
index c5d3c01ec8..42da354058 100644
--- a/content/zh/docs/hertz/tutorials/toolkit/_index.md
+++ b/content/zh/docs/hertz/tutorials/toolkit/_index.md
@@ -1,5 +1,5 @@
---
-title: "代码生成"
+title: "hz 代码生成"
weight: 6
description: >
diff --git a/content/zh/docs/hertz/tutorials/toolkit/usage/annotation.md b/content/zh/docs/hertz/tutorials/toolkit/annotation.md
similarity index 93%
rename from content/zh/docs/hertz/tutorials/toolkit/usage/annotation.md
rename to content/zh/docs/hertz/tutorials/toolkit/annotation.md
index e315ea5882..b117d9523c 100644
--- a/content/zh/docs/hertz/tutorials/toolkit/usage/annotation.md
+++ b/content/zh/docs/hertz/tutorials/toolkit/annotation.md
@@ -12,6 +12,8 @@ description: >
## 支持的 api 注解
+Field 注解 tag 说明可参考 [支持的-tag](https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/binding-and-validate/#%E6%94%AF%E6%8C%81%E7%9A%84-tag)。
+
| _Field 注解_ | |
| ---------------------------------------- | --------------------------------------- |
| 注解 | 说明 |
diff --git a/content/zh/docs/hertz/tutorials/toolkit/usage/cautions.md b/content/zh/docs/hertz/tutorials/toolkit/cautions.md
similarity index 52%
rename from content/zh/docs/hertz/tutorials/toolkit/usage/cautions.md
rename to content/zh/docs/hertz/tutorials/toolkit/cautions.md
index 247c63256d..a45e84e808 100644
--- a/content/zh/docs/hertz/tutorials/toolkit/usage/cautions.md
+++ b/content/zh/docs/hertz/tutorials/toolkit/cautions.md
@@ -6,11 +6,11 @@ description: >
---
### 使用 protobuf IDL 的注意事项
-hz 目前支持 [proto2](https://developers.google.com/protocol-buffers/docs/proto) / [proto3](https://developers.google.com/protocol-buffers/docs/proto3) 的语法
+hz 目前支持 [proto2](https://developers.google.com/protocol-buffers/docs/proto) / [proto3](https://developers.google.com/protocol-buffers/docs/proto3) 的语法。
-**我们希望用户在定义 protobuf idl 的时候指定 go_package**,这样一来符合 protobuf 的语义,二来生成的 model 位置可以通过 go_package 来决定。如果用户不指定 go_package,hz 会默认将 proto 文件的 package 做为 go_package,可能会有一些预期外的命名冲突。
+**我们希望用户在定义 protobuf idl 的时候指定 go_package**,这样一来符合 protobuf 的语义,二来生成的 model 位置可以通过 go_package 来决定。如果用户不指定 go_package,hz 会默认将 proto 文件的 package 作为 go_package,可能会有一些预期外的命名冲突。
-例如,可以这样定义 go_package
+例如,可以这样定义 go_package:
```protobuf
option go_package = "hello.world"; // or hello/world
@@ -32,7 +32,7 @@ router 注册文件同样会取 go_package 最后一级作为生成路径,其
**hz 对于 thrift idl 的定义无特殊要求**,符合语法规范即可。代码的生成路径会和 thrift 的 namespace 相关。
-例如,可以这样定义 namespace
+例如,可以这样定义 namespace:
```thrift
namespace go hello.world
@@ -54,52 +54,52 @@ router 注册文件同样会取 namespace 作为生成路径,其生成路径
1. 使用自定义路径的注意事项
-hz 为了用户使用方便,提供了自定义 handler 路径、model 路径、模板等功能。但是 hz 在创建一个新项目的时候并没有保存当前项目的信息,所以在使用 update 命令时可以认为是一种无状态的更新。因此对于同一套 idl 在 new 和 update 的时候,使用了不同的自定义信息,可能会产生重复的代码,举个例子,如下:
+ hz 为了用户使用方便,提供了自定义 handler 路径、model 路径、模板等功能。但是 hz 在创建一个新项目的时候并没有保存当前项目的信息,所以在使用 update 命令时可以认为是一种无状态的更新。因此对于同一套 idl 在 new 和 update 的时候,使用了不同的自定义信息,可能会产生重复的代码,举个例子,如下:
-创建新项目:
+ 创建新项目:
-```bash
-hz new -idl demo.thrift
+ ```bash
+ hz new -idl demo.thrift
-// 此时,hz 会把 model 生成在 "biz/model"下
-```
+ // 此时,hz 会把 model 生成在 "biz/model"下
+ ```
-更新项目:
+ 更新项目:
-```bash
-hz update -idl demo.thrift --model_dir=my_model
+ ```bash
+ hz update -idl demo.thrift --model_dir=my_model
-// 此时,hz 不会更新"biz/model"下的 model 代码,而是会在"my_model"下;这时"biz/model"和"my_model"下的代码就会重复,且新生成的 handler 会依赖"my_model",之前的 handler 会依赖"biz/model",这时就需要用户手动删除&改动一些代码了。
-```
+ // 此时,hz 不会更新"biz/model"下的 model 代码,而是会在"my_model"下;这时"biz/model"和"my_model"下的代码就会重复,且新生成的 handler 会依赖"my_model",之前的 handler 会依赖"biz/model",这时就需要用户手动删除&改动一些代码了。
+ ```
-因此,**我们希望用户使用 update 命令的时候,自定义的路径 "client_dir"、"model_dir"、"handler_dir",最好和 new 相同。**
+ 因此,**我们希望用户使用 update 命令的时候,自定义的路径 "client_dir"、"model_dir"、"handler_dir",最好和 new 相同。**
2. update handler 的行为
-hz 在 new 项目的时候会根据默认模板/自定义模板来生成 handler,其中每个 service 生成一个文件,该文件包含了该 service 定义的所有 handler 代码;如果 idl 定义了多个 service,则每个 service 都会生成一个文件,这些文件都在同一路径下;举个例子:
+ hz 在 new 项目的时候会根据默认模板/自定义模板来生成 handler,其中每个 service 生成一个文件,该文件包含了该 service 定义的所有 handler 代码;如果 idl 定义了多个 service,则每个 service 都会生成一个文件,这些文件都在同一路径下;举个例子:
-```thrift
-// demo.thrift
-namespace go hello.example
+ ```thrift
+ // demo.thrift
+ namespace go hello.example
-service Service1 {
- HelloResp Method1(1: HelloReq request) (api.get="/hello");
-}
+ service Service1 {
+ HelloResp Method1(1: HelloReq request) (api.get="/hello");
+ }
-service Service2 {
- HelloResp Method2(1: HelloReq request) (api.get="/new");
-}
+ service Service2 {
+ HelloResp Method2(1: HelloReq request) (api.get="/new");
+ }
-// 那么该 idl 生成的 handler 文件如下:
-${handler_dir}/${namespace}/service1.go -> method1
-${handler_dir}/${namespace}/service2.go -> method2
-```
+ // 那么该 idl 生成的 handler 文件如下:
+ ${handler_dir}/${namespace}/service1.go -> method1
+ ${handler_dir}/${namespace}/service2.go -> method2
+ ```
-**当该 idl 增加了新的 method 后,就会在对应 service 的文件的末尾追加 handler 模板;注意这里追加的 handler 会使用默认的模板,新生成 service 文件会根据情况使用自定义模板。**
+ **当该 idl 增加了新的 method 后,就会在对应 service 的文件的末尾追加 handler 模板;注意这里追加的 handler 会使用默认的模板,新生成 service 文件会根据情况使用自定义模板。**
3. update router 的行为
-hz 在 new 的时候生成的 router 代码主要有如下三个:
+ hz 在 new 的时候生成的 router 代码主要有如下三个:
- biz/router/${namespace}/${idlName}.go: 每个主 idl 都会生成对应的路由注册代码文件,该文件以路由组的方式注册 idl 中定义的所有路由,并设置默认的中间件。
@@ -109,9 +109,9 @@ hz 在 new 的时候生成的 router 代码主要有如下三个:
-- biz/router/register.go:该文件负责调用不同 idl 生成的路由注册;比如我在两个 idl "demo1.thrift"、"demo2.thrift"中都定义了 service,那么这两个文件都会生成对应的路由注册代码。register.go 负责调用这两部分的路由注册函数。
+- biz/router/register.go:该文件负责调用不同 idl 生成的路由注册;比如我在两个 idl "demo1.thrift"、"demo2.thrift" 中都定义了 service,那么这两个文件都会生成对应的路由注册代码。register.go 负责调用这两部分的路由注册函数。
-基于上述描述,给出 router 在 update 时的行为描述:
+ 基于上述描述,给出 router 在 update 时的行为描述:
- biz/${namespace}/${idlName}.go: 每次都基于 idl 重新生成,用户不要改该文件代码,否则会丢失代码。
@@ -125,6 +125,6 @@ hz 在 new 的时候生成的 router 代码主要有如下三个:
### 使用 Windows 操作系统时的注意事项
-使用 `hz` 命令创建项目时将用到 `symlink`,在 Windows 操作系统下你可能需要 [开启开发者模式](https://learn.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) 来启用用户权限的 symlink
+使用 `hz` 命令创建项目时将用到 `symlink`,在 Windows 操作系统下你可能需要 [开启开发者模式](https://learn.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) 来启用用户权限的 symlink。
在基于 protobuf IDL 创建项目时,你需要手动安装 [protoc 命令行工具](https://github.com/protocolbuffers/protobuf/releases) 至 PATH 环境变量,另外如果你使用 `google/protobuf` 包下的文件,你需要将 protoc-win64.zip 中 include 目录下的所有文件放在 protoc 同一目录。
diff --git a/content/zh/docs/hertz/tutorials/toolkit/usage/command.md b/content/zh/docs/hertz/tutorials/toolkit/command.md
similarity index 92%
rename from content/zh/docs/hertz/tutorials/toolkit/usage/command.md
rename to content/zh/docs/hertz/tutorials/toolkit/command.md
index ede0c56d40..59ff00b234 100644
--- a/content/zh/docs/hertz/tutorials/toolkit/usage/command.md
+++ b/content/zh/docs/hertz/tutorials/toolkit/command.md
@@ -17,7 +17,7 @@ USAGE:
hz [global options] command [command options] [arguments...]
VERSION:
- 0.0.1
+ 0.x.x
COMMANDS:
new Generate a new Hertz project
@@ -63,7 +63,7 @@ OPTIONS:
--protoc value, -p value Specify arguments for the protoc. ({flag}={value}) (accepts multiple inputs)
--service value Specify the service name.
--snake_tag Use snake_case style naming for tags. (Only works for 'form', 'query', 'json') (default: false)
- --thriftgo value, -t value Specify arguments for the thriftgo. ({flag}={value}) (accepts mul
+ --thriftgo value, -t value Specify arguments for the thriftgo. ({flag}={value}) (accepts mul)
```
- client_dir: 指定 client 侧代码的生成路径,如果不指定则不生成;当前为每个 service 生成一个全局的 client,后续会提供更丰富的 client 代码能力
@@ -134,7 +134,7 @@ OPTIONS:
-- unset_omitempty: 当 idl 为 protobuf 时,生成 model field,去掉 omitempty tag;当 idl 为 thrift 时,是否添加 omitempty 根据 field 是 "optional"还是"required"决定
+- unset_omitempty: 当 idl 为 protobuf 时,生成 model field,去掉 omitempty tag;当 idl 为 thrift 时,是否添加 omitempty 根据 field 是 "optional" 还是 "required" 决定
### Update
@@ -176,7 +176,7 @@ OPTIONS:
-- handler_dir: 指定 handler 的生成路径,默认为"biz/handler";注意:如果对同一套 idl 进行 update,需要 handler_dir 的值与使用 new 的时候相同,否则会生成冗余的代码,需要用户自行删除。
+- handler_dir: 指定 handler 的生成路径,默认为 "biz/handler";注意:如果对同一套 idl 进行 update,需要 handler_dir 的值与使用 new 的时候相同,否则会生成冗余的代码,需要用户自行删除。
@@ -188,7 +188,7 @@ OPTIONS:
-- model_dir: 指定 model 的生成路径,默认为"biz/model";注意:如果对同一套 idl 进行 update,需要 model_dir 的值与使用 new 的时候相同,否则会生成重复的 model 代码且导致 handler 引用不一致。
+- model_dir: 指定 model 的生成路径,默认为 "biz/model";注意:如果对同一套 idl 进行 update,需要 model_dir 的值与使用 new 的时候相同,否则会生成重复的 model 代码且导致 handler 引用不一致。
@@ -220,4 +220,4 @@ OPTIONS:
-- unset_omitempty: 当 idl 为 protobuf 时,生成 model field,去掉 mitempty tag;当 idl 为 thrift 时,是否添加 omitempty 根据 field 是 "optional"还是"required"决定
+- unset_omitempty: 当 idl 为 protobuf 时,生成 model field,去掉 mitempty tag;当 idl 为 thrift 时,是否添加 omitempty 根据 field 是 "optional" 还是 "required" 决定
diff --git a/content/zh/docs/hertz/tutorials/toolkit/usage/install.md b/content/zh/docs/hertz/tutorials/toolkit/install.md
similarity index 89%
rename from content/zh/docs/hertz/tutorials/toolkit/usage/install.md
rename to content/zh/docs/hertz/tutorials/toolkit/install.md
index c6c72e5bae..a43db15adf 100644
--- a/content/zh/docs/hertz/tutorials/toolkit/usage/install.md
+++ b/content/zh/docs/hertz/tutorials/toolkit/install.md
@@ -9,18 +9,18 @@ hz 是 Hertz 框架提供的一个用于生成代码的命令行工具。目前
## 安装
-1. 确保 `GOPATH` 环境变量已经被正确地定义(例如 `export GOPATH=~/go`)并且将`$GOPATH/bin`添加到 `PATH` 环境变量之中(例如 `export PATH=$GOPATH/bin:$PATH`);请勿将 `GOPATH` 设置为当前用户没有读写权限的目录
+1. 确保 `GOPATH` 环境变量已经被正确的定义(例如 `export GOPATH=~/go`)并且将`$GOPATH/bin`添加到 `PATH` 环境变量之中(例如 `export PATH=$GOPATH/bin:$PATH`);请勿将 `GOPATH` 设置为当前用户没有读写权限的目录
2. 安装 hz:
-```bash
-go install github.com/cloudwego/hertz/cmd/hz@latest
-```
+ ```bash
+ go install github.com/cloudwego/hertz/cmd/hz@latest
+ ```
3. 验证是否安装成功 `hz -v`, 如果显示如下版本的信息,则说明安装成功
-```console
-hz version v0.1.0
-```
+ ```console
+ hz version v0.x.x
+ ```
**注意**,由于 hz 会为自身的二进制文件创建软链接,因此请确保 hz 的安装路径具有可写权限。
@@ -30,7 +30,7 @@ hz version v0.1.0
hz 生成的代码里,一部分是底层的编译器生成的(通常是关于 IDL 里定义的结构体),另一部分是 IDL 中用户定义的路由、method 等信息。用户可直接运行该代码。
-从执行流上来说,当 hz 使用 thrift IDL 生成代码时,hz 会调用 thriftgo 来生成 go 结构体代码,并将自身作为 thriftgo 的一个插件(名为 thrift-gen-hertz)来执行来生成其他代码。当用于 protobuf IDL 时亦是如此。
+从执行流上来说,当 hz 使用 thrift IDL 生成代码时,hz 会调用 thriftgo 来生成 go 结构体代码,并将自身作为 thriftgo 的一个插件(名为 thrift-gen-hertz)来执行并生成其他代码。当用于 protobuf IDL 时亦是如此。
```console
$> hz ... --idl=IDL
diff --git a/content/zh/docs/hertz/tutorials/toolkit/usage/layout.md b/content/zh/docs/hertz/tutorials/toolkit/layout.md
similarity index 93%
rename from content/zh/docs/hertz/tutorials/toolkit/usage/layout.md
rename to content/zh/docs/hertz/tutorials/toolkit/layout.md
index db6b24d5d3..a6e192361f 100644
--- a/content/zh/docs/hertz/tutorials/toolkit/usage/layout.md
+++ b/content/zh/docs/hertz/tutorials/toolkit/layout.md
@@ -6,7 +6,7 @@ description: >
---
### 生成代码的结构
-hz 生成的代码结构都类似,下面以"基于 thrift IDL 创建项目"小节生成的代码结构为例,说明 hz 生成的代码的含义。
+hz 生成的代码结构都类似,下面以 [hz 使用 (thrift)](/zh/docs/hertz/tutorials/toolkit/usage/usage-thrift/) 小节生成的代码结构为例,说明 hz 生成的代码的含义。
```
.
diff --git a/content/zh/docs/hertz/tutorials/toolkit/more-feature/_index.md b/content/zh/docs/hertz/tutorials/toolkit/more-feature/_index.md
index 4e90bdac98..11a2630ffc 100644
--- a/content/zh/docs/hertz/tutorials/toolkit/more-feature/_index.md
+++ b/content/zh/docs/hertz/tutorials/toolkit/more-feature/_index.md
@@ -1,5 +1,5 @@
---
title: "更多特性"
-weight: 2
+weight: 9
description: >
---
diff --git a/content/zh/docs/hertz/tutorials/toolkit/usage/usage-protobuf.md b/content/zh/docs/hertz/tutorials/toolkit/usage-protobuf.md
similarity index 99%
rename from content/zh/docs/hertz/tutorials/toolkit/usage/usage-protobuf.md
rename to content/zh/docs/hertz/tutorials/toolkit/usage-protobuf.md
index 30519aeff4..d72f8d06de 100644
--- a/content/zh/docs/hertz/tutorials/toolkit/usage/usage-protobuf.md
+++ b/content/zh/docs/hertz/tutorials/toolkit/usage-protobuf.md
@@ -227,7 +227,7 @@ description: >
在"biz/handler/hello/hello_service.go" 下新增了新的方法
在"biz/handler/hello" 下新增了文件 "new_service.go" 以及对应的 "Method3" 方法。
- 下面我们来开发 "Method2" 接口
+ 下面我们来开发 "Method2" 接口:
```go
// Method1 .
diff --git a/content/zh/docs/hertz/tutorials/toolkit/usage/usage-thrift.md b/content/zh/docs/hertz/tutorials/toolkit/usage-thrift.md
similarity index 99%
rename from content/zh/docs/hertz/tutorials/toolkit/usage/usage-thrift.md
rename to content/zh/docs/hertz/tutorials/toolkit/usage-thrift.md
index 3aebd9cf3d..6653e94e8a 100644
--- a/content/zh/docs/hertz/tutorials/toolkit/usage/usage-thrift.md
+++ b/content/zh/docs/hertz/tutorials/toolkit/usage-thrift.md
@@ -162,7 +162,7 @@ description: >
在 "biz/handler/hello/example/hello_service.go" 下新增了新的方法
在 "biz/handler/hello/example" 下新增了文件 "new_service.go" 以及对应的 "NewMethod" 方法。
- 下面我们来开发 "OtherMethod" 接口
+ 下面我们来开发 "OtherMethod" 接口:
```go
// HelloMethod .
diff --git a/content/zh/docs/hertz/tutorials/toolkit/usage/usage.md b/content/zh/docs/hertz/tutorials/toolkit/usage.md
similarity index 100%
rename from content/zh/docs/hertz/tutorials/toolkit/usage/usage.md
rename to content/zh/docs/hertz/tutorials/toolkit/usage.md
diff --git a/content/zh/docs/hertz/tutorials/toolkit/usage/_index.md b/content/zh/docs/hertz/tutorials/toolkit/usage/_index.md
deleted file mode 100644
index 9f6c91b0c0..0000000000
--- a/content/zh/docs/hertz/tutorials/toolkit/usage/_index.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-title: "hz 使用方法"
-weight: 1
-description: >
----