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:
@@ -6,6 +6,22 @@ import (
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// Doc contains any documentation, if present. Example C code is excluded.
|
||||
type Doc struct {
|
||||
Brief string // short description
|
||||
Description string // long description
|
||||
Fields map[string]string // from field name to description
|
||||
Errors map[string]string // from error type to description
|
||||
}
|
||||
|
||||
// DescribeField is an accessor that supports nil receivers.
|
||||
func (d *Doc) DescribeField(name string) string {
|
||||
if d == nil {
|
||||
return ""
|
||||
}
|
||||
return d.Fields[name]
|
||||
}
|
||||
|
||||
// Request represents all XML 'request' nodes.
|
||||
// If the request doesn't have a reply, Reply is nil.
|
||||
type Request struct {
|
||||
@@ -15,6 +31,7 @@ type Request struct {
|
||||
Combine bool // Not currently used.
|
||||
Fields []Field // All fields in the request.
|
||||
Reply *Reply // A reply, if one exists for this request.
|
||||
Doc Doc // Documentation.
|
||||
}
|
||||
|
||||
type Requests []*Request
|
||||
@@ -126,6 +143,7 @@ func (r *Request) Size(c *Context) Size {
|
||||
// Reply encapsulates the fields associated with a 'reply' element.
|
||||
type Reply struct {
|
||||
Fields []Field
|
||||
Doc Doc
|
||||
}
|
||||
|
||||
// Size gets the number of bytes in this request's reply.
|
||||
|
||||
Reference in New Issue
Block a user