aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/go_request_reply.go
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2018-09-29 21:42:23 +0200
committerPřemysl Janouch <p@janouch.name>2018-09-30 17:34:26 +0200
commit3e9ed4eac6a953b2616bcf129b515a857271acdc (patch)
treeb7e674aa21fe3044eec6071e0d990c3933ba5f0d /nexgb/xgbgen/go_request_reply.go
parent0056720d05d72d7b3a1b3cbdae5b5c5d80e167d3 (diff)
downloadhaven-3e9ed4eac6a953b2616bcf129b515a857271acdc.tar.gz
haven-3e9ed4eac6a953b2616bcf129b515a857271acdc.tar.xz
haven-3e9ed4eac6a953b2616bcf129b515a857271acdc.zip
xgbgen: process <doc> elements
Most of XCB documentation now ends up in Go sources, although the end result is of mixed quality.
Diffstat (limited to 'nexgb/xgbgen/go_request_reply.go')
-rw-r--r--nexgb/xgbgen/go_request_reply.go28
1 files changed, 28 insertions, 0 deletions
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 "+