diff --git a/bindings/go/scip/testutil/format.go b/bindings/go/scip/testutil/format.go index 1b145cc7..9ce4fc75 100644 --- a/bindings/go/scip/testutil/format.go +++ b/bindings/go/scip/testutil/format.go @@ -164,35 +164,31 @@ func FormatSnapshot( return b.String(), formattingError } -func writeDocumentation(b *strings.Builder, documentation string, prefix string, override bool) { - // At least get the first line of documentation if there is leading whitespace - documentation = strings.TrimSpace(documentation) +func writeMultiline(b *strings.Builder, prefix string, paragraph string) { + for _, s := range strings.Split(paragraph, "\n") { + b.WriteString(prefix) + b.WriteString("> ") + b.WriteString(s) + } +} +func writeDocumentation(b *strings.Builder, documentation string, prefix string, override bool) { b.WriteString(prefix) if override { b.WriteString("override_") } - b.WriteString("documentation ") + b.WriteString("documentation") - truncatedDocumentation := documentation - newlineIndex := strings.Index(documentation, "\n") - if newlineIndex >= 0 { - truncatedDocumentation = documentation[0:newlineIndex] - } - b.WriteString(truncatedDocumentation) + writeMultiline(b, prefix, documentation) } func writeDiagnostic(b *strings.Builder, prefix string, diagnostic *scip.Diagnostic) { b.WriteString(prefix) b.WriteString("diagnostic ") - b.WriteString(diagnostic.Severity.String() + ": ") + b.WriteString(diagnostic.Severity.String()) + b.WriteRune(':') - message := diagnostic.Message - newlineIndex := strings.Index(message, "\n") - if newlineIndex >= 0 { - message = message[0:newlineIndex] - } - b.WriteString(message) + writeMultiline(b, prefix, diagnostic.Message) } // isRangeLess compares two SCIP ranges (which are encoded as []int32). diff --git a/cmd/scip/tests/snapshots/output/cyclic-reference/cycle1.repro b/cmd/scip/tests/snapshots/output/cyclic-reference/cycle1.repro index 2572d7b6..711c2ebe 100755 --- a/cmd/scip/tests/snapshots/output/cyclic-reference/cycle1.repro +++ b/cmd/scip/tests/snapshots/output/cyclic-reference/cycle1.repro @@ -1,7 +1,8 @@ # Test cyclic references between files. definition hello(). # ^^^^^^^^ definition cycle1.repro/hello(). -# documentation signature of hello(). +# documentation +# > signature of hello(). reference hello(). # ^^^^^^^^ reference cycle1.repro/hello(). reference hello2(). diff --git a/cmd/scip/tests/snapshots/output/cyclic-reference/cycle2.repro b/cmd/scip/tests/snapshots/output/cyclic-reference/cycle2.repro index 396e53ca..d9997592 100755 --- a/cmd/scip/tests/snapshots/output/cyclic-reference/cycle2.repro +++ b/cmd/scip/tests/snapshots/output/cyclic-reference/cycle2.repro @@ -1,7 +1,8 @@ # Test cyclic references between files. definition hello2(). # ^^^^^^^^^ definition cycle2.repro/hello2(). -# documentation signature of hello2(). +# documentation +# > signature of hello2(). reference hello(). # ^^^^^^^^ reference cycle1.repro/hello(). reference hello2(). diff --git a/cmd/scip/tests/snapshots/output/diagnostics/diagnostics.repro b/cmd/scip/tests/snapshots/output/diagnostics/diagnostics.repro index 170077e5..81ef168a 100755 --- a/cmd/scip/tests/snapshots/output/diagnostics/diagnostics.repro +++ b/cmd/scip/tests/snapshots/output/diagnostics/diagnostics.repro @@ -1,8 +1,11 @@ definition deprecatedMethod. # ^^^^^^^^^^^^^^^^^ definition diagnostics.repro/deprecatedMethod. -# documentation signature of deprecatedMethod. -# diagnostic Warning: deprecated identifier +# documentation +# > signature of deprecatedMethod. +# diagnostic Warning: +# > deprecated identifier reference deprecatedMethod. # ^^^^^^^^^^^^^^^^^ reference diagnostics.repro/deprecatedMethod. -# diagnostic Warning: deprecated identifier +# diagnostic Warning: +# > deprecated identifier diff --git a/cmd/scip/tests/snapshots/output/duplicates/duplicate.repro b/cmd/scip/tests/snapshots/output/duplicates/duplicate.repro index c3eb7209..608f145d 100755 --- a/cmd/scip/tests/snapshots/output/duplicates/duplicate.repro +++ b/cmd/scip/tests/snapshots/output/duplicates/duplicate.repro @@ -1,7 +1,9 @@ definition readFileSync. # ^^^^^^^^^^^^^ definition duplicate.repro/readFileSync. -# documentation signature of readFileSync. +# documentation +# > signature of readFileSync. definition readFileSync. # ^^^^^^^^^^^^^ definition duplicate.repro/readFileSync. -# documentation signature of readFileSync. +# documentation +# > signature of readFileSync. diff --git a/cmd/scip/tests/snapshots/output/forward-def/forward_def.repro b/cmd/scip/tests/snapshots/output/forward-def/forward_def.repro index 049addb5..2e633659 100755 --- a/cmd/scip/tests/snapshots/output/forward-def/forward_def.repro +++ b/cmd/scip/tests/snapshots/output/forward-def/forward_def.repro @@ -2,7 +2,8 @@ # ^^^^ forward_definition forward_def.repro/abc# definition abc# # ^^^^ definition forward_def.repro/abc# -# documentation signature of abc# +# documentation +# > signature of abc# reference abc# # ^^^^ reference forward_def.repro/abc# diff --git a/cmd/scip/tests/snapshots/output/implementation-cross-repo/bird.repro b/cmd/scip/tests/snapshots/output/implementation-cross-repo/bird.repro index d442b402..0be0be06 100755 --- a/cmd/scip/tests/snapshots/output/implementation-cross-repo/bird.repro +++ b/cmd/scip/tests/snapshots/output/implementation-cross-repo/bird.repro @@ -1,7 +1,8 @@ # Test how to implement a symbol from an external workspace. definition bird# implements global implementation animal.repro/animal# # ^^^^^ definition bird.repro/bird# -# documentation signature of bird# +# documentation +# > signature of bird# # relationship implementation animal.repro/animal# implementation # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference implementation animal.repro/animal# diff --git a/cmd/scip/tests/snapshots/output/implementation/animal.repro b/cmd/scip/tests/snapshots/output/implementation/animal.repro index e98d0378..218fa3a6 100755 --- a/cmd/scip/tests/snapshots/output/implementation/animal.repro +++ b/cmd/scip/tests/snapshots/output/implementation/animal.repro @@ -1,15 +1,18 @@ # Test how to implement a symbol within the same workspace. definition animal# # ^^^^^^^ definition animal.repro/animal# -# documentation signature of animal# +# documentation +# > signature of animal# definition dog# implements animal# # ^^^^ definition animal.repro/dog# -# documentation signature of dog# +# documentation +# > signature of dog# # relationship animal.repro/animal# implementation # ^^^^^^^ reference animal.repro/animal# definition cat# implements animal# # ^^^^ definition animal.repro/cat# -# documentation signature of cat# +# documentation +# > signature of cat# # relationship animal.repro/animal# implementation # ^^^^^^^ reference animal.repro/animal# diff --git a/cmd/scip/tests/snapshots/output/local-document/local1.repro b/cmd/scip/tests/snapshots/output/local-document/local1.repro index 3509f733..685441ac 100755 --- a/cmd/scip/tests/snapshots/output/local-document/local1.repro +++ b/cmd/scip/tests/snapshots/output/local-document/local1.repro @@ -1,8 +1,10 @@ # docstring: local is a local method definition localExample # ^^^^^^^^^^^^ definition local Example -# documentation signature of localExample -# documentation : local is a local method +# documentation +# > signature of localExample +# documentation +# > : local is a local method reference localExample # ^^^^^^^^^^^^ reference local Example diff --git a/cmd/scip/tests/snapshots/output/relationships/defined_by.repro b/cmd/scip/tests/snapshots/output/relationships/defined_by.repro index 7f3beaee..adbcaa17 100755 --- a/cmd/scip/tests/snapshots/output/relationships/defined_by.repro +++ b/cmd/scip/tests/snapshots/output/relationships/defined_by.repro @@ -1,10 +1,12 @@ definition M_f. # ^^^^ definition defined_by.repro/M_f. -# documentation signature of M_f. +# documentation +# > signature of M_f. definition C1_f. # ^^^^^ definition defined_by.repro/C1_f. -# documentation signature of C1_f. +# documentation +# > signature of C1_f. reference C2_f. # ^^^^^ reference defined_by.repro/C1_f. diff --git a/cmd/scip/tests/snapshots/output/relationships/mixed.repro b/cmd/scip/tests/snapshots/output/relationships/mixed.repro index baf0ef1d..6eb69995 100755 --- a/cmd/scip/tests/snapshots/output/relationships/mixed.repro +++ b/cmd/scip/tests/snapshots/output/relationships/mixed.repro @@ -1,15 +1,19 @@ definition local1 # ^^^^^^ definition local 1 -# documentation signature of local1 +# documentation +# > signature of local1 definition local2 # ^^^^^^ definition local 2 -# documentation signature of local2 +# documentation +# > signature of local2 definition local3 # ^^^^^^ definition local 3 -# documentation signature of local3 +# documentation +# > signature of local3 definition local4 implements local1 references local2 type_defines local3 # ^^^^^^ definition local 4 -# documentation signature of local4 +# documentation +# > signature of local4 # relationship local 1 implementation # relationship local 2 reference # relationship local 3 type_definition diff --git a/cmd/scip/tests/snapshots/output/relationships/references.repro b/cmd/scip/tests/snapshots/output/relationships/references.repro index 6faaeba2..44c9eab3 100755 --- a/cmd/scip/tests/snapshots/output/relationships/references.repro +++ b/cmd/scip/tests/snapshots/output/relationships/references.repro @@ -1,9 +1,11 @@ definition local1 # ^^^^^^ definition local 1 -# documentation signature of local1 +# documentation +# > signature of local1 definition local2 references local1 # ^^^^^^ definition local 2 -# documentation signature of local2 +# documentation +# > signature of local2 # relationship local 1 reference # ^^^^^^ reference local 1 diff --git a/cmd/scip/tests/snapshots/output/relationships/type_defines.repro b/cmd/scip/tests/snapshots/output/relationships/type_defines.repro index 4962ab24..708bba8f 100755 --- a/cmd/scip/tests/snapshots/output/relationships/type_defines.repro +++ b/cmd/scip/tests/snapshots/output/relationships/type_defines.repro @@ -1,9 +1,11 @@ definition local1 # ^^^^^^ definition local 1 -# documentation signature of local1 +# documentation +# > signature of local1 definition local2 type_defines local1 # ^^^^^^ definition local 2 -# documentation signature of local2 +# documentation +# > signature of local2 # relationship local 1 type_definition # ^^^^^^ reference local 1