Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Source:

// https://discourse.gohugo.io/t/range-length-or-last-element/3803/2

{{ $list := (where .Site.Pages "Section" "docs") -}}
{{ $list := (where .Site.AllPages "Section" "docs") -}}
{{ $len := (len $list) -}}

index.add(
Expand Down
32 changes: 26 additions & 6 deletions config/_default/menus/menus.zh.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,42 @@
identifier = "prologue"
url = "/docs/prologue/"

[[docs]]
name = "帮助"
weight = 60
identifier = "help"
url = "/docs/help/"
# [[docs]]
# name = "帮助"
# weight = 60
# identifier = "help"
# url = "/docs/help/"

[[main]]
name = "文档"
url = "/docs/prologue/introduction/"
# url = "/docs/1.0/prologue/introduction/"
weight = 10

[[main]]
name = "教程"
weight = 20
identifier = "tutorial"
url = "/docs/prologue/introduction/"

[[main]]
name = "简介"
weight = 310
identifier = "introduction"
url = "/docs/prologue/introduction/"
parent = "tutorial"

[[main]]
name = "快速开始"
weight = 320
identifier = "quick-start"
url = "/docs/prologue/quick-start/"
parent = "tutorial"

[[main]]
name = "博客"
url = "/blog/"
weight = 20
weight = 30

[[social]]
name = "GitHub"
Expand Down
2 changes: 1 addition & 1 deletion content/en/docs/help/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Help Tableau."
lead: ""
date: 2020-10-06T08:49:15+08:00
lastmod: 2020-10-06T08:49:15+08:00
draft: false
draft: true
images: []
weight: 1000
---
9 changes: 9 additions & 0 deletions content/zh/docs/api/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title : "API"
description: "API 指南。"
date: 2022-09-04T08:48:45+08:00
lastmod: 2022-09-04T08:48:45+08:00
draft: false
images: []
weight: 3000
---
10 changes: 10 additions & 0 deletions content/zh/docs/api/checker/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "检查器"
description: "检查器指南。"
lead: ""
date: 2022-03-10T08:00:00+08:00
lastmod: 2022-03-10T08:00:00+08:00
draft: false
images: []
weight: 3300
---
47 changes: 47 additions & 0 deletions content/zh/docs/api/checker/guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: "指南"
description: "Go 检查器指南。"
lead: "Go 检查器指南。"
date: 2022-03-10T08:00:00+08:00
lastmod: 2022-03-10T08:00:00+08:00
draft: false
images: []
weight: 300
toc: true
---

## 生成脚手架代码

例如,为 Protobuf 消息 `ItemConf` 生成的 `*.check.go` 文件内容如下:

```go
type ItemConf struct {
tableau.ItemConf
}

func (x *ItemConf) Check(hub *tableau.Hub) error {
// TODO: implement here.
return nil
}

func (x *ItemConf) CheckCompatibility(hub, newHub *tableau.Hub) error {
// TODO: implement here.
return nil
}

func init() {
// NOTE: This func is auto-generated. DO NOT EDIT.
register(func() tableau.Messager {
return new(ItemConf)
})
}
```

## 插件:protoc-gen-go-tableau-checker

使用此 protoc 插件的示例:
[checker/test/gen.sh](https://github.com/tableauio/checker/blob/master/test/gen.sh)。

## 完整示例

请查看 [go-tableau-checker](https://github.com/tableauio/checker/blob/master/test)。
10 changes: 10 additions & 0 deletions content/zh/docs/api/loader/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "加载器"
description: "加载器指南。"
lead: ""
date: 2022-03-10T08:00:00+08:00
lastmod: 2022-03-10T08:00:00+08:00
draft: false
images: []
weight: 3200
---
109 changes: 109 additions & 0 deletions content/zh/docs/api/loader/cpp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
title: "C++"
description: "C++ 加载器指南。"
lead: "C++ 加载器指南。"
date: 2022-03-10T08:00:00+08:00
lastmod: 2022-03-10T08:00:00+08:00
draft: false
images: []
weight: 3220
toc: true
---


## API

### Data

`const ProtobufMessage& Data()`

获取内部的 protobuf 消息数据。

### Map

`const MapValueType* Get(k1 KEY1, k2 KEY2...) const`

获取第 N 级的映射值。请注意,这仅适用于每个级别消息的**第一个映射字段**。

### OrderedMap

> 前提条件:你需要将元表选项 `OrderedMap` 设置为 `true`。
>
> 请参阅 [元表选项:OrderedMap](../../../excel/metasheet/#option-orderedmap)。

`const OrderedMapValueType* GetOrderedMap(k1 KEY1, k2 KEY2...) const`

获取第 N 级的有序映射值。请注意,这仅适用于每个级别消息的**第一个映射字段**。

### Index

> 前提条件:你需要适当设置元表选项 `Index`。
>
> 请参阅 [元表选项:Index](../../../excel/metasheet/#option-index)。

如果索引名称是 `Chapter`,则访问器如下:

- `const Index_ChapterMap& FindChapter() const`:获取整个哈希映射。
- `const vector<ParentType>* FindChapter(k1 KEY1, k2 KEY2...) const`:通过键查找值。一个键可能对应多个值,这些值通过向量返回。
- `const ParentType* FindFirstChapter(k1 KEY1, k2 KEY2...) const`:通过键查找第一个值。

### OrderedIndex

> 前提条件:你需要适当设置元表选项 `OrderedIndex`。
>
> 请参阅 [元表选项:OrderedIndex](../../../excel/metasheet/#option-orderedindex)。

如果有序索引名称是 `Chapter`,则访问器如下:

- `const OrderedIndex_ChapterMap& FindChapter() const`:获取整个有序映射。
- `const vector<ParentType>* FindChapter(k1 KEY1, k2 KEY2...) const`:通过键查找值。一个键可能对应多个值,这些值通过向量返回。
- `const ParentType* FindFirstChapter(k1 KEY1, k2 KEY2...) const`:通过键查找第一个值。

## 自定义消息器

如果内置 API 不足以满足你的业务逻辑,你可以添加一个自定义消息器,在其中可以基于加载的配置对象编写预处理逻辑。

示例:[cpp-tableau-loader/hub/custom](https://github.com/tableauio/loader/tree/master/test/cpp-tableau-loader/src/hub/custom)

**custom_xxx_conf.h**:

```cpp
#pragma once
#include "protoconf/hub.pc.h"
#include "protoconf/xxx_conf.pc.h"
class CustomXXXConf : public tableau::Messager {
public:
static const std::string& Name() { return kCustomName; };
virtual bool Load(const std::string& dir, tableau::Format fmt,
const tableau::LoadOptions* options = nullptr) override {
return true;
}
virtual bool ProcessAfterLoadAll(const tableau::Hub& hub) override;

private:
static const std::string kCustomName;
// TODO: 添加自定义数据字段。
};
```

**custom_xxx_conf.cpp**:

```cpp
#include "hub/custom/xxx/custom_xxx_conf.h"

const std::string CustomXXXConf::kCustomName = "CustomXXXConf";

bool CustomItemConf::ProcessAfterLoadAll(const tableau::Hub& hub) {
// TODO: 在此处实现。
return true;
}
```

## 插件:protoc-gen-cpp-tableau-loader

使用此 protoc 插件的示例:
[cpp-tableau-loader/gen.sh](https://github.com/tableauio/loader/blob/master/test/cpp-tableau-loader/gen.sh)。

## 完整示例

请查看 [cpp-tableau-loader](https://github.com/tableauio/loader/tree/master/test/cpp-tableau-loader)。
15 changes: 15 additions & 0 deletions content/zh/docs/api/loader/csharp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "C#"
description: "C# 加载器指南。"
lead: "C# 加载器指南。"
date: 2022-03-10T08:00:00+08:00
lastmod: 2022-03-10T08:00:00+08:00
draft: false
images: []
weight: 3240
toc: true
---

## 概述

TODO: 请参考 [Tableau 加载器](https://github.com/tableauio/loader)。
98 changes: 98 additions & 0 deletions content/zh/docs/api/loader/go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
title: "Go"
description: "Go 加载器指南。"
lead: "Go 加载器指南。"
date: 2022-03-10T08:00:00+08:00
lastmod: 2022-03-10T08:00:00+08:00
draft: false
images: []
weight: 3230
toc: true
---

## API

### Data

`func Data() *ProtobufMessage`

获取内部的 protobuf 消息数据。

### Map

`func GetN(k1 KEY1, k2 KEY2...) (*MapValueType, error)`

获取第 N 级的映射值。请注意,这仅适用于每个级别消息的**第一个映射字段**。

### OrderedMap

> 前提条件:你需要将元表选项 `OrderedMap` 设置为 `true`。
>
> 请参阅 [元表选项:OrderedMap](../../../excel/metasheet/#option-orderedmap)。

`func GetOrderedMapN(k1 KEY1, k2 KEY2...) (*OrderedMapValueType, error)`

获取第 N 级的有序映射值。请注意,这仅适用于每个级别消息的**第一个映射字段**。

### Index

> 前提条件:你需要适当设置元表选项 `Index`。
>
> 请参阅 [元表选项:Index](../../../excel/metasheet/#option-index)。

如果索引名称是 `Chapter`,则访问器如下:

- `func FindChapterMap() *Index_ChapterMap`:获取整个哈希映射。
- `func FindChapter(k1 KEY1, k2 KEY2...) []*ParentType`:通过键查找值。一个键可能对应多个值,这些值通过切片返回。
- `func FindFirstChapter(k1 KEY1, k2 KEY2...) *ParentType`:通过键查找第一个值。

### OrderedIndex

> 前提条件:你需要适当设置元表选项 `OrderedIndex`。
>
> 请参阅 [元表选项:OrderedIndex](../../../excel/metasheet/#option-orderedindex)。

如果有序索引名称是 `Chapter`,则访问器如下:

- `func FindChapterMap() *OrderedIndex_ChapterMap`:获取整个有序映射。
- `func FindChapter(k1 KEY1, k2 KEY2...) []*ParentType`:通过键查找值。一个键可能对应多个值,这些值通过切片返回。
- `func FindFirstChapter(k1 KEY1, k2 KEY2...) *ParentType`:通过键查找第一个值。

## 自定义消息器

如果内置 API 不足以满足你的业务逻辑,你可以添加一个自定义消息器,在其中可以基于加载的配置对象编写预处理逻辑。

示例:[go-tableau-loader/customconf](https://github.com/tableauio/loader/tree/master/test/go-tableau-loader/customconf)

**custom_xxx_conf.go**:

```go
type CustomXXXConf struct {
tableau.UnimplementedMessager
// TODO: 添加自定义数据字段。
}

func (x *CustomItemConf) Name() string {
return "CustomXXXConf"
}

func (x *CustomItemConf) ProcessAfterLoadAll(hub *tableau.Hub) error {
// TODO: 在此处实现。
return nil
}

func init() {
tableau.Register(func() tableau.Messager {
return new(CustomXXXConf)
})
}
```

## 插件:protoc-gen-go-tableau-loader

使用此 protoc 插件的示例:
[go-tableau-loader/gen.sh](https://github.com/tableauio/loader/blob/master/test/go-tableau-loader/gen.sh)。

## 完整示例

请查看 [go-tableau-loader](https://github.com/tableauio/loader/tree/master/test/go-tableau-loader)。
15 changes: 15 additions & 0 deletions content/zh/docs/api/loader/lua.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "Lua"
description: "Lua 加载器指南。"
lead: "Lua 加载器指南。"
date: 2022-03-10T08:00:00+08:00
lastmod: 2022-03-10T08:00:00+08:00
draft: false
images: []
weight: 3260
toc: true
---

## 概述

TODO: 请参考 [Tableau 加载器](https://github.com/tableauio/loader)。
Loading