formattree

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package formattree knows the layout of the folder of the module format, spec.Format: where its examples and test vectors lie, of which kind each case is, what a case folder holds, and which folders are laid out as a module and which files are files of a part on their own, as the format text lays them out. The vector test and the tests of the module check take it from here, so that a place where a new tag of spec puts a case comes to all of them at once. Only tests import it.

Index

Constants

View Source
const (
	KindValidExample   = "examples/valid"
	KindInvalidExample = "examples/invalid"
	KindModuleExample  = "examples/module"
	KindRules          = "rules"
	KindOpenView       = "open-view"
	KindVerdicts       = "verdicts"
	KindLeaks          = "leaks"
	KindPages          = "pages"
	KindRandom         = "random"
	KindTemplates      = "templates"
	KindTiers          = "tiers"
	KindPackages       = "packages"
	KindIndexes        = "indexes"
	KindVersions       = "versions"
)

The kinds of the cases, as Classify gives them: of an example by its folder, and of a vector by the folder of vectors/ that holds it.

View Source
const (
	CaseModule    = "module"    // of packages/ and versions/: the module, laid out as a module
	CaseModules   = "modules"   // of indexes/: a folder laid out as a module for each module
	CasePublished = "published" // of versions/: a folder for each published version
	CasePackage   = "package.yaml"
	CaseIndex     = "index.yaml"
	CaseVersion   = "version.yaml"
	CasePart      = "part.yaml" // of open-view/: the part whose open view the case gives
	CaseOpenView  = "open-view.yaml"
	CaseDigest    = "digest.yaml"
)

The things a case folder holds, by their names.

View Source
const CoursePart = "course"

CoursePart is the term of a course, which is no part of a module's layout: its examples and the vectors of its rule are files of their own.

Variables

View Source
var ExampleParts = slices.Concat(LayoutParts, []string{CoursePart, "inventory", "module-index"})

ExampleParts are the parts that have examples of their own, each with its schema: the parts of a module's layout, a course, the inventory of a package and the module index.

FileVectors are the vectors whose cases are files.

FolderVectors are the vectors whose cases are folders of their own kind, by the things each folder holds and nothing else, in order.

View Source
var LayoutParts = []string{"lesson", "manifest", "reading-list", "skill-graph", "solving-steps", "task", "techniques", "traps"}

LayoutParts are the parts of a module's layout, whose open views have vectors.

View Source
var VerdictKinds = []string{"choice", "fraction", "number", "predicate", "time"}

VerdictKinds are the check kinds that give verdicts, by the names of their folders; rubric gives none.

Functions

func Classify

func Classify(name string) (casePath, kind string, known bool)

Classify says where a file of spec.Format belongs: the path of its case within the folder and the case's kind; no kind for a file of no case — the text, VERSION, page.yaml, areas.yaml and the schemas —; and false for a file of no kind it knows.

func Modules

func Modules(fsys fs.FS) (map[string]string, error)

Modules gives the folders of fsys, a tree laid out as spec.Format is, that are laid out as a module, each with the rule it is a case of, or "" for a module that breaks no rule: an example of a whole module, a case of a rule that is a folder, the module of a case of packages/ and of versions/, each module of a case of indexes/, and each published version of a case of versions/ that is laid out as a module.

func OpenViewFiles

func OpenViewFiles(part string) []string

OpenViewFiles are the files a case of the open view of part holds, and nothing else, in order.

func PartFiles

func PartFiles(fsys fs.FS) (map[string]PartFile, error)

PartFiles gives the files of fsys, a tree laid out as spec.Format is, that are files of a part of a module's layout on their own, by their paths: the examples of the parts of the layout, the cases in a file of the rule of such a part, and the parts of the vectors of the open view. A case of a rule yaml.* is a file that the YAML reader alone reads, of no part, and a case of a rule course.* is a course, which is no part of a module.

func RuleFolder

func RuleFolder(name string) bool

RuleFolder says whether name is a folder of rules/: the ID of a format rule. The rules of the module index and of versions of a module have their vectors among those of indexes and versions.

Types

type PartFile

type PartFile struct {
	Part, Rule, Kind string
}

A PartFile is a file of a part of a module's layout on its own: the term of its part, the rule it is a case of, or "", and the kind of its case.

Jump to

Keyboard shortcuts

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