Don't mark up the first word in a collective comment.
Change-Id: I3fc0cc07d7a0a29df02601e321d5a5a9ff128bf9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/47330
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/util/doc.go b/util/doc.go
index bdcfcb0..17d7479 100644
--- a/util/doc.go
+++ b/util/doc.go
@@ -291,6 +291,10 @@
return strings.HasPrefix(name, "Private functions") || strings.HasPrefix(name, "Private structures") || strings.Contains(name, "(hidden)")
}
+func isCollectiveComment(line string) bool {
+ return strings.HasPrefix(line, "The ") || strings.HasPrefix(line, "These ")
+}
+
func (config *Config) parseHeader(path string) (*HeaderFile, error) {
headerPath := filepath.Join(config.BaseDirectory, path)
@@ -439,12 +443,10 @@
// As a matter of style, comments should start
// with the name of the thing that they are
// commenting on. We make an exception here for
- // collective comments, which are detected by
- // starting with “The” or “These”.
+ // collective comments.
if len(comment) > 0 &&
len(name) > 0 &&
- !strings.HasPrefix(comment[0], "The ") &&
- !strings.HasPrefix(comment[0], "These ") {
+ !isCollectiveComment(comment[0]) {
subject := commentSubject(comment[0])
ok := subject == name
if l := len(subject); l > 0 && subject[l-1] == '*' {
@@ -540,6 +542,9 @@
}
func markupFirstWord(s template.HTML) template.HTML {
+ if isCollectiveComment(string(s)) {
+ return s
+ }
start := 0
again:
end := strings.Index(string(s[start:]), " ")