generator

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DifficultyEasy difficulty = iota
	DifficultyMedium
	DifficultyHard
)
View Source
const (
	TplSourceMarkdownName = "source_markdown"
	TplIndexMarkdownName  = "index"
)

Variables

View Source
var TplIndexMarkdown = `` /* 137-byte string literal not displayed */
View Source
var TplSourceMarkdown = `` /* 490-byte string literal not displayed */

Functions

func LoadTemplates

func LoadTemplates(out *Templates, list map[string]string) error

func WriteReadme

func WriteReadme(w io.Writer, tpl *template.Template, data any) error

WriteReadme ...

Types

type GenerationResult

type GenerationResult struct {
	// contains filtered or unexported fields
}

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator is the main structure responsible for readme generation from different sources of problems.

func NewGenerator

func NewGenerator(
	outputDir string,
	templates *Templates,
	sp StructureProvider,
	pp []Provider,
	options ...Option,
) *Generator

NewGenerator returns new algo source readme generator.

func (*Generator) GenerateReadme

func (g *Generator) GenerateReadme(ctx context.Context) error

GenerateReadme ...

type Option added in v0.0.2

type Option func(g *Generator)

func HideUnsolvedProblems added in v0.0.2

func HideUnsolvedProblems() Option

HideUnsolvedProblems returns option to be set for generator to hide unsolved problems.

type OverloadTemplate

type OverloadTemplate func(parsed *template.Template, t *Templates)

type Problem

type Problem struct {
	ID int64 `json:"id"`

	URL   string `json:"url"` // external URL of problem
	Slug  string `json:"slug"`
	Title string `json:"title"`

	Difficulty difficulty `json:"diff"`

	Solutions []SolutionFile `json:"-"`
	IsSolved  bool           `json:"-"`
	// contains filtered or unexported fields
}

type ProblemsGroup added in v0.0.2

type ProblemsGroup struct {
	Title string
	Stats Stats
}

func GroupByLevel added in v0.0.2

func GroupByLevel(s Stats) []ProblemsGroup

type ProblemsProvider

type ProblemsProvider interface {
	// GetAllProblems returns list of all problems of algo Provider no matter solved they or not.
	GetAllProblems(ctx context.Context) ([]Problem, error)
}

ProblemsProvider - source of single source of algorithmic problems. E.g. - leetcode, hackerrank, etc.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(name string, cacheDir string, base ProblemsProvider) Provider

func (*Provider) GetAllProblems

func (p *Provider) GetAllProblems(ctx context.Context) ([]Problem, error)

type RenderFormatter

type RenderFormatter interface {
	// FormatOutput formats list of problems and outputs bytes content to be written as w of
	// readme.
	FormatOutput(ctx context.Context, source Source) ([]byte, error)
}

type Solution

type Solution struct {
	ProblemUID    string
	BasePath      string
	SolutionFiles []string
}

type SolutionFile

type SolutionFile struct {
	Filename string
	Filepath string
	Lang     string
}

type Source

type Source struct {
	Name  string
	Stats Stats
}

type Stats added in v0.0.2

type Stats struct {
	Solved int64
	// contains filtered or unexported fields
}

func (Stats) Problems added in v0.0.2

func (s Stats) Problems() []Problem

func (Stats) SolvedPercentString added in v0.0.3

func (s Stats) SolvedPercentString() string

func (Stats) Total added in v0.0.2

func (s Stats) Total() int

type StructureProvider

type StructureProvider interface {
	GetSolvedProblems(ctx context.Context, sourceName string) ([]Solution, error)
	GetProblemUID(p Problem) string
}

StructureProvider is the source that knows directory & files structure of all solved problems.

type TemplateSource

type TemplateSource struct {
	Title string
	Path  string
}

type Templates

type Templates struct {
	Source, Index *template.Template
}

Jump to

Keyboard shortcuts

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