Ver Fonte

website/cmd/elvdoc: Fix a bug handling comment blocks from multiple files.

Qi Xiao há 1 ano atrás
pai
commit
0203a2ad82
1 ficheiros alterados com 6 adições e 2 exclusões
  1. 6 2
      website/cmd/elvdoc/main.go

+ 6 - 2
website/cmd/elvdoc/main.go

@@ -70,7 +70,7 @@ func mustGlob(p string) []string {
 
 // Makes a reader that concatenates multiple files.
 func multiFile(names []string) (io.Reader, func(), error) {
-	readers := make([]io.Reader, len(names))
+	readers := make([]io.Reader, 2*len(names))
 	closers := make([]io.Closer, len(names))
 	for i, name := range names {
 		file, err := os.Open(name)
@@ -80,7 +80,11 @@ func multiFile(names []string) (io.Reader, func(), error) {
 			}
 			return nil, nil, err
 		}
-		readers[i] = file
+		readers[2*i] = file
+		// Insert an empty line between adjacent files so that the comment block
+		// at the end of one file doesn't get merged with the comment block at
+		// the start of the next file.
+		readers[2*i+1] = strings.NewReader("\n\n")
 		closers[i] = file
 	}
 	return io.MultiReader(readers...), func() {