Code optimized (#523)

* optimized markdown generator

* optimized markdown generator

* optimized markdown generator

* add more comment

* add comment

* add comment

* add comments for rpc tool

* add comments for model tool

* add comments for model tool

* add comments for model tool

* add comments for config tool

* add comments for config tool

* add comments

* add comments

* add comments

* add comments

* add comment

* remove rpc main head info

* add comment

* optimized

Co-authored-by: anqiansong <anqiansong@xiaoheiban.cn>
This commit is contained in:
kingxt
2021-02-26 16:11:47 +08:00
committed by GitHub
parent ef146cf5ba
commit e6ef1fca12
104 changed files with 651 additions and 375 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/api/parser/g4/gen/api"
)
// KvExpr describes key-value for api
type KvExpr struct {
Key Expr
Value Expr
@@ -13,6 +14,7 @@ type KvExpr struct {
CommentExpr Expr
}
// VisitKvLit implements from api.BaseApiParserVisitor
func (v *ApiVisitor) VisitKvLit(ctx *api.KvLitContext) interface{} {
var kvExpr KvExpr
kvExpr.Key = v.newExprWithToken(ctx.GetKey())
@@ -48,11 +50,13 @@ func (v *ApiVisitor) VisitKvLit(ctx *api.KvLitContext) interface{} {
return &kvExpr
}
// Format provides a formatter for api command, now nothing to do
func (k *KvExpr) Format() error {
// todo
return nil
}
// Equal compares whether the element literals in two KvExpr are equal
func (k *KvExpr) Equal(v interface{}) bool {
if v == nil {
return false
@@ -70,10 +74,12 @@ func (k *KvExpr) Equal(v interface{}) bool {
return k.Key.Equal(kv.Key) && k.Value.Equal(kv.Value)
}
// Doc returns the document of KvExpr, like // some text
func (k *KvExpr) Doc() []Expr {
return k.DocExpr
}
// Comment returns the comment of KvExpr, like // some text
func (k *KvExpr) Comment() Expr {
return k.CommentExpr
}