Documentation
¶
Overview ¶
Package sherpadoc contains types for reading and writing documentation for sherpa API's.
Index ¶
Constants ¶
const (
// SherpadocVersion is the sherpadoc version generated by this command.
SherpadocVersion = 1
)
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check walks the sherpa section and checks it for correctness. It checks for:
- Duplicate type names. - Duplicate parameter or return names. - References to types that are not defined. - Validity of typewords.
func IsBasicType ¶ added in v0.0.16
IsBasicType returns whether name is a basic type, like int32, string, any, timestamp, etc.
Types ¶
type Arg ¶
type Arg struct {
Name string // Name of the argument.
Typewords []string // Typewords is an array of tokens describing the type.
}
Arg is the name and type of a function parameter or return value.
Production rules:
basictype := "bool" | "int8", "uint8" | "int16" | "uint16" | "int32" | "uint32" | "int64" | "uint64" | "int64s" | "uint64s" | "float32" | "float64" | "string" | "timestamp"
array := "[]"
map := "{}"
identifier := [a-zA-Z][a-zA-Z0-9]*
type := "nullable"? ("any" | basictype | identifier | array type | map type)
It is not possible to have inline structs in an Arg. Those must be encoded as a named type.
type Function ¶
type Function struct {
Name string // Name of the function.
Docs string // Text or markdown, describing the function, its parameters, return types and possible errors.
Params []Arg
Returns []Arg
}
Function contains the documentation for a single function.
type Section ¶
type Section struct {
Name string // Name of an API section.
Docs string // Explanation of the API in text or markdown.
Functions []*Function // Functions in this section.
Sections []*Section // Subsections, each with their own documentation.
Structs []Struct // Structs as named types.
Ints []Ints // Int enums as named types.
Strings []Strings // String enums used as named types.
Version string `json:",omitempty"` // Version if this API, only relevant for the top-level section of an API. Typically filled in by server at startup.
SherpaVersion int // Version of sherpa this API implements. Currently at 0. Typically filled in by server at startup.
SherpadocVersion int `json:",omitempty"` // Version of the sherpadoc format. Currently at 1, the first defined version. Only relevant for the top-level section of an API.
}
Section represents documentation about a Sherpa API section, as returned by the "_docs" function.
type StringValue ¶ added in v0.0.18
type Strings ¶
type Strings struct {
Name string
Docs string
Values []StringValue
}
Strings is a type representing an enum with strings as values.