apislurp

package module
v0.0.0-...-08e03ce Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: LGPL-3.0 Imports: 9 Imported by: 0

README

apislurp

pipeline coverage godoc

A small Discord documentation parser.

Coverage

This package covers the structures inside discord-api-docs/resources/ as well as the Gateway.md file inside discord-api-docs/topics/.

Usage

Refer to internal/tests/{resources,topics}/.

License

apislurp is licensed under the Lesser GNU General Public License version 3.0 (LGPLv3). As a special exception (regardless if LGPLv3 covers this or not), all code generated using apislurp may be licensed without restriction. This includes proprietary licenses. In other words, the use of apislurp makes no requirements about the licenses of generated code.

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Document

type Document struct {
	Structures []Structure
}

Document represents a single Markdown page.

func Parse

func Parse(md []byte) Document

Parse parses the given raw Markdown text into a Document.

type Field

type Field struct {
	Name        string
	RawName     string
	Type        Type
	Optional    bool
	Description string
}

Field is a single field inside a structure, typically represented by a table row.

func NewField

func NewField(name, desc string, t Type) Field

NewField creates a new field from the given parameters taken from a table row.

type Structure

type Structure struct {
	Name    string
	RawName string
	Type    StructureType
	Fields  []Field
}

Structure is a single structure, typically represented by a Markdown table.

func NewStructure

func NewStructure(rawName string) Structure

NewStructure creates a new structure from the raw name taken from a table cell. If the structure type cannot be derived from the given name, then a zero-value Structure is returned.

type StructureType

type StructureType string
const (
	StructureObject     StructureType = "Structure"
	StructureEvent      StructureType = "Event Fields"
	StructureProperties StructureType = "Properties"
)

type Type

type Type struct {
	Names     []TypeName // or types
	Array     bool
	ArraySize int // 0 == slice/not an array
	Nullable  bool
	RawText   string
}

Type represents a type for each field. Types may be duplicated or slightly different from other types elsewhere in other fields and structures.

func NewType

func NewType(typeField, description string) Type

NewType creates a new normalized Type instance from the given raw type name. If description is not empty, then the function will try and parse the new type from it if the type is "array".

type TypeName

type TypeName string

TypeName represents a short, normalized type name. These names are normalized on a best effort basis; they may not cover every single edge case in the documentation. As such, one shouldn't rely on the uniqueness of those names too much and instead handle unknown type names (edge cases) appropriately.

const (
	TypeSnowflake TypeName = "snowflake"
	TypeString    TypeName = "string"
	TypeInteger   TypeName = "integer" // also "int"
	TypeBoolean   TypeName = "boolean"
	TypeArray     TypeName = "array" // use ParseTypeName to handle this.
	TypeMixed     TypeName = "mixed"
	TypeObject    TypeName = "object" // this is a thing and I don't know why.
	TypeImageData TypeName = "image data"
	TypeTimestamp TypeName = "ISO8601 timestamp"
)

Primitives.

const (
	TypeUser               TypeName = "user"
	TypeRole               TypeName = "role"
	TypeEmoji              TypeName = "emoji"
	TypeParty              TypeName = "party"
	TypeAssets             TypeName = "assets"
	TypeAccount            TypeName = "account"
	TypeWebhook            TypeName = "webhook"
	TypeSecrets            TypeName = "secrets"
	TypeActivity           TypeName = "activity"
	TypeReaction           TypeName = "reaction"
	TypeOverwrite          TypeName = "overwrite"
	TypeAttachment         TypeName = "attachment"
	TypeTimestamps         TypeName = "timestamps"
	TypeApplication        TypeName = "application"
	TypeVoiceState         TypeName = "voice state"
	TypeClientStatus       TypeName = "client_status"
	TypeUpdateStatus       TypeName = "update status"
	TypeAllowedMentionType TypeName = "allowed mention type"

	TypePresence       TypeName = "presence"
	TypePresenceUpdate TypeName = "presence update"

	TypeIntegration               TypeName = "integration"
	TypeIntegrationExpireBehavior TypeName = "integration expire behavior"

	TypeChannel        TypeName = "channel"
	TypeChannelMention TypeName = "channel mention"

	TypeGuild            TypeName = "guild"
	TypeGuildMember      TypeName = "guild member" // also "member"
	TypeGuildFeature     TypeName = "guild feature"
	TypeUnavailableGuild TypeName = "unavailable guild"

	TypeMessage            TypeName = "message"
	TypeMessageActivity    TypeName = "message activity"
	TypeMessageReference   TypeName = "message reference"
	TypeMessageApplication TypeName = "message application"

	TypeEmbed          TypeName = "embed"
	TypeEmbedFooter    TypeName = "embed footer"
	TypeEmbedImage     TypeName = "embed image"
	TypeEmbedThumbnail TypeName = "embed thumbnail"
	TypeEmbedVideo     TypeName = "embed video"
	TypeEmbedProvider  TypeName = "embed provider"
	TypeEmbedAuthor    TypeName = "embed author"
	TypeEmbedField     TypeName = "embed field"

	TypeAuditLog       TypeName = "audit log"
	TypeAuditLogEvent  TypeName = "audit log event"
	TypeAuditLogEntry  TypeName = "audit log entry"
	TypeAuditLogChange TypeName = "audit log change"
	TypeAuditEntryInfo TypeName = "audit entry info"
)

Object Types.

func ParseTypeName

func ParseTypeName(fname string) (tname TypeName, array bool, arraySize int)

ParseTypeName parses an individual type name. It does NOT split on "or" words. An empty TypeName is returned if parsing fails.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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