textdiff

package
v0.0.0-...-e2c53ed Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

Package cloudeng.io/algo/lcs/textdiff

import cloudeng.io/algo/lcs/textdiff

Package textdiff providers support for diff'ing text.

Functions

Func DP
func DP(a, b string) *lcs.EditScript[rune]

DP uses cloudeng.io/algo/lcs.DP to generate diffs.

Func LineFNVHashDecoder
func LineFNVHashDecoder(data []byte) (string, int64, int)

LineFNVHashDecoder decodes a byte slice into newline delimited blocks each of which is represented by a 64 bit hash obtained from fnv.New64a.

Func Myers
func Myers(a, b string) *lcs.EditScript[rune]

Myers uses cloudeng.io/algo/lcs.Myers to generate diffs.

Types

Type Diff
type Diff struct {
	// contains filtered or unexported fields
}

Diff represents the ability to diff two slices.

Functions
func LinesDP(a, b []byte) *Diff

LinesDP uses cloudeng.io/algo/lcs.DP to generate diffs.

func LinesMyers(a, b []byte) *Diff

LinesMyers uses cloudeng.io/algo/lcs.Myers to generate diffs.

Methods
func (d *Diff) Group(i int) *Group

Group returns the i'th 'diff group'.

func (d *Diff) NumGroups() int

NumGroups returns the number of 'diff groups' created.

func (d *Diff) Same() bool

Same returns true if there were no diffs.

Type Group
type Group struct {
	// contains filtered or unexported fields
}

Group represents a single diff 'group', that is a set of insertions/deletions that are pertain to the same set of lines.

Methods
func (g *Group) Deleted() string

Deleted returns the text would be deleted.

func (g *Group) Inserted() string

Inserted returns the text to be inserted.

func (g *Group) Summary() string

Summary returns a summary message in the style of the unix/linux diff command line tool, eg. 1,2a3.

Type LineDecoder
type LineDecoder struct {
	// contains filtered or unexported fields
}

LineDecoder represents a decoder that can be used to split a byte stream into lines for use with the cloudeng.io/algo/lcs package.

Functions
func NewLineDecoder(fn func(data []byte) (string, int64, int)) *LineDecoder

NewLineDecoder returns a new instance of LineDecoder.

Methods
func (ld *LineDecoder) Decode(data []byte) (int64, int)

Decode can be used as the decode function when creating a new decoder using cloudeng.io/algo.codec.NewDecoder.

func (ld *LineDecoder) Line(i int) (string, uint64)

Line returns the i'th line.

func (ld *LineDecoder) NumLines() int

NumLines returns the number of lines decoded.

TODO
  • cnicolaou: adjust the lcs algorithms to be identical to diff?

Documentation

Overview

Package textdiff providers support for diff'ing text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DP

func DP(a, b string) *lcs.EditScript[rune]

DP uses cloudeng.io/algo/lcs.DP to generate diffs.

func LineFNVHashDecoder

func LineFNVHashDecoder(data []byte) (string, int64, int)

LineFNVHashDecoder decodes a byte slice into newline delimited blocks each of which is represented by a 64 bit hash obtained from fnv.New64a.

func Myers

func Myers(a, b string) *lcs.EditScript[rune]

Myers uses cloudeng.io/algo/lcs.Myers to generate diffs.

Types

type Diff

type Diff struct {
	// contains filtered or unexported fields
}

Diff represents the ability to diff two slices.

func LinesDP

func LinesDP(a, b []byte) *Diff

LinesDP uses cloudeng.io/algo/lcs.DP to generate diffs.

func LinesMyers

func LinesMyers(a, b []byte) *Diff

LinesMyers uses cloudeng.io/algo/lcs.Myers to generate diffs.

func (*Diff) Group

func (d *Diff) Group(i int) *Group

Group returns the i'th 'diff group'.

func (*Diff) NumGroups

func (d *Diff) NumGroups() int

NumGroups returns the number of 'diff groups' created.

func (*Diff) Same

func (d *Diff) Same() bool

Same returns true if there were no diffs.

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group represents a single diff 'group', that is a set of insertions/deletions that are pertain to the same set of lines.

func (*Group) Deleted

func (g *Group) Deleted() string

Deleted returns the text would be deleted.

func (*Group) Inserted

func (g *Group) Inserted() string

Inserted returns the text to be inserted.

func (*Group) Summary

func (g *Group) Summary() string

Summary returns a summary message in the style of the unix/linux diff command line tool, eg. 1,2a3.

type LineDecoder

type LineDecoder struct {
	// contains filtered or unexported fields
}

LineDecoder represents a decoder that can be used to split a byte stream into lines for use with the cloudeng.io/algo/lcs package.

func NewLineDecoder

func NewLineDecoder(fn func(data []byte) (string, int64, int)) *LineDecoder

NewLineDecoder returns a new instance of LineDecoder.

func (*LineDecoder) Decode

func (ld *LineDecoder) Decode(data []byte) (int64, int)

Decode can be used as the decode function when creating a new decoder using cloudeng.io/algo.codec.NewDecoder.

func (*LineDecoder) Line

func (ld *LineDecoder) Line(i int) (string, uint64)

Line returns the i'th line.

func (*LineDecoder) NumLines

func (ld *LineDecoder) NumLines() int

NumLines returns the number of lines decoded.

Jump to

Keyboard shortcuts

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