ref

package
v0.0.0-...-0bd99a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sanitize

func Sanitize[T ~string](text T) string

Types

type Arg

type Arg struct {
	Name string // The name of the argument.
	Desc string // A brief description of the argument.
}

An Arg describes the name and description of a function argument.

type Entry

type Entry struct {
	// The shorthand name of the function(s), without any suffix, etc.
	//
	// For example, the following functions would all be defined within the "glUniform" entry:
	//
	//  - glUniform2d
	//  - glUniform3fv
	//  - glUniformMatrix4fv
	Name string `json:"name"`
	// Desc is the description/summary for all functions covered within this entry. This is typically a brief single
	// sentence, often without a subject and/or ending punctuation.
	//
	// For example, the entry for "glGet" reads verbatim as: "return the value or values of a selected parameter"
	Desc string `json:"desc"`
	// Description of each OpenGL function this entry pertains to. These functions describe the full names of actual
	// functions as they are defined in the OpenGL specification.
	Funcs []Function `json:"functions"`
	// Documentation for function parameters, using name as key and summary as value.
	//
	// Unlike the Desc field, these are typically full sentences. Any inner XML or links are flattened to only provide
	// the text value. Newlines and tabs used for formatting on a webpage are stripped.
	Params map[string]string `json:"params"`
	// Contains the names of other related functions.
	SeeAlso []string `json:"seealso"`
	// Possible error value constants OpenGL will emit when using this function.
	Errors []string `json:"errors"`
}

A Entry describes a simplified reference page of the OpenGL spec, intended for providing brief inline documentation.

func LoadEntry

func LoadEntry(path string) (*Entry, error)

LoadEntry returns a new Entry loaded from the XML file at the given path.

func NewEntry

func NewEntry(r io.Reader) (*Entry, error)

NewEntry returns a new Entry from the given reader.

func (*Entry) Func

func (entry *Entry) Func(name string) (fn Function, ok bool)

Func returns the function definition with the given name and flag indicating if it was found.

func (*Entry) UnmarshalXML

func (entry *Entry) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements the xml.Unmarshaler interface.

type Function

type Function struct {
	// The OpenGL name of the function.
	Name string `xml:"funcdef>function" json:"name"`
	// The ordered list of names for the function arguments.
	Args []string `xml:"paramdef>parameter" json:"args"`
}

A Function describes the prototype and parameter names/types of an OpenGL function.

func (*Function) String

func (fn *Function) String() string

String implements the fmt.Stringer interface.

type Spec

type Spec struct {
	Name    string            // The name of the specification (i.e. "gl4", "es3.0", etc).
	Entries map[string]*Entry // Documentation entries defined in the specification.
}

A Spec defines the reference documentation sources for an OpenGL API and version.

func LoadSpec

func LoadSpec(base, name string) (spec Spec, err error)

LoadSpec returns a new Spec loaded from the specified base and child directory name.

type Text

type Text string

A Text object captures the inner XML as text, but also flattens nested elements into their inner text value.

func (*Text) UnmarshalXML

func (text *Text) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements the xml.Unmarshaler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL