genprotocol

package
v0.0.0-...-73cb9a3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

README

genprotocol

Package genprotocol generates the TypeScript codes from Microsoft/language-server-protocol/specification.md markdown.

Documentation

Overview

Package genprotocol generates the TypeScript codes from Microsoft/language-server-protocol/specification.md markdown.

The "gitlab.com/golang-commonmark/markdown" AST are:

*markdown.HeadingOpen
  *markdown.Inline
*markdown.HeadingClose

*markdown.ParagraphOpen
  *markdown.Inline
*markdown.ParagraphClose

*markdown.BulletListOpen
  *markdown.ListItemOpen
    *markdown.ParagraphOpen
      *markdown.Inline
    *markdown.ParagraphClose
  *markdown.ListItemClose
*markdown.BulletListClose

*markdown.BlockquoteOpen
  *markdown.ParagraphOpen
    *markdown.Inline
  *markdown.ParagraphClose
*markdown.BlockquoteClose

*markdown.Fence
*markdown.CodeBlock

*markdown.OrderedListOpen
  *markdown.ListItemOpen
    *markdown.ParagraphOpen
      *markdown.Inline
    *markdown.ParagraphClose
  *markdown.ListItemClose
*markdown.OrderedListClose

*markdown.TableOpen
  *markdown.TheadOpen
    *markdown.TrOpen
      *markdown.ThOpen
        *markdown.Inline
      *markdown.ThClose
    *markdown.TrClose
  *markdown.TheadClose

  *markdown.TbodyOpen
    *markdown.TrOpen
      *markdown.TdOpen
        *markdown.ThClose
          *markdown.Inline
        *markdown.TdClose
      *markdown.TrClose
    *markdown.TbodyClose
*markdown.TableClose

*markdown.Hr

Index

Constants

View Source
const HeaderLevel = 3

HeaderLevel needs headers comment heading level.

View Source
const (
	// SpecificationMarkdownURI is the Microsoft/language-server-protocol/specification.md markdown uri.
	SpecificationMarkdownURI = "https://github.com/Microsoft/language-server-protocol/raw/gh-pages/specification.md"
)

Variables

View Source
var CommonInitialisms = map[string]bool{
	"ACL":   true,
	"API":   true,
	"ASCII": true,
	"CPU":   true,
	"CSS":   true,
	"DNS":   true,
	"EOF":   true,
	"GUID":  true,
	"HTML":  true,
	"HTTP":  true,
	"HTTPS": true,
	"ID":    true,
	"IP":    true,
	"JSON":  true,
	"LHS":   true,
	"QPS":   true,
	"RAM":   true,
	"RHS":   true,
	"RPC":   true,
	"SLA":   true,
	"SMTP":  true,
	"SQL":   true,
	"SSH":   true,
	"TCP":   true,
	"TLS":   true,
	"TTL":   true,
	"UDP":   true,
	"UI":    true,
	"UID":   true,
	"UUID":  true,
	"URI":   true,
	"URL":   true,
	"UTF8":  true,
	"VM":    true,
	"XML":   true,
	"XMPP":  true,
	"XSRF":  true,
	"XSS":   true,
}

CommonInitialisms is a set of common initialisms. Only add entries that are highly unlikely to be non-initialisms. For instance, "ID" is fine (Freudian code is rare), but "AND" is not.

This code copied from golang.org/x/lint/lint.go

https://github.com/golang/lint/blob/5614ed5bae6fb75893070bdc0996a68765fdd275/lint.go#L768-L810
View Source
var IgnoreFences = map[string]bool{
	`{
    start: { line: 5, character: 23 },
    end : { line 6, character : 0 }
}
`: true,
	`{ language: 'typescript', scheme: 'file' }
{ language: 'json', pattern: '**/package.json' }
`: true,
}

IgnoreFences map of ignore Fences codes map.

View Source
var IgnoreHeaders = map[string]bool{
	"$ Notifications and Requests": true,
	"Goto Declaration Request":     true,
	"Goto Definition Request":      true,
	"Goto Type Definition Request": true,
	"Goto Implementation Request":  true,
}

IgnoreHeaders ignores header comment map.

View Source
var InlineReplacer = strings.NewReplacer(
	"`", "",
	"\n", " ",
)

InlineReplacer replacer of inline code block.

Functions

func ExpandHTML

func ExpandHTML(s string) string

ExpandHTML expands the HTML links from s.

func Getspecification

func Getspecification(uri string) ([]byte, error)

GetSpec gets the specification.md.

func SplitComment

func SplitComment(comment string) string

func ToLowerCamelCase

func ToLowerCamelCase(s string) string

ToLowerCamelCase converts s to LowerCamelCase.

Types

type Parser

type Parser struct {
	Tokens    []markdown.Token
	TokenPos  int
	PrevToken markdown.Token

	TypeScriptFuncs   []*TypeScriptFunc
	TypeScriptFuncPos int
}

Parser represents a specification markdown parser.

func (*Parser) Parse

func (p *Parser) Parse(tokens []markdown.Token)

Parse parses the specification.md.

func (*Parser) ParseComment

func (p *Parser) ParseComment(src string)

func (*Parser) ParseFence

func (p *Parser) ParseFence(tok *markdown.Fence)

ParseFence parses markdown Fence codes.

func (*Parser) ParseHeading

func (p *Parser) ParseHeading(tok *markdown.HeadingOpen)

ParseHeading parses the markdown.Heading.

func (*Parser) ParseInline

func (p *Parser) ParseInline(tok *markdown.Inline)

ParseInline parses inline markdown text.

func (*Parser) ParseParagraph

func (p *Parser) ParseParagraph(tok *markdown.ParagraphOpen)

ParseParagraph parses markdown Paragraph text.

type TypeScriptFunc

type TypeScriptFunc struct {
	Comment string
	Src     string
}

TypeScriptFunc represents a typescript function.

Jump to

Keyboard shortcuts

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