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 ¶
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.
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.
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 ¶
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.
var FileVectors = []string{KindLeaks, KindPages, KindRandom, KindTemplates, KindTiers}
FileVectors are the vectors whose cases are files.
var FolderVectors = map[string][]string{ KindPackages: {CaseModule, CasePackage}, KindIndexes: {CaseIndex, CaseModules}, KindVersions: {CaseModule, CasePublished, CaseVersion}, }
FolderVectors are the vectors whose cases are folders of their own kind, by the things each folder holds and nothing else, in order.
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.
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 ¶
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 ¶
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 ¶
OpenViewFiles are the files a case of the open view of part holds, and nothing else, in order.
func PartFiles ¶
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 ¶
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.