diff

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 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 diff compares two compiled specs and lists what changed in meaning (§11.5). It reads only compiled specs; finding the earlier one in git is the project package's job.

Index

Constants

View Source
const FormatVersion = "0.1"

FormatVersion is the version of the JSON report (S17.1, S17.13).

Variables

Kinds lists every kind in the order of the diff table.

Functions

func Line

func Line(r spec.Rule) string

Line is a rule as the report shows it: its ID, its sentence as written with spaces normalised, and its tags.

func WriteJSON

func WriteJSON(w io.Writer, r Report) error

WriteJSON writes the report as indented JSON.

func WriteMarkdown

func WriteMarkdown(w io.Writer, against string, changes []Change) error

WriteMarkdown writes the report as the "What this changes" section of a proposal: a heading for each kind with changes, in the order of the diff table, and under it each rule with where it is, its line before and after, and the other kinds it is listed under.

Types

type ByKind

type ByKind struct {
	Added        []Entry `json:"added"`
	Removed      []Entry `json:"removed"`
	Dropped      []Entry `json:"dropped"`
	Downgraded   []Entry `json:"downgraded"`
	Accepted     []Entry `json:"accepted"`
	Reworded     []Entry `json:"reworded"`
	Weakened     []Entry `json:"weakened"`
	Strengthened []Entry `json:"strengthened"`
	Reversed     []Entry `json:"reversed"`
}

ByKind holds the entries of each kind, in the order of the diff table.

type Change

type Change struct {
	Kinds  []Kind
	Before *spec.Rule
	After  *spec.Rule
}

Change is one rule that changed, with every kind it is listed under (S16.1). Before is nil for an added rule and After for a removed one.

func Compare

func Compare(before, after []spec.Rule) []Change

Compare lists the rules that changed in meaning between two specs, in the order of their files and lines.

Rules with IDs are matched by ID (S16.2). Rules without are matched by their text with spaces normalised (S16.3), so any change of words to a rule without an ID, a change of spelling included, shows as removed and added.

func (Change) Rule

func (c Change) Rule() *spec.Rule

Rule is the side of the change that says where the rule is: after, or before for a removed rule.

type Entry

type Entry struct {
	ID     *string    `json:"id"`
	File   string     `json:"file"`
	Lines  spec.Lines `json:"lines"`
	Before *string    `json:"before"`
	After  *string    `json:"after"`
}

Entry is one change under one kind in the JSON report. File and Lines say where the rule is now, or where it was for a removed rule. Before and After are the rule's line as Line writes it, or null.

type Kind

type Kind string

Kind is one row of the diff table (§11.5).

const (
	Added        Kind = "added"
	Removed      Kind = "removed"
	Dropped      Kind = "dropped"
	Downgraded   Kind = "downgraded"
	Accepted     Kind = "accepted"
	Reworded     Kind = "reworded"
	Weakened     Kind = "weakened"
	Strengthened Kind = "strengthened"
	Reversed     Kind = "reversed"
)

The kinds, in the order of the diff table.

type Report

type Report struct {
	Version string `json:"version"`
	Against string `json:"against"`
	Kinds   ByKind `json:"kinds"`
}

Report is the JSON report: every kind of the diff table, in its order, each with its entries; a kind with none has an empty list.

func NewReport

func NewReport(against string, changes []Change) Report

NewReport groups the changes by kind.

Jump to

Keyboard shortcuts

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