tableau icon indicating copy to clipboard operation
tableau copied to clipboard

YAML: support yaml

Open wenchy opened this issue 2 years ago • 0 comments

Syntax v1

Solution 1

---
#@sheet @TABLEAU # doc's first line is sheet name line.
LiteConf:
  Sheet: LiteConf
  OrderedMap: true
LoaderConf:
  Sheet: LoaderConf
 
---
#@sheet LiteConf
RulerLite: #@type LiteInfo
  CacheExpire: 2h #@type duration
  MaxBatchNum: 50 #@type int32
GuildLite: #@type LiteInfo
  CacheExpire: 2h  #@type duration
  MaxBatchNum: 50  #@type int32

---
#@sheet LoaderConf
Servers: #@type map<string, Server>
  gamesvr:
    Name: gamesvr #@type string
    Confs:  #@type map<string, Conf>
      ItemConf: 
        Async: true #@type bool
      DropConf:
        Async: true #@type bool
  mailsvr:
    Name: mailsvr
    Confs: 
      ItemConf: 
        Async: true
      DropConf:
        Async: true

Solution 2

---
"@TABLEAU":
  - Sheet: LiteConf
    OrderedMap: true
  - Sheet: LoaderConf

---
LiteConf:
  RulerLite: #@type RulerLite
    CacheExpire: 2h #@type duration
    MaxBatchNum: 50 #@type int32
  GuildLite: #@type LiteInfo
    CacheExpire: 2h  #@type duration
    MaxBatchNum: 50  #@type uint64

---
LoaderConf:
  Server: #@type map<string, Server>
    gamesvr:
      Name: gamesvr #@type string
      Conf:  #@type map<string, Conf>
        ItemConf:
          Async: true #@type bool
        DropConf:
          Async: true #@type bool
    mailsvr:
      Name: mailsvr
      Confs:
        ItemConf:
          Async: true
        DropConf:
          Async: true

Generated proto

message LiteConf {
  option (tableau.worksheet) = {name:"LiteConf"};

  LiteInfo ruler_lite= 1 [(tableau.field) = {name:"RulerLite"}];
  message LiteInfo {
    google.protobuf.Duration cache_expire = 1 [(tableau.field) = {name:"CacheExpire"}];
    int32 max_batch_num= 2 [(tableau.field) = {name:"MaxBatchNum"}];
  }
  LiteInfo guild_lite= 1 [(tableau.field) = {name:"GuildLite"}];
}

message LoaderConf {
  option (tableau.worksheet) = {name:"LoaderConf"};

  map<string, Server> server_map = 1 [(tableau.field) = {key:"Key"}];
  message Server {
    string key = 1 [(tableau.field) = {name:"Key"}];
    string name = 2 [(tableau.field) = {name:"Name"}];
    map<string, Conf> conf_map= 3 [(tableau.field) = {name:"Confs" key:"Confs"}];
      message Conf {
        string key = 1 [(tableau.field) = {name:"Key"}];
        bool async= 2 [(tableau.field) = {name:"Async"}];
      }
  }
}

wenchy avatar Apr 03 '23 04:04 wenchy