Documentation

Overview

    Package parse parses Protocol Buffers.

    Index

    Constants

    This section is empty.

    Variables

    View Source
    var (
    	ProtoTypes = [...]string{
    		"double",
    		"float",
    		"int32",
    		"int64",
    		"uint32",
    		"uint64",
    		"sint32",
    		"sint64",
    		"fixed32",
    		"fixed64",
    		"sfixed32",
    		"sfixed64",
    		"bool",
    		"string",
    		"bytes",
    	}
    
    	ToCpp = map[ProtoType]string{
    		Double:   "double",
    		Float:    "float",
    		Int32:    "int32",
    		Int64:    "int64",
    		Uint32:   "uint32",
    		Uint64:   "uint64",
    		Sint32:   "int32",
    		Sint64:   "int64",
    		Fixed32:  "uint32",
    		Fixed64:  "uint64",
    		Sfixed32: "int32",
    		Sfixed64: "int64",
    		Bool:     "bool",
    		String:   "string",
    		Bytes:    "string",
    	}
    
    	ToJava = map[ProtoType]string{
    		Double:   "double",
    		Float:    "float",
    		Int32:    "int",
    		Int64:    "long",
    		Uint32:   "int",
    		Uint64:   "long",
    		Sint32:   "int",
    		Sint64:   "long",
    		Fixed32:  "int",
    		Fixed64:  "long",
    		Sfixed32: "int32",
    		Sfixed64: "int64",
    		Bool:     "boolean",
    		String:   "String",
    		Bytes:    "ByteString",
    	}
    
    	ToPython = map[ProtoType]string{
    		Double:   "float",
    		Float:    "float",
    		Int32:    "int",
    		Int64:    "int/long",
    		Uint32:   "int/long",
    		Uint64:   "int/long",
    		Sint32:   "int",
    		Sint64:   "int/long",
    		Fixed32:  "int",
    		Fixed64:  "int/long",
    		Sfixed32: "int",
    		Sfixed64: "int/long",
    		Bool:     "boolean",
    		String:   "str/unicode",
    		Bytes:    "str",
    	}
    
    	ToGo = map[ProtoType]string{
    		Double:   "float64",
    		Float:    "float32",
    		Int32:    "int32",
    		Int64:    "int64",
    		Uint32:   "uint32",
    		Uint64:   "uint64",
    		Sint32:   "int32",
    		Sint64:   "int64",
    		Fixed32:  "uint32",
    		Fixed64:  "uint64",
    		Sfixed32: "int32",
    		Sfixed64: "int64",
    		Bool:     "bool",
    		String:   "string",
    		Bytes:    "[]byte",
    	}
    
    	ToRuby = map[ProtoType]string{
    		Double:   "Float",
    		Float:    "Float",
    		Int32:    "Fixnum or Bignum (as required)",
    		Int64:    "Bignum",
    		Uint32:   "Fixnum or Bignum (as required)",
    		Uint64:   "Bignum",
    		Sint32:   "Fixnum or Bignum (as required)",
    		Sint64:   "Bignum",
    		Fixed32:  "Fixnum or Bignum (as required)",
    		Fixed64:  "Bignum",
    		Sfixed32: "Fixnum or Bignum (as required)",
    		Sfixed64: "Bignum",
    		Bool:     "TrueClass/FalseClass",
    		String:   "String (UTF-8)",
    		Bytes:    "String (ASCII-8BIT)",
    	}
    
    	ToCsharp = map[ProtoType]string{
    		Double:   "double",
    		Float:    "float",
    		Int32:    "int",
    		Int64:    "long",
    		Uint32:   "uint",
    		Uint64:   "ulong",
    		Sint32:   "int",
    		Sint64:   "long",
    		Fixed32:  "uint",
    		Fixed64:  "ulong",
    		Sfixed32: "int",
    		Sfixed64: "long",
    		Bool:     "bool",
    		String:   "string",
    		Bytes:    "ByteString",
    	}
    )

      https://developers.google.com/protocol-buffers/docs/proto3#scalar

      Functions

      This section is empty.

      Types

      type ParseOption

      type ParseOption int
      const (
      	ParseService ParseOption = iota
      	ParseMessage
      )

      type Proto

      type Proto struct {
      	Services []ProtoService
      	Messages []ProtoMessage
      }

        Proto represents sets of 'ProtoMessage' and 'ProtoService'.

        func ReadDir

        func ReadDir(targetDir, messageOnlyFromThisFile string) (*Proto, error)

        func ReadFile

        func ReadFile(fpath string) (*Proto, error)

        func (*Proto) Markdown

        func (p *Proto) Markdown(title string, parseOpts []ParseOption, lopts ...string) (string, error)

          Markdown saves 'Proto' to markdown documentation. lopts are a slice of language options (C++, Java, Python, Go, Ruby, C#).

          func (*Proto) Sort

          func (p *Proto) Sort()

          type ProtoField

          type ProtoField struct {
          	Name                 string
          	Description          string
          	Repeated             bool
          	ProtoType            ProtoType
          	UserDefinedProtoType string
          }

            ProtoField represent member fields in ProtoMessage.

            type ProtoMessage

            type ProtoMessage struct {
            	FilePath    string
            	Name        string
            	Description string
            	Fields      []ProtoField
            }

              ProtoMessage represents the 'message' type in Protocol Buffer. (https://developers.google.com/protocol-buffers/docs/proto3#simple)

              type ProtoMethod

              type ProtoMethod struct {
              	Name         string
              	Description  string
              	RequestType  string
              	ResponseType string
              }

                ProtoMethod represents methods in ProtoService.

                type ProtoService

                type ProtoService struct {
                	FilePath    string
                	Name        string
                	Description string
                	Methods     []ProtoMethod
                }

                  ProtoService represents the 'service' type in Protocol Buffer. (https://developers.google.com/protocol-buffers/docs/proto3#services)

                  type ProtoType

                  type ProtoType int

                    https://developers.google.com/protocol-buffers/docs/proto3#scalar

                    const (
                    	Double ProtoType = iota
                    	Float
                    	Int32
                    	Int64
                    	Uint32
                    	Uint64
                    	Sint32
                    	Sint64
                    	Fixed32
                    	Fixed64
                    	Sfixed32
                    	Sfixed64
                    	Bool
                    	String
                    	Bytes
                    )

                    func ToProtoType

                    func ToProtoType(s string) (ProtoType, error)

                      ToProtoType parses string to return 'ProtoType'.

                      func (ProtoType) Cpp

                      func (t ProtoType) Cpp() string

                      func (ProtoType) Csharp

                      func (t ProtoType) Csharp() string

                      func (ProtoType) Go

                      func (t ProtoType) Go() string

                      func (ProtoType) Java

                      func (t ProtoType) Java() string

                      func (ProtoType) Python

                      func (t ProtoType) Python() string

                      func (ProtoType) Ruby

                      func (t ProtoType) Ruby() string

                      func (ProtoType) String

                      func (t ProtoType) String() string