Skip to content

Commit 4200b1f

Browse files
author
dmullis
committed
Refresh generated files
1 parent 37cd586 commit 4200b1f

24 files changed

+4921
-1524
lines changed

README.md

Lines changed: 88 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,87 @@
11
# GoAT: Go ASCII Tool
22

3-
This is a Go implementation of [markdeep.mini.js]'s ASCII diagram
4-
generation.
3+
## What **GoAT** Can Do For You
54

6-
## Update (2022-02-07)
5+
- From a chunky ASCII-art source drawing, render polished, graphically-rich [SVG](#complicated),
6+
with the [goat](./cmd/goat) CLI command.
77

8-
I hacked together GoAT a number of years ago while trying to embed some
9-
diagrams in a Hugo project I was playing with. Through an odd twist of fate
10-
GoAT eventually made its way into the upstream Hugo project, and if you're
11-
using [v0.93.0] you can embed these diagrams natively. Neat!
8+
- Tie together all three of:
9+
1. Your code's major data structures or abstract data/control flows.
10+
2. Related ASCII-art diagrams embedded in comments, adjacent to the source code.
11+
3. Polished line diagrams in your user-facing high-level documentation, with inline links
12+
to SVG produced by [goat](./cmd/goat).
13+
For Markdown or similar formats, links may be expanded either at build-time or run-time,
14+
as needed by your doc tool suite.
1215

13-
My original implementation was certainly buggy and not on par with markdeep.
14-
I'm grateful for the folks who've helped smooth out the rough edges, and I've
15-
updated this project to reflect the good changes made in the Hugo fork,
16-
including a long-overdue `go.mod`.
16+
Your ASCII-art source persists as the single-point-of-truth, revision-controlled along with
17+
the code that embeds it.
18+
This README contains an [example](#library-data-flow).
1719

18-
There's a lot I would like to do with this project that I will never get to, so
19-
instead I recommend you look at these forks:
20+
## You Will Also Need
2021

21-
* [@bep] is the fork currently used by Hugo, which I expect to be more active
22-
over time.
23-
* [@dmacvicar] has improved SVG/PNG/PDF rendering.
24-
* [@sw46] has implemented a really wonderful hand-drawn style worth checking
25-
out.
22+
#### Graphical- or Rectangle-oriented text editing capability
23+
Both **vim** and **emacs** offer useful support.
24+
In Emacs, see the built-in rectangle-editing commands, and ```picture-mode```.
2625

27-
## Usage
26+
#### A fixed-pitch font with 2:1 height:width ratio as presented by your editor and terminal emulator
27+
Most fixed-pitch or "monospace" Unicode fonts maintain a 2:1 aspect ratio for
28+
characters in the ASCII range,
29+
and all GoAT drawing characters are ASCII.
30+
However, certain Unicode graphical characters e.g. MIDDLE DOT may be useful, and
31+
conform to the width of the ASCII range.
2832

29-
```bash
30-
$ go get github.com/blampe/goat
31-
$ cat my-cool-diagram.txt | goat > my-cool-diagram.svg
32-
```
33-
34-
By default, the program reads from stdin, unless `-i infile` is given.
35-
36-
By default, the program writes to stdout, unless `-o outfile` is given or a
37-
binary format with `-f` is selected.
38-
39-
By default, it writes in [SVG] format, unless another format is specified with
40-
`-f`.
33+
CJK characters on the other hand are typically wider than 2:1.
34+
Non-standard width characters are not in general composable on the left-right axis within a plain-text
35+
drawing, because the remainder of the line of text to their right is pushed out of alignment
36+
with rows above and below.
4137

42-
## TODO
43-
44-
- Dashed lines signaled by `:` or `=`.
45-
- Bold lines signaled by ???.
38+
## Installation
39+
```
40+
$ go install github.com/dmullis/goat/cmd/goat@latest
41+
```
4642

4743
## Examples
4844

49-
Here are some SVGs and the UTF-8 input they were generated from:
45+
Here are some snippets of
46+
GoAT-formatted UTF-8
47+
and the SVG each can generate.
48+
The SVG you see below was linked to by
49+
inline Markdown image references
50+
([howto](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#images),
51+
[spec](https://github.github.com/gfm/#images)) from
52+
GoAT's [README.md](README.md), then finally rendered to HTML ```<img>``` elements by Github's Markdown processor
5053

51-
### Trees
52-
53-
![Trees Example](https://cdn.rawgit.com/blampe/goat/main/examples/trees.svg)
5454

55+
### Trees
5556
```
57+
5658
. . . .--- 1 .-- 1 / 1
5759
/ \ | | .---+ .-+ +
5860
/ \ .---+---. .--+--. | '--- 2 | '-- 2 / \ 2
5961
+ + | | | | ---+ ---+ +
6062
/ \ / \ .-+-. .-+-. .+. .+. | .--- 3 | .-- 3 \ / 3
6163
/ \ / \ | | | | | | | | '---+ '-+ +
6264
1 2 3 4 1 2 3 4 1 2 3 4 '--- 4 '-- 4 \ 4
63-
```
6465
65-
### Overlaps
6666
67-
![Overlaps Example](https://cdn.rawgit.com/blampe/goat/main/examples/overlaps.svg)
67+
```
68+
![](./examples/trees.svg)
6869

70+
### Overlaps
6971
```
72+
7073
.-. .-. .-. .-. .-. .-.
7174
| | | | | | | | | | | |
7275
.---------. .--+---+--. .--+---+--. .--| |--. .--+ +--. .------|--.
7376
| | | | | | | | | | | | | | | | | |
7477
'---------' '--+---+--' '--+---+--' '--| |--' '--+ +--' '--|------'
7578
| | | | | | | | | | | |
7679
'-' '-' '-' '-' '-' '-'
80+
7781
```
82+
![](./examples/overlaps.svg)
7883

7984
### Line Decorations
80-
81-
![Line Decorations Example](https://cdn.rawgit.com/blampe/goat/main/examples/line-decorations.svg)
82-
8385
```
8486
________ o * * .--------------.
8587
*---+--. | | o o | ^ \ / | .----------. |
@@ -88,12 +90,11 @@ Here are some SVGs and the UTF-8 input they were generated from:
8890
<--' ^ ^ | | | | | ^ \ | '--------' | |
8991
\/ *-----' o |<----->| '-----' |__| v '------------' |
9092
/\ *---------------'
93+
9194
```
95+
![](./examples/line-decorations.svg)
9296

9397
### Line Ends
94-
95-
![Line Ends Example](https://cdn.rawgit.com/blampe/goat/main/examples/line-ends.svg)
96-
9798
```
9899
o--o *--o / / * o o o o o * * * * o o o o * * * * o o o o * * * *
99100
o--* *--* v v ^ ^ | | | | | | | | \ \ \ \ \ \ \ \ / / / / / / / /
@@ -105,26 +106,28 @@ Here are some SVGs and the UTF-8 input they were generated from:
105106
* o | | * o \ \
106107
107108
<--o <--* <--> <--- ---o ---* ---> ---- *<-- o<-- -->o -->*
108-
```
109109
110-
### Dot Grids
111110
112-
![Dot Grids Example](https://cdn.rawgit.com/blampe/goat/main/examples/dot-grids.svg)
111+
```
112+
![](./examples/line-ends.svg)
113113

114+
### Dot Grids
114115
```
116+
115117
o o o o o * * * * * * * o o * o o o * * * o o o · * · · · · · ·
116118
o o o o o * * * * * o o o o * o o o o * * * * * o * * · * * · · · · · ·
117119
o o o o o * * * * * o * o o o o o o o o * * * * * o o o o o · o · · o · · * * ·
118120
o o o o o * * * * * o * o o o o o o o * * * * o * o o · · · · o · · * ·
119121
o o o o o * * * * * * * * * o o o o * * * o * o · · · · · · · *
122+
123+
120124
```
121125
Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character, encoded with UTF-8.
126+
![](./examples/dot-grids.svg)
122127

123128
### Large Nodes
124-
125-
![Large Node Example](https://cdn.rawgit.com/blampe/goat/main/examples/large-nodes.svg)
126-
127129
```
130+
128131
.---. .-. .-. .-. .-.
129132
| A +----->| 1 +<---->| 2 |<----+ 4 +------------------. | 8 |
130133
'---' '-' '+' '-' | '-'
@@ -133,12 +136,12 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
133136
.-. .-+-. .-. .-+-. .-. .+. .---.
134137
| 3 +---->| B |<----->| 5 +---->| C +---->| 6 +---->| 7 |<---->| D |
135138
'-' '---' '-' '---' '-' '-' '---'
139+
136140
```
141+
![](./examples/large-nodes.svg)
137142

138143
### Small Grids
139-
140-
![Small Grids Example](https://cdn.rawgit.com/blampe/goat/main/examples/small-grids.svg)
141-
144+
![](./examples/small-grids.svg)
142145
```
143146
___ ___ .---+---+---+---+---. .---+---+---+---. .---. .---.
144147
___/ \___/ \ | | | | | | / \ / \ / \ / \ / | +---+ |
@@ -147,12 +150,11 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
147150
/ a \___/ \___/ +---+---+---+---+---+ +---+---+---+---+ +---+ b +---+
148151
\___/ \___/ \ | | a | | | | / \ / \ / \ / \ / | a +---+ |
149152
\___/ \___/ '---+---+---+---+---' '---+---+---+---' '---' '---'
150-
```
151153
152-
### Big Grids
153154
154-
![Big Grids Example](https://cdn.rawgit.com/blampe/goat/main/examples/big-grids.svg)
155+
```
155156

157+
### Big Grids
156158
```
157159
.----. .----.
158160
/ \ / \ .-----+-----+-----.
@@ -165,12 +167,12 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
165167
'----+ +----+ + | | | | +-----+-----+-----+-----+
166168
\ / \ / | A | | | / / / / /
167169
'----' '----' '-----+-----+-----' '-----+-----+-----+-----+
168-
```
169170
170-
### Complicated
171171
172-
![Complicated Example](https://cdn.rawgit.com/blampe/goat/main/examples/complicated.svg)
172+
```
173+
![](./examples/big-grids.svg)
173174

175+
### Complicated
174176
```
175177
+-------------------+ ^ .---.
176178
| A Box |__.--.__ __.--> | .-. | |
@@ -196,9 +198,31 @@ Note that '·' above is not ASCII, but rather Unicode, the MIDDLE DOT character,
196198
.-. .---+--------. / A || B *bold* | ^
197199
| | | Not a dot | <---+---<-- A dash--is not a line v |
198200
'-' '---------+--' / Nor/is this. ---
201+
199202
```
203+
![](./examples/complicated.svg)
204+
205+
### More examples are [here](examples)
206+
207+
## The GoAT Library
208+
209+
The core engine of ```goat``` is accessible as a Go library package, for inclusion in specialized
210+
code of your own.
211+
The code implements a subset, and some extensions, of the ASCII diagram generation function of the browser-side Javascript in [Markdeep](http://casual-effects.com/markdeep/).
212+
213+
### library Data Flow
214+
![](./goat.svg)
215+
216+
The diagram above was derived by [./make.sh](./make.sh) from ASCII-art in the Go
217+
source file [./goat.go](./goat.go).
218+
219+
#### Project Tenets
200220

201-
More examples are available [here](examples).
221+
1. Utility and ease of integration into existing projects are paramount.
222+
2. Compatibility with MarkDeep desired, but not required.
223+
3. TXT and SVG intelligibility are co-equal in priority.
224+
4. Composability of TXT not to be sacrificed -- only width-8 characters allowed.
225+
5. Per-platform support limited to a single widely-available fixed-pitch TXT font.
202226

203227
[@bep]: https://github.com/bep/goat/
204228
[@dmacvicar]: https://github.com/dmacvicar/goat

examples/arrows.svg

Lines changed: 13 additions & 5 deletions
Loading

examples/big-grids.svg

Lines changed: 19 additions & 11 deletions
Loading

examples/big-shapes.svg

Lines changed: 13 additions & 5 deletions
Loading

0 commit comments

Comments
 (0)