Documentation ¶
Index ¶
- Variables
- func GetSolutionCode(q *leetcode.QuestionData) (string, error)
- func IsDepUpdateToDate(lang Lang) (bool, error)
- func RunLocalTest(q *leetcode.QuestionData, targetCase string) (bool, error)
- func UpdateDep(lang Lang) error
- func UpdateSolutionCode(q *leetcode.QuestionData, newCode string) error
- type FileOutput
- type FileType
- type GenerateResult
- type JudgeResult
- type Judger
- type Lang
- type LocalTestable
- type ModifierFunc
- type Range
- type TestCase
- type TestCases
Constants ¶
This section is empty.
Variables ¶
var (
SupportedLangs = []Lang{
golangGen,
python3Gen,
cppGen,
rustGen,
javaGen,
jsGen,
tsGen,
phpGen,
cGen,
csharpGen,
rubyGen,
swiftGen,
kotlinGen,
bashGen,
mysqlGen,
mssqlGen,
oraclesqlGen,
erlangGen,
racketGen,
scalaGen,
elixirGen,
dartGen,
}
)
Functions ¶
func GetSolutionCode ¶
func GetSolutionCode(q *leetcode.QuestionData) (string, error)
GetSolutionCode retrieves the solution code from the generated code file.
func IsDepUpdateToDate ¶ added in v1.4.2
func RunLocalTest ¶
func RunLocalTest(q *leetcode.QuestionData, targetCase string) (bool, error)
func UpdateSolutionCode ¶ added in v0.2.2
func UpdateSolutionCode(q *leetcode.QuestionData, newCode string) error
UpdateSolutionCode updates the solution code in the generated code file.
Types ¶
type FileOutput ¶
type FileOutput struct { Filename string Type FileType Content string Written bool // contains filtered or unexported fields }
func GetFileOutput ¶ added in v1.3.9
func GetFileOutput(q *leetcode.QuestionData, fileType FileType) (*FileOutput, error)
GetFileOutput returns the file output for the given question and file type.
func (*FileOutput) GetContent ¶ added in v1.3.1
func (f *FileOutput) GetContent() (string, error)
func (*FileOutput) GetPath ¶ added in v1.3.1
func (f *FileOutput) GetPath() string
type GenerateResult ¶
type GenerateResult struct { Question *leetcode.QuestionData Lang Lang OutDir string SubDir string Files []FileOutput ResultHooks []func(*GenerateResult) error // contains filtered or unexported fields }
func Generate ¶
func Generate(q *leetcode.QuestionData) (*GenerateResult, error)
Generate generates the code for the given question.
func GenerateContest ¶
func GenerateContest(ct *leetcode.Contest) ([]*GenerateResult, error)
GenerateContest generates the code for all questions in the given contest.
func GeneratePathsOnly ¶
func GeneratePathsOnly(q *leetcode.QuestionData) (*GenerateResult, error)
GeneratePathsOnly runs generate process but only returns the paths of generated files, without writing them.
func (*GenerateResult) AddFile ¶ added in v1.3.1
func (r *GenerateResult) AddFile(f FileOutput) *GenerateResult
func (*GenerateResult) GetFile ¶ added in v1.3.1
func (r *GenerateResult) GetFile(typ FileType) *FileOutput
func (*GenerateResult) SetOutDir ¶ added in v1.3.1
func (r *GenerateResult) SetOutDir(dir string)
func (*GenerateResult) TargetDir ¶ added in v1.3.1
func (r *GenerateResult) TargetDir() string
type JudgeResult ¶ added in v1.3.1
type Judger ¶ added in v1.3.1
type Judger interface {
Judge(input []string, output, actualOutput string) JudgeResult
}
func GetJudger ¶ added in v1.3.1
func GetJudger(q *leetcode.QuestionData) Judger
type Lang ¶
type Lang interface { // Name returns the full name of the language. e.g. "C++", "JavaScript", "Python" Name() string // ShortName returns the short name of the language. e.g. "cpp", "js", "py" ShortName() string // Slug returns the slug of the language. e.g. "cpp", "javascript", "python3" Slug() string // InitWorkspace initializes the language workspace for code running. InitWorkspace(dir string) error // Generate generates code files for the question. Generate(q *leetcode.QuestionData) (*GenerateResult, error) // GeneratePaths generates the paths of the code files for the question, without generating the real files. GeneratePaths(q *leetcode.QuestionData) (*GenerateResult, error) }
Lang is a basic generator for a language.
func GetGenerator ¶
GetGenerator returns the generator for the given language. If the language is not supported, an error will be returned. The language can be specified by slug, short name or prefix of full name.
type LocalTestable ¶
type LocalTestable interface { // RunLocalTest runs local test for the question. RunLocalTest(q *leetcode.QuestionData, outDir string, targetCase string) (bool, error) }
LocalTestable is an interface for languages that can run local test.
type ModifierFunc ¶ added in v0.1.6
type ModifierFunc = func(string, *leetcode.QuestionData) string
type TestCase ¶ added in v1.3.1
type TestCase struct { Question *leetcode.QuestionData No int Input []string Output string }
func (*TestCase) InputString ¶ added in v1.3.1
type TestCases ¶ added in v1.3.1
type TestCases struct { Cases []TestCase Question *leetcode.QuestionData }
func ParseTestCases ¶ added in v1.3.1
func ParseTestCases(q *leetcode.QuestionData, f *FileOutput) (TestCases, error)