Skip to content

Commit 7d97b47

Browse files
author
dmullis
committed
Process GoAT drawing from .go source file to SVG inserted in README
1 parent fc9803f commit 7d97b47

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

‎README.md.tmpl‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ By default, the program writes to stdout, unless `-o outfile` is given.
4848
- Dashed lines signaled by `:` or `=`.
4949
- Bold lines signaled by ???.
5050

51+
## Data Flow
52+
![]({{.Root}}/goat.svg)
53+
5154
## Examples
5255

5356
Here are some SVGs and the UTF-8 input they were generated from:

‎canvas.go‎

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
21
/*
32
Package goat formats "ASCII-art" drawings into Github-flavored Markdown.
43
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>
4+
<goat>
5+
porcelain API
6+
BuildAndWriteSVG()
7+
.----------.
8+
ASCII-art | | Markdown
9+
----------------------->| +------------------------->
10+
| |
11+
'----------'
12+
13+
14+
· · · · · · · · · · · · · · · · · · · · · · · ·
15+
16+
plumbing API
17+
Canvas{}
18+
NewCanvas() .-------------------. WriteSVGBody()
19+
| | .-------.
20+
ASCII-art .--. | data map[x,y]rune | | SVG{} | Markdown
21+
---------->| +--->| text map[x,y]rune +-->| +------->
22+
'--' | | | |
23+
'-------------------' '-------'
24+
</goat>
1525
*/
1626
package goat
1727

‎make.sh‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ usage () {
1717
}
1818

1919
# Define colors for SVG ~foreground~ seen on Github front page.
20-
svg_color_dark_scheme="#EDF"
21-
svg_color_light_scheme="#014"
20+
svg_color_dark_scheme="#EEF"
21+
svg_color_light_scheme="#011"
2222

2323
TEST_ARGS=
2424

@@ -36,32 +36,30 @@ done
3636
#
3737
# If the command fails due to expected changes in SVG output, rerun
3838
# this script with "TEST_ARGS=-write" first on the command line.
39-
# XX Better not to fail if the .txt source has changed.
39+
# X Results are used as "golden" standard for GitHub-side regression tests --
40+
# so arguments here must not conflict with those in "test.yml".
4041
go test -run . -v \
41-
-svg-color-dark-scheme ${svg_color_dark_scheme} \
42-
-svg-color-light-scheme ${svg_color_light_scheme} \
4342
${TEST_ARGS}
4443

4544
# build README.md
4645
go run ./cmd/tmpl-expand Root="." <README.md.tmpl >README.md \
4746
$(bash -c 'echo ./examples/{trees,overlaps,line-decorations,line-ends,dot-grids,large-nodes,small-grids,big-grids,complicated}.{txt,svg}')
4847

49-
go_to_markdown () {
50-
BASENAME=$1
51-
# input is a scan of the Go package in $CWD
52-
go doc -all |
53-
tee ${BASENAME}.go.doc.txt |
54-
# XX relative path assumes $CWD is the project root dir
55-
go run ./cmd/goatdoc -svgfilesprefix=${BASENAME} >${BASENAME}.md
56-
}
57-
58-
# build API.md XX rename $(go list -f {{.Name}}).goatdoc.md ?
59-
go_to_markdown API
48+
# '-d' writes ./awkvars.out
49+
cat *.go |
50+
awk '
51+
/[<]goat[>]/ {p = 1; next}
52+
/[<][/]goat[>]/ {p = 0; next}
53+
p > 0 {print}' |
54+
tee goat.txt |
55+
go run ./cmd/goat \
56+
-svg-color-dark-scheme ${svg_color_dark_scheme} \
57+
-svg-color-light-scheme ${svg_color_light_scheme} \
58+
>goat.svg
6059

6160
if [ ! "$githubuser" ] # XX Is this the right test
6261
then
6362
# Render to HTML, for local inspection.
6463
./markdown_to_html.sh README.md >README.html
6564
./markdown_to_html.sh CHANGELOG.md >CHANGELOG.html
66-
./markdown_to_html.sh API.md >API.html
6765
fi

0 commit comments

Comments
 (0)