Commit 3a798b10 authored by Matthias Simon's avatar Matthias Simon
Browse files

Format examples

parent 4f93b564
Loading
Loading
Loading
Loading
Loading
+3 −2
Changes for tools/HANDOVER.md: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -274,8 +274,9 @@ These will surface once the slice runs on all of `../src`:

`t3s format [path...]` rewrites TTCN-3 fences in the Markdown sources.
`ttcn3.Format` parses each block with `syntax.Parse` and prints it with
`format.Fprint` from `github.com/nokia/ntt`. The canonical printer uses tabs
and keeps the author's line breaks; it only repairs indentation and
`format.CanonicalPrinter` from `github.com/nokia/ntt`, configured with
`UseSpaces` and `TabWidth` set to 4 (`indentWidth` in `format.go`). The
printer keeps the author's line breaks; it only repairs indentation and
spacing. `Fprint` returns the parse error when the block does not parse, so
that block is left unchanged.

+1 −1
Changes for tools/go.mod: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ go 1.26.9

require (
	github.com/hashicorp/go-multierror v1.1.1
	github.com/nokia/ntt v0.23.2
	github.com/nokia/ntt v0.24.0
	github.com/yuin/goldmark v1.8.6
	golang.org/x/text v0.43.0
	golang.org/x/tools v0.52.0
+4 −2
Changes for tools/go.sum: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
github.com/5nord/goldenfile v0.0.0-20261104194339-4f95f84a5ba8 h1:IQPxF7EG5kmsyOUXfwwzh5gUaWyojrnHLwCOYUWoMCA=
github.com/5nord/goldenfile v0.0.0-20261104194339-4f95f84a5ba8/go.mod h1:M1uhuntiZ4o+HT46QUPhW08vjH6tzMoaVbUW692A8i8=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gosimple/slug v1.12.0 h1:xzuhj7G7cGtd34NXnW/yF0l+AGNfWqwgh/IXgFy7dnc=
@@ -8,8 +10,8 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/nokia/ntt v0.23.2 h1:lye5EM5XW9B5VVBfUb8CVGY5YbpnnsXVoRjJe9cJ7kc=
github.com/nokia/ntt v0.23.2/go.mod h1:XLda/XbBlsr6MWZehbAY4eaqH8ClZoGMCPGFs/+mRDU=
github.com/nokia/ntt v0.24.0 h1:YKGwzWXxQuJWA6QnfnNfR0xpLMpxQMnnZosiNrdT9b8=
github.com/nokia/ntt v0.24.0/go.mod h1:1PK8Qpy6Lu6g7Qq7zF4eLK8ojxgLddsNfPigcQ+pq9s=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
+7 −1
Changes for tools/internal/ttcn3/format.go: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -82,7 +82,10 @@ func Format(src []byte, blocks []*doc.Code) ([]byte, error) {
			continue
		}
		var buf bytes.Buffer
		if err := format.Fprint(&buf, body); err != nil {
		p := format.NewCanonicalPrinter(&buf)
		p.UseSpaces = true
		p.TabWidth = indentWidth
		if err := p.Fprint(body); err != nil {
			errs = append(errs, blockErrors(c, err)...)
			continue
		}
@@ -114,6 +117,9 @@ type edit struct {
	lines      []string
}

// indentWidth is the number of spaces per indent level in formatted blocks.
const indentWidth = 4

func isTTCN3(lang string) bool {
	return strings.EqualFold(lang, "ttcn3")
}
+1 −1
Changes for tools/internal/ttcn3/format_test.go: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ func TestFormatRewritesBodies(t *testing.T) {
		"```ttcn3 example=\"add\"\n" +
		"function f() {\n" +
		"\n" +
		"\tvar integer x := 1;\n" +
		"    var integer x := 1;\n" +
		"}\n" +
		"```\n\n" +
		"Tail.\n\n" +
+88 −88

File changed.

Contains only whitespace changes.

+143 −143

File changed.

Contains only whitespace changes.

+5 −5

File changed.

Contains only whitespace changes.

+15 −15

File changed.

Contains only whitespace changes.

+85 −85

File changed.

Contains only whitespace changes.

+60 −60

File changed.

Contains only whitespace changes.

+32 −32

File changed.

Contains only whitespace changes.

+22 −22

File changed.

Contains only whitespace changes.

+3 −3

File changed.

Contains only whitespace changes.

+65 −65

File changed.

Contains only whitespace changes.

+3 −3

File changed.

Contains only whitespace changes.

+6 −6

File changed.

Contains only whitespace changes.

+20 −20

File changed.

Contains only whitespace changes.

+8 −8

File changed.

Contains only whitespace changes.

+370 −370

File changed.

Contains only whitespace changes.

+50 −50

File changed.

Contains only whitespace changes.

+12 −12

File changed.

Contains only whitespace changes.

+219 −219

File changed.

Contains only whitespace changes.

+3 −3

File changed.

Contains only whitespace changes.