diff options
author | Russ Cox <rsc@golang.org> | 2018-08-17 10:51:53 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2018-08-17 17:05:37 +0000 |
commit | c81d216d844f165b729fa3dbb0c3d834eb4268a8 (patch) | |
tree | d53ee84e72fa61da0b2790c912b277ac82200dea | |
parent | 3e0f5f934eb474196297fddf957157422f93a2d7 (diff) | |
download | go-c81d216d844f165b729fa3dbb0c3d834eb4268a8.tar.gz go-c81d216d844f165b729fa3dbb0c3d834eb4268a8.zip |
go/doc: allow interior dot in heading, as in "go.mod"
Only the expected headings are affected.
Diffing the output of "go run headscan.go" before and after:
$ diff head1 head2
26a27,28
> Edit go.mod from tools or scripts
> Make go.mod semantically consistent
168c170
< 141 headings found
---
> 143 headings found
$
Fixes #26938.
Change-Id: I204fd982a60773aa26880cd19eed890c373b8ab6
Reviewed-on: https://go-review.googlesource.com/129677
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r-- | src/go/doc/comment.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/go/doc/comment.go b/src/go/doc/comment.go index 7c4490e7c3..d068d8960c 100644 --- a/src/go/doc/comment.go +++ b/src/go/doc/comment.go @@ -232,7 +232,7 @@ func heading(line string) string { } // exclude lines with illegal characters. we allow "()," - if strings.ContainsAny(line, ".;:!?+*/=[]{}_^°&§~%#@<\">\\") { + if strings.ContainsAny(line, ";:!?+*/=[]{}_^°&§~%#@<\">\\") { return "" } @@ -248,6 +248,18 @@ func heading(line string) string { b = b[i+2:] } + // allow "." when followed by non-space + for b := line;; { + i := strings.IndexRune(b, '.') + if i < 0 { + break + } + if i+1 >= len(b) || b[i+1] == ' ' { + return "" // not followed by non-space + } + b = b[i+1:] + } + return line } |