module

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 12 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; and the YAML rules of section 4 on each file of a part, by internal/yaml (R22).

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 FormatVersion = "0.3"

FormatVersion is the version of the module format that this library reads: the version of the schemas and test vectors it takes from spec.Format (format/README.md, section 2). 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).

Types

type Breach

type Breach struct {
	Rule 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 file of a part that is not YAML 1.2.2, which the format refuses without an ID (format/README.md, section 4).

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 —, and at one place in the order of their rules, 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, and each file of a part by the YAML rules (format/README.md, sections 4, 10 and 11). 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 a manifest by the format version it names. 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