Skip to content

Commit

Permalink
docs: 优化 README.md 的测试用例描述
Browse files Browse the repository at this point in the history
  • Loading branch information
kercylan98 committed Jan 15, 2024
1 parent a026e4c commit 580bab2
Show file tree
Hide file tree
Showing 20 changed files with 351 additions and 151 deletions.
3 changes: 2 additions & 1 deletion game/space/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ space 游戏中常见的空间设计,例如房间、地图等
<span id="NewRoomManager"></span>
> 创建房间管理器 RoomManager 的实例
示例代码:
**示例代码:**

```go

func ExampleNewRoomManager() {
Expand Down
9 changes: 6 additions & 3 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ func TestNewBot(t *testing.T) {
<span id="New"></span>
> 根据特定网络类型创建一个服务器
示例代码:
**示例代码:**

```go

func ExampleNew() {
Expand Down Expand Up @@ -351,7 +352,8 @@ func TestNew(t *testing.T) {
<span id="BindService"></span>
> 绑定服务到特定 Server,被绑定的服务将会在 Server 初始化时执行 Service.OnInit 方法
示例代码:
**示例代码:**

```go

func ExampleBindService() {
Expand Down Expand Up @@ -860,7 +862,8 @@ type Server struct {
> - server.NetworkWebsocket (addr:":8888/ws")
> - server.NetworkKcp (addr:":8888")
> - server.NetworkNone (addr:"")
示例代码:
**示例代码:**

```go

func ExampleServer_Run() {
Expand Down
6 changes: 4 additions & 2 deletions server/internal/dispatcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
<span id="NewDispatcher"></span>
> 创建一个新的消息分发器 Dispatcher 实例
示例代码:
**示例代码:**

```go

func ExampleNewDispatcher() {
Expand Down Expand Up @@ -111,7 +112,8 @@ func TestNewDispatcher(t *testing.T) {
<span id="NewManager"></span>
> 生成消息分发器管理器
示例代码:
**示例代码:**

```go

func ExampleNewManager() {
Expand Down
15 changes: 10 additions & 5 deletions server/router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
<span id="NewMultistage"></span>
> 创建一个支持多级分类的路由器
示例代码:
**示例代码:**

```go

func ExampleNewMultistage() {
Expand Down Expand Up @@ -76,7 +77,8 @@ type Multistage[HandleFunc any] struct {
#### func (*Multistage) Register(routes ...any) MultistageBind[HandleFunc]
> 注册路由是结合 Sub 和 Route 的快捷方式,用于一次性注册多级路由
> - 该函数将返回一个注册函数,可通过调用其将路由绑定到特定处理函数,例如:router.Register("a", "b").Bind(onExec())
示例代码:
**示例代码:**

```go

func ExampleMultistage_Register() {
Expand All @@ -90,7 +92,8 @@ func ExampleMultistage_Register() {
***
#### func (*Multistage) Route(route any, handleFunc HandleFunc)
> 为特定路由绑定处理函数,被绑定的处理函数将可以通过 Match 函数进行匹配
示例代码:
**示例代码:**

```go

func ExampleMultistage_Route() {
Expand All @@ -105,7 +108,8 @@ func ExampleMultistage_Route() {
#### func (*Multistage) Match(routes ...any) HandleFunc
> 匹配已绑定处理函数的路由,返回处理函数
> - 如果未找到将会返回空指针
示例代码:
**示例代码:**

```go

func ExampleMultistage_Match() {
Expand Down Expand Up @@ -154,7 +158,8 @@ func TestMultistage_Match(t *testing.T) {
***
#### func (*Multistage) Sub(route any) *Multistage[HandleFunc]
> 获取子路由器
示例代码:
**示例代码:**

```go

func ExampleMultistage_Sub() {
Expand Down
3 changes: 2 additions & 1 deletion server/writeloop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
>
> 传入 writeHandler 的消息对象是从 pool 中获取的,并且在 writeHandler 执行完成后会被放回 pool 中,因此 writeHandler 不应该持有消息对象的引用,同时也不应该主动释放消息对象
示例代码:
**示例代码:**

```go

func ExampleNewUnbounded() {
Expand Down

0 comments on commit 580bab2

Please sign in to comment.