1
0
mirror of https://github.com/golang/go synced 2024-11-12 03:00:22 -07:00

go/doc: permit a package synopsis to end with ":\n".

R=gri, r
CC=golang-dev
https://golang.org/cl/12822043
This commit is contained in:
David Symonds 2013-08-13 16:20:17 +10:00
parent f7ab3917f9
commit c272fd14a8
2 changed files with 7 additions and 3 deletions

View File

@ -10,12 +10,15 @@ import (
)
// firstSentenceLen returns the length of the first sentence in s.
// The sentence ends after the first period followed by space and
// not preceded by exactly one uppercase letter.
//
// The sentence ends at the first colon followed by a newline,
// or at the first period followed by space and not preceded by
// exactly one uppercase letter.
func firstSentenceLen(s string) int {
var ppp, pp, p rune
for i, q := range s {
if p == ':' && q == '\n' {
return i
}
if q == '\n' || q == '\r' || q == '\t' {
q = ' '
}

View File

@ -29,6 +29,7 @@ var tests = []struct {
{"Package Καλημέρα κόσμε.", 36, "Package Καλημέρα κόσμε."},
{"Package こんにちは 世界\n", 31, "Package こんにちは 世界"},
{"Package foo does bar.", 21, "Package foo does bar."},
{"Package foo does these things:\n - a\n - b", 30, "Package foo does these things:"},
{"Copyright 2012 Google, Inc. Package foo does bar.", 27, ""},
{"All Rights reserved. Package foo does bar.", 20, ""},
{"All rights reserved. Package foo does bar.", 20, ""},