module

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 20 Imported by: 1 module, 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 module reads an author's module and checks it as the module format says: its layout and the version of the format it names, each file against the schema of its part, and the format rules of each part, between parts and of the whole module — the tiers of the skill graph, the templates with every instance and solver, and the leak check of the texts a learner sees before solving among them (format/README.md, sections 2 and 4–24). A breach names the ID of its rule and its place. The CLI's check and build call it, and module-registry from stage 4 (architecture 3.6).

The epic of code brings it part by part (R16). It holds so far the folder of a module as an fs.FS, by the layout of section 10 and the rules module.*; the format version of section 2 and manifest.format-version; the YAML rules of section 4 on each file of a part, by internal/yaml (R22); each file of a part against the schema of its part, by internal/schema, with a breach of a schema named by its keyword and place as section 8 names it (R23); the rules of the manifest, the skill graph and the catalogs of sections 11, 12, 16 and 17, read on the types of formatv0, with the tiers of the skill graph, Tiers, which the package will hold (R25); and the rules of a task and of a lesson of sections 14, 15 and 21 that need no check kind, no leak check and no template (R26); the rules of a task that the check of an answer slot sees itself, by package verdict (R27, R28); task.no-leaks and lesson.no-leaks, by package leak (R30); and the rules of templates of section 23, by package template, with the rules of a task on every instance of a template that read its strings, and task.instances, which holds each instance to the schema of a task (R32).

Index

Examples

Constants

View Source
const (
	RuleManifest      = "module.manifest"
	RuleLayout        = "module.layout"
	RuleFileIDs       = "module.file-ids"
	RuleMedia         = "module.media"
	RuleLicense       = "module.license"
	RulePlainText     = "module.plain-text"
	RuleFormatVersion = "manifest.format-version"
)

The rules the check holds, by the part a breach of each is reported in (format/README.md, sections 10 and 11).

View Source
const (
	RuleTaskChoiceKey           = "task.choice-key"
	RuleTaskChoiceOptions       = "task.choice-options"
	RuleTaskFractionKey         = "task.fraction-key"
	RuleTaskTrapValues          = "task.trap-values"
	RuleTaskPredicateExpression = "task.predicate-expression"
)

The rules of a task that the check of an answer slot sees itself (format/README.md, section 15).

View Source
const (
	RuleTaskNoLeaks   = "task.no-leaks"
	RuleLessonNoLeaks = "lesson.no-leaks"
)

The rules of the leak check on the texts of a module (format/README.md, sections 20 and 21).

View Source
const (
	RuleManifestDependencies  = "manifest.dependencies"
	RuleManifestBands         = "manifest.bands"
	RuleManifestRungTemplates = "manifest.rung-templates"
	RuleSkillGraphAcyclic     = "skill-graph.acyclic"
	RuleSkillGraphKnownSkills = "skill-graph.known-skills"
	RuleSkillGraphRetiredIDs  = "skill-graph.retired-ids"
	RuleSkillGraphOwnAnchors  = "skill-graph.own-anchors"
	RuleTrapsKnownSkills      = "traps.known-skills"
	RuleTaskKnownTraps        = "task.known-traps"
	RuleTaskKnownTechniques   = "task.known-techniques"
)

The rules of the parts that the check holds, by the part a breach of each is reported in (format/README.md, sections 11, 12, 16 and 17).

View Source
const (
	RuleTaskKnownSkills     = "task.known-skills"
	RuleTaskSkillRoles      = "task.skill-roles"
	RuleTaskOwnAnchors      = "task.own-anchors"
	RuleTaskKnownBand       = "task.known-band"
	RuleTaskKnownPictures   = "task.known-pictures"
	RuleTaskAgeCategories   = "task.age-categories"
	RuleTaskZones           = "task.zones"
	RuleTaskAssessability   = "task.assessability"
	RuleLessonKnownSkills   = "lesson.known-skills"
	RuleLessonKnownTasks    = "lesson.known-tasks"
	RuleLessonTaskSkills    = "lesson.task-skills"
	RuleLessonKnownPictures = "lesson.known-pictures"
	RuleLessonAreas         = "lesson.areas"
	RuleLessonAgeCategories = "lesson.age-categories"
	RuleLessonOrder         = "lesson.order"
)

The rules of a task and of a lesson that the check holds (format/README.md, sections 14, 15 and 21): those that need no check kind, no leak check and no template.

View Source
const (
	RuleTaskTemplateNames       = template.RuleNames
	RuleTaskTemplateExpressions = template.RuleExpressions
	RuleTaskPlaceholders        = template.RulePlaceholders
	RuleTaskTemplateInstances   = template.RuleInstances
	RuleTaskInstances           = "task.instances"
)

The rules of templates (format/README.md, section 23): those that a template breaks by itself, which package template reads, and task.instances, which holds each of its instances to the schema of a task.

View Source
const FormatVersion = "0.3"

FormatVersion is the version of the module format that this library reads: the version of the schemas that internal/schema holds, a copy of those of spec.Format, and of the test vectors (format/README.md, section 2; R23). While the format is v0, it is the one version the library reads.

Variables

This section is empty.

Functions

func ReadsFormat

func ReadsFormat(v string) bool

ReadsFormat says whether the library reads a module written in the format version v, as a manifest names it in module_format_version: while the format is v0, only FormatVersion (format/README.md, section 2).

func Tiers added in v0.1.12

Tiers gives the tier of each skill of a skill graph (format/README.md, section 12): tier 1 for a skill with no prerequisite among the module's skills, and one tier above the highest of its prerequisites among them for every other, so that an anchor skill counts for none. The package holds them in its canonical view, as skill_tiers (section 25). A graph whose prerequisites name a skill that it does not have, or run in a cycle, has no tiers: it breaks skill-graph.known-skills or skill-graph.acyclic, and Tiers gives an error.

Types

type Breach

type Breach struct {
	Rule string
	// The keyword of JSON Schema 2020-12 that fails, such as required or pattern, when the breach is
	// of the schema; its place is then Pointer, where the schema holding the keyword applies, as an
	// example of the format names it (format/README.md, section 8).
	Keyword string
	// The file or folder from the module's folder, with / between names, as the folder lists them;
	// "." for the module's folder itself, as fs.FS names it, and empty for the file that CheckFile
	// checks, which has no path.
	Path string
	// The place in the file, line and column from 1: in a file of a part as yaml.Breach counts them,
	// and in LICENSE and NOTICE with every line ended by LF alone. 0 when the breach is of the file
	// as a whole or of a value in it.
	Line, Column int
	// The value in the file that breaks the rule, as a JSON Pointer in URI fragment form, such as
	// #/module_format_version (format/README.md, section 8); empty when the breach is of no value.
	Pointer string
	Message string
}

A Breach is one reason a module is refused: a rule it breaks; or, when Rule is empty, a keyword of the schema of its part that a file fails, which Keyword names; or, when both are empty, a file of a part that is not YAML 1.2.2, which the format refuses without an ID (format/README.md, sections 4 and 8).

func (Breach) String

func (b Breach) String() string

type Report

type Report struct {
	Breaches []Breach
}

A Report is what the check of a module finds: every breach, in the order of their places — the path, then the line and column, then the value, member by member, with an element of an array by its index —, and at one place in the order of their rules and keywords, so that it does not depend on the order in which the folder lists its files. A report with no breach accepts the module.

func Check

func Check(fsys fs.FS) (Report, error)

Check reads the module whose folder is the root of fsys and checks it by the format version FormatVersion: its layout, each file of a part by the YAML rules and against the schema of its part, and the files that both accept by the rules of the parts (format/README.md, sections 4, 5 and 10–17). A manifest that names a version the library does not read gives a report of that breach alone, since the rest of the module is written by rules the library does not know. The error is for a folder or file that could not be read, and then there is no report.

Example
report, err := Check(fstest.MapFS{
	"Manifest.yaml": {Data: []byte(manifest)},
	"LICENSE":       {Data: []byte("The text of the license.\r\n")},
})
if err != nil {
	panic(err)
}
fmt.Println(report)
Output:
.: module.manifest: the folder holds no file manifest.yaml
LICENSE:1:25: module.plain-text: holds a carriage return: every line ends with LF alone
Manifest.yaml: module.layout: stands at no path of the layout of a module

func CheckFile

func CheckFile(part string, data []byte) (Report, error)

CheckFile checks a file of a part on its own, as an example of the part and a test vector of a part's rule in a file are checked (format/README.md, sections 8 and 9): by the YAML rules and against the schema of the part, and, when both accept it, by the rules within its part; a manifest first by the format version it names, which, when the library does not read it, is the report's only breach, as in Check. Its breaches have no path. part is the term of a part of the layout, such as manifest or task; any other is an error.

func (Report) String

func (r Report) String() string

Jump to

Keyboard shortcuts

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