doctree

package
v0.0.0-...-8353322 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2016 License: MIT Imports: 8 Imported by: 0

README

Documentation Structure

This package contains structs and code defining how protobuf documentation will be represented within this program, and code for the creation, navigation and serialization of these structures.

Documentation

Overview

Doctree, which stands for "documentation tree", creates a tree of nodes representing the components of a service defined through Protobuf definition files. The tree is composed of nodes fulfilling the `Describable` interface, with the root node fulfilling the `Doctree` interface. The `Doctree` interface is a superset of the `Describable` interface.

The main entrypoint for the Doctree package is the `New` function, which takes a Protobuf `CodeGeneratorRequest` struct and creates a Doctree representing all the documentation from the `CodeGeneratorRequest`.

For a larger explanation of how and why Doctree is structured the way it is, see the comment for the 'associateComments' function in the source code of the 'associate_comments.go' file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssociateComments

func AssociateComments(dt Doctree, req *plugin.CodeGeneratorRequest)

Types

type BindingField

type BindingField struct {
	Describable
	Name        string
	Description string
	Kind        string
	Value       string
}

BindingField represents a single field within an `option` annotation for an rpc method. For example, an rpc method may have an http annotation with fields like `get: "/example/path"`. Each of those fields is represented by a `BindingField`. The `Kind` field is the left side of the option field, and the `Value` is the right hand side of the option field.

func (*BindingField) Describe

func (self *BindingField) Describe(depth int) string

func (*BindingField) GetByName

func (self *BindingField) GetByName(s string) Describable

func (*BindingField) GetDescription

func (self *BindingField) GetDescription() string

func (*BindingField) GetName

func (self *BindingField) GetName() string

func (*BindingField) SetDescription

func (self *BindingField) SetDescription(d string)

func (*BindingField) SetName

func (self *BindingField) SetName(s string)

type Describable

type Describable interface {
	// The "Name" of this describable
	GetName() string
	SetName(string)
	// GetDescription returns the description of this describable
	GetDescription() string
	SetDescription(string)
	// describe causes a Describable to generate a string representing itself.
	// The integer argument is used as the 'depth' that this Describable sits
	// within a tree of Describable structs, allowing it to print its
	// information with proper indentation. If called recursively, allows for
	// printing of a structured tree-style view of a tree of Describables.
	Describe(int) string

	// GetByName allows one to query a Describable to see if it has a child
	// Describable in any of its collections.
	GetByName(string) Describable
	// contains filtered or unexported methods
}

Describable offers an interface for traversing a Doctree and finding information from the nodes within it.

type Doctree

type Doctree interface {
	Describable
	SetComment([]string, string)
	String() string
	Markdown() string
}

Doctree is the root interface for this package, and is chiefly implemented by MicroserviceDefinition. See MicroserviceDefinition for further documentation on these Methods.

type EnumValue

type EnumValue struct {
	Describable
	Name        string
	Description string
	Number      int
}

func (*EnumValue) Describe

func (self *EnumValue) Describe(depth int) string

func (*EnumValue) GetDescription

func (self *EnumValue) GetDescription() string

func (*EnumValue) GetName

func (self *EnumValue) GetName() string

func (*EnumValue) SetDescription

func (self *EnumValue) SetDescription(d string)

func (*EnumValue) SetName

func (self *EnumValue) SetName(s string)

type FieldType

type FieldType struct {
	Describable
	Name        string
	Description string
	Enum        *ProtoEnum
}

func (*FieldType) Describe

func (self *FieldType) Describe(depth int) string

func (*FieldType) GetByName

func (self *FieldType) GetByName(s string) Describable

func (*FieldType) GetDescription

func (self *FieldType) GetDescription() string

func (*FieldType) GetName

func (self *FieldType) GetName() string

func (*FieldType) SetDescription

func (self *FieldType) SetDescription(d string)

func (*FieldType) SetName

func (self *FieldType) SetName(s string)

type HttpParameter

type HttpParameter struct {
	Describable
	Name        string
	Description string
	Location    string
	Type        string
}

HttpParameter contains information for one parameter of an http binding. It is created by contextualizing all of the `BindingField`'s within a `MethodHttpBinding`, with each `HttpParameter` corresponding to one of the fields in the input message for the given rpc method. It's type is the protobuf type of the field of the struct it's refering to.

func (*HttpParameter) Describe

func (self *HttpParameter) Describe(depth int) string

func (*HttpParameter) GetByName

func (self *HttpParameter) GetByName(s string) Describable

func (*HttpParameter) GetDescription

func (self *HttpParameter) GetDescription() string

func (*HttpParameter) GetName

func (self *HttpParameter) GetName() string

func (*HttpParameter) SetDescription

func (self *HttpParameter) SetDescription(d string)

func (*HttpParameter) SetName

func (self *HttpParameter) SetName(s string)

type MessageField

type MessageField struct {
	Describable
	Name        string
	Description string
	Type        FieldType
	Number      int
	// Label is one of either "LABEL_OPTIONAL", "LABEL_REPEATED", or
	// "LABEL_REQUIRED"
	Label string
}

func (*MessageField) Describe

func (self *MessageField) Describe(depth int) string

func (*MessageField) GetByName

func (self *MessageField) GetByName(s string) Describable

func (*MessageField) GetDescription

func (self *MessageField) GetDescription() string

func (*MessageField) GetName

func (self *MessageField) GetName() string

func (*MessageField) SetDescription

func (self *MessageField) SetDescription(d string)

func (*MessageField) SetName

func (self *MessageField) SetName(s string)

type MethodHttpBinding

type MethodHttpBinding struct {
	Describable
	Name        string
	Description string
	Verb        string
	Path        string
	Fields      []*BindingField
	Params      []*HttpParameter
}

func (*MethodHttpBinding) Describe

func (self *MethodHttpBinding) Describe(depth int) string

func (*MethodHttpBinding) GetByName

func (self *MethodHttpBinding) GetByName(s string) Describable

func (*MethodHttpBinding) GetDescription

func (self *MethodHttpBinding) GetDescription() string

func (*MethodHttpBinding) GetName

func (self *MethodHttpBinding) GetName() string

func (*MethodHttpBinding) SetDescription

func (self *MethodHttpBinding) SetDescription(d string)

func (*MethodHttpBinding) SetName

func (self *MethodHttpBinding) SetName(s string)

type MicroserviceDefinition

type MicroserviceDefinition struct {
	Describable
	Name        string
	Description string
	Files       []*ProtoFile
}

MicroserviceDefinition is the root node for any particular `Doctree`

func (*MicroserviceDefinition) Describe

func (self *MicroserviceDefinition) Describe(depth int) string

func (*MicroserviceDefinition) GetByName

func (self *MicroserviceDefinition) GetByName(name string) Describable

GetByName returns any ProtoFile structs it my have with a matching `Name`.

func (*MicroserviceDefinition) GetDescription

func (self *MicroserviceDefinition) GetDescription() string

func (*MicroserviceDefinition) GetName

func (self *MicroserviceDefinition) GetName() string

func (*MicroserviceDefinition) Markdown

func (self *MicroserviceDefinition) Markdown() string

func (*MicroserviceDefinition) SetComment

func (self *MicroserviceDefinition) SetComment(namepath []string, comment_body string)

SetComment changes the node at the given 'name-path' to have a description of `comment_body`. `name-path` is a series of names of describable objects each found within the previous, accessed by recursively calling `GetByName` on the result of the last call, beginning with this MicroserviceDefinition. Once the final Describable object is found, the `description` field of that struct is set to `comment_body`.

func (*MicroserviceDefinition) SetDescription

func (self *MicroserviceDefinition) SetDescription(d string)

func (*MicroserviceDefinition) SetName

func (self *MicroserviceDefinition) SetName(s string)

func (*MicroserviceDefinition) String

func (self *MicroserviceDefinition) String() string

String kicks off the recursive call to `describe` within the tree of Describables, returning a string showing the structured view of the tree.

type ProtoEnum

type ProtoEnum struct {
	Describable
	Name        string
	Description string
	Values      []*EnumValue
}

func (*ProtoEnum) Describe

func (self *ProtoEnum) Describe(depth int) string

func (*ProtoEnum) GetDescription

func (self *ProtoEnum) GetDescription() string

func (*ProtoEnum) GetName

func (self *ProtoEnum) GetName() string

func (*ProtoEnum) SetDescription

func (self *ProtoEnum) SetDescription(d string)

func (*ProtoEnum) SetName

func (self *ProtoEnum) SetName(s string)

type ProtoFile

type ProtoFile struct {
	Describable
	Name        string
	Description string
	Messages    []*ProtoMessage
	Enums       []*ProtoEnum
	Services    []*ProtoService
}

func (*ProtoFile) Describe

func (self *ProtoFile) Describe(depth int) string

func (*ProtoFile) GetByName

func (self *ProtoFile) GetByName(name string) Describable

func (*ProtoFile) GetDescription

func (self *ProtoFile) GetDescription() string

func (*ProtoFile) GetName

func (self *ProtoFile) GetName() string

func (*ProtoFile) SetDescription

func (self *ProtoFile) SetDescription(d string)

func (*ProtoFile) SetName

func (self *ProtoFile) SetName(s string)

type ProtoMessage

type ProtoMessage struct {
	Describable
	Name        string
	Description string
	Fields      []*MessageField
}

func (*ProtoMessage) Describe

func (self *ProtoMessage) Describe(depth int) string

func (*ProtoMessage) GetByName

func (self *ProtoMessage) GetByName(name string) Describable

func (*ProtoMessage) GetDescription

func (self *ProtoMessage) GetDescription() string

func (*ProtoMessage) GetName

func (self *ProtoMessage) GetName() string

func (*ProtoMessage) SetDescription

func (self *ProtoMessage) SetDescription(d string)

func (*ProtoMessage) SetName

func (self *ProtoMessage) SetName(s string)

type ProtoService

type ProtoService struct {
	Describable
	Name               string
	Description        string
	Methods            []*ServiceMethod
	FullyQualifiedName string
}

func (*ProtoService) Describe

func (self *ProtoService) Describe(depth int) string

func (*ProtoService) GetByName

func (self *ProtoService) GetByName(name string) Describable

func (*ProtoService) GetDescription

func (self *ProtoService) GetDescription() string

func (*ProtoService) GetName

func (self *ProtoService) GetName() string

func (*ProtoService) SetDescription

func (self *ProtoService) SetDescription(d string)

func (*ProtoService) SetName

func (self *ProtoService) SetName(s string)

type ServiceMethod

type ServiceMethod struct {
	Describable
	Name         string
	Description  string
	RequestType  *ProtoMessage
	ResponseType *ProtoMessage
	HttpBindings []*MethodHttpBinding
}

func (*ServiceMethod) Describe

func (self *ServiceMethod) Describe(depth int) string

func (*ServiceMethod) GetByName

func (self *ServiceMethod) GetByName(name string) Describable

func (*ServiceMethod) GetDescription

func (self *ServiceMethod) GetDescription() string

func (*ServiceMethod) GetName

func (self *ServiceMethod) GetName() string

func (*ServiceMethod) SetDescription

func (self *ServiceMethod) SetDescription(d string)

func (*ServiceMethod) SetName

func (self *ServiceMethod) SetName(s string)

Directories

Path Synopsis
Makedt is a package for exposing the creation of a doctree structure.
Makedt is a package for exposing the creation of a doctree structure.
googlethirdparty
Package google_api is a generated protocol buffer package.
Package google_api is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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