lang

package
v0.1.6-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// TODO scala, typescript, erlang, dart, racket
	SupportedLangs = []Lang{
		golangGen,
		python3Gen,
		cppGen,
		rustGen,
		javaGen,
		jsGen,
		phpGen,
		cGen,
		csharpGen,
		rubyGen,
		swiftGen,
		kotlinGen,
		bashGen,
		mysqlGen,
		mssqlGen,
		oraclesqlGen,
	}
)

Functions

func GetSolutionCode

func GetSolutionCode(q *leetcode.QuestionData) (string, error)

func RunLocalTest

func RunLocalTest(q *leetcode.QuestionData) (bool, error)

Types

type FileOutput

type FileOutput struct {
	Path    string
	Content string
	Written bool
	Type    FileType
}

type FileType

type FileType int
const (
	CodeFile FileType = iota
	TestFile
	DocFile
	OtherFile
)

type GenerateResult

type GenerateResult struct {
	Question *leetcode.QuestionData
	Lang     Lang
	Files    []FileOutput
}

func Generate

func Generate(q *leetcode.QuestionData) (*GenerateResult, error)

func GenerateContest

func GenerateContest(ct *leetcode.Contest) ([]*GenerateResult, error)

func GeneratePathsOnly

func GeneratePathsOnly(q *leetcode.QuestionData) (*GenerateResult, error)

GeneratePathsOnly runs generate process but does not generate real content.

func (*GenerateResult) GetCodeFile

func (r *GenerateResult) GetCodeFile() *FileOutput

func (*GenerateResult) PrependPath

func (r *GenerateResult) PrependPath(dir string)

type Lang

type Lang interface {
	Name() string
	ShortName() string
	Slug() string
	LineComment() string
	// Generate generates code files for the question.
	Generate(q *leetcode.QuestionData) (*GenerateResult, error)
	GeneratePaths(q *leetcode.QuestionData) (*GenerateResult, error)
}

func GetGenerator

func GetGenerator(lang string) (Lang, error)

type LocalTestable

type LocalTestable interface {
	RunLocalTest(q *leetcode.QuestionData, dir string) (bool, error)
}

type ModifierFunc added in v0.1.6

type ModifierFunc func(string, *leetcode.QuestionData) string

type NeedInitialization

type NeedInitialization interface {
	HasInitialized(dir string) (bool, error)
	Initialize(dir string) error
}

Jump to

Keyboard shortcuts

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