xgbgen: process <doc> elements

Most of XCB documentation now ends up in Go sources,
although the end result is of mixed quality.
This commit is contained in:
2018-09-29 21:42:23 +02:00
parent 0056720d05
commit 3e9ed4eac6
9 changed files with 187 additions and 24 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"log"
"sort"
"strings"
)
// Context represents the protocol we're converting to Go, and a writer
@@ -34,6 +35,13 @@ func (c *Context) Put(format string, v ...interface{}) {
}
}
// PutComment writes each line of comment commented out to 'out'.
func (c *Context) PutComment(comment string) {
for _, line := range strings.Split(comment, "\n") {
c.Putln("// %s", line)
}
}
// Morph is the big daddy of them all. It takes in an XML byte slice,
// parse it, transforms the XML types into more usable types,
// and writes Go code to the 'out' buffer.