Skip to content

Commit b0b6c6c

Browse files
author
dmullis
committed
Comments and formatting only
1 parent 975b273 commit b0b6c6c

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

‎canvas.go‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2+
/*
3+
Package goat formats "ASCII-art" drawings into Github-flavored Markdown.
4+
5+
<goat>
6+
Internal Data Flow
7+
8+
Canvas{} WriteSVGBody() SVG{}
9+
NewCanvas() .-----------------. .-------. .-------------.
10+
ASCII-art .--. | data map[x,y]rune | | | | | Markdown
11+
---------->| +--->| text map[x,y]rune |-->| +--->| Body string +----->
12+
'--' | | | | | |
13+
'-----------------' '-------' '-------------'
14+
</goat>
15+
*/
116
package goat
217

318
import (
@@ -133,8 +148,8 @@ func (c *Canvas) runeAt(i Index) rune {
133148

134149
// NewCanvas creates a new canvas with contents read from the given io.Reader.
135150
// Content should be newline delimited.
136-
// XX Move this to top of file.
137151
func NewCanvas(in io.Reader) (c Canvas) {
152+
// XX Move this function to top of file.
138153
width := 0
139154
height := 0
140155

@@ -201,7 +216,7 @@ type Drawable interface {
201216

202217
// Line represents a straight segment between two points 'start' and 'stop', where
203218
// 'start' is either lesser in X (north-east, east, south-east), or
204-
// equal in X and lesser in Y (south).
219+
// equal in X and lesser in Y (south).
205220
type Line struct {
206221
start Index
207222
stop Index
@@ -302,7 +317,7 @@ type Text struct {
302317
str string // Possibly multiple bytes, from Unicode source of type 'rune'
303318
}
304319

305-
// Bridge correspondes to combinations of "-)-" or "-(-" and is displayed as
320+
// Bridge corresponds to combinations of "-)-" or "-(-" and is displayed as
306321
// the vertical line "hopping over" the horizontal.
307322
type Bridge struct {
308323
start Index

‎cmd/goat/main.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func main() {
5656
if outputFilename != "" {
5757
var err error
5858
output, err = os.Create(outputFilename)
59-
defer output.Close()
59+
defer output.Close() // XX Move outside 'if' -- close os.Stdout as well?
6060
if err != nil {
6161
log.Fatal(err)
6262
}

‎cmd/tmpl-expand/main.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type (
3131
// General args
3232
var (
3333
writeMarkdown = flag.Bool("markdown", false,
34-
`Write out usage doc in Github-flavored Markdown format`)
34+
`Reformat -help usage message into Github-flavored Markdown`)
3535

3636
exitStatus int
3737
)

‎svg.go‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// All output is buffered into the object SVG, then written to the output stream.
12
package goat
23

34
import (
@@ -21,24 +22,24 @@ svg {
2122
color: %s;
2223
}
2324
@media (prefers-color-scheme: dark) {
24-
svg {
25-
color: %s;
26-
}
25+
svg {
26+
color: %s;
27+
}
2728
}
2829
</style>`,
2930
svgColorLightScheme,
3031
svgColorDarkScheme)
3132

3233
return fmt.Sprintf(
33-
"<svg class='%s' xmlns='%s' version='%s' height='%d' width='%d' font-family='Menlo,Lucida Console,monospace'>\n" +
34+
"<svg xmlns='%s' version='%s' height='%d' width='%d' font-family='Menlo,Lucida Console,monospace'>\n" +
3435
"%s\n" +
3536
"%s</svg>\n",
36-
"diagram", // XX can this have any effect?
3737
"http://www.w3.org/2000/svg",
3838
"1.1", s.Height, s.Width, style, s.Body)
3939
}
4040

41-
// BuildSVG reads in a newline-delimited ASCII diagram from src and returns an SVG.
41+
// BuildSVG reads a newline-delimited ASCII diagram from src and returns an
42+
// initialized SVG struct.
4243
func BuildSVG(src io.Reader) SVG {
4344
var buff bytes.Buffer
4445
canvas := NewCanvas(src)
@@ -53,7 +54,7 @@ func BuildSVG(src io.Reader) SVG {
5354
// BuildAndWriteSVG reads in a newline-delimited ASCII diagram from src and writes a
5455
// corresponding SVG diagram to dst.
5556
func BuildAndWriteSVG(src io.Reader, dst io.Writer,
56-
svgColorLightScheme string, svgColorDarkScheme string) {
57+
svgColorLightScheme, svgColorDarkScheme string) {
5758
svg := BuildSVG(src)
5859
writeBytes(dst, svg.String(svgColorLightScheme, svgColorDarkScheme))
5960
}
@@ -70,12 +71,12 @@ func writeBytes(out io.Writer, format string, args ...interface{}) {
7071
func writeText(out io.Writer, canvas *Canvas) {
7172
writeBytes(out,
7273
`<style>
73-
text {
74+
text {
7475
text-anchor: middle;
7576
font-family: "Menlo","Lucida Console","monospace";
7677
fill: currentColor;
7778
font-size: 1em;
78-
}
79+
}
7980
</style>
8081
`)
8182
for _, textObj := range canvas.Text() {

0 commit comments

Comments
 (0)