From 3e9ed4eac6a953b2616bcf129b515a857271acdc Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sat, 29 Sep 2018 21:42:23 +0200 Subject: xgbgen: process elements Most of XCB documentation now ends up in Go sources, although the end result is of mixed quality. --- nexgb/xgbgen/go_request_reply.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'nexgb/xgbgen/go_request_reply.go') diff --git a/nexgb/xgbgen/go_request_reply.go b/nexgb/xgbgen/go_request_reply.go index fead79a..1c0ce14 100644 --- a/nexgb/xgbgen/go_request_reply.go +++ b/nexgb/xgbgen/go_request_reply.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "sort" "strings" ) @@ -12,6 +13,33 @@ func (r *Request) Define(c *Context) { c.Putln("*xgb.Cookie") c.Putln("}") c.Putln("") + + if r.Doc.Description != "" { + c.PutComment(r.Doc.Description) + c.Putln("//") + } + + allErrors := make([]string, 0, len(r.Doc.Errors)) + for kind := range r.Doc.Errors { + allErrors = append(allErrors, kind) + } + sort.Strings(allErrors) + + undocErrors := make([]string, 0) + for _, kind := range allErrors { + if desc := r.Doc.Errors[kind]; desc == "" { + undocErrors = append(undocErrors, kind) + } else { + c.PutComment(fmt.Sprintf("May return a %s error if %s%s", kind, + strings.ToLower(desc[:1]), desc[1:])) + c.Putln("//") + } + } + if len(undocErrors) > 0 { + c.Putln("// May return %s errors.", strings.Join(undocErrors, ", ")) + c.Putln("//") + } + if r.Reply != nil { c.Putln("// %s sends a checked request.", r.SrcName()) c.Putln("// If an error occurs, it will be returned with the reply "+ -- cgit v1.2.3-70-g09d2