cmd/doc: submit to the punched card tyranny · golang/go@a625b91

1 min read Original article ↗
Original file line numberDiff line numberDiff line change

@@ -20,6 +20,12 @@ import (

2020

"unicode/utf8"

2121

)

2222
23+

const (

24+

punchedCardWidth = 80 // These things just won't leave us alone.

25+

indentedWidth = punchedCardWidth - len(indent)

26+

indent = " "

27+

)

28+
2329

type Package struct {

2430

writer io.Writer // Destination for output.

2531

name string // Package name, json for encoding/json.

@@ -135,7 +141,7 @@ func (pkg *Package) emit(comment string, node ast.Node) {

135141

}

136142

if comment != "" {

137143

pkg.newlines(2) // Guarantee blank line before comment.

138-

doc.ToText(&pkg.buf, comment, " ", "\t", 80)

144+

doc.ToText(&pkg.buf, comment, " ", indent, indentedWidth)

139145

}

140146

pkg.newlines(1)

141147

}

@@ -204,7 +210,7 @@ func (pkg *Package) packageDoc() {

204210

pkg.packageClause(false)

205211

}

206212
207-

doc.ToText(&pkg.buf, pkg.doc.Doc, "", "\t", 80)

213+

doc.ToText(&pkg.buf, pkg.doc.Doc, "", indent, indentedWidth)

208214

pkg.newlines(1)

209215
210216

if !pkg.showInternals() {