Explaining Code Using ASCII Art
blog.regehr.org
blog.regehr.org
Plain text is almost a universal truth -- and it's easy to church up your documentation with a well presented ASCII chart.
Some ANSI Color Codes and ASCIInema can carry you a long way.
Here's a list of plain text information tools from my notes:
https://mbarkhau.keybase.pub/asciigrid/
https://gitlab.com/mbarkhau/asciigrid/
ascii-tables is exactly what is says on the label. https://ozh.github.io/ascii-tables/
https://github.com/ozh/ascii-tables/
https://www.netpen.io/main/
https://github.com/ebirger/netpen/
svgbob and svg-term are both great for creating SVGs out of these plain text files: https://github.com/marionebl/svg-term-cli/
https://ivanceras.github.io/svgbob-editor/
https://github.com/ivanceras/svgbob/
Here are some TUI/CLI focused frameworks. These are over kill for me - but maybe useful to someone here: https://www.textualize.io/
https://charm.sh/
http://maaslalani.com/slides/
https://github.com/peterbrittain/asciimatics/
TUI/Text-Based presentaion tools: https://sli.dev/
https://github.com/slidevjs/slidev/
https://github.com/maaslalani/slides/
http://maaslalani.com/slides/
https://github.com/d0c-s4vage/lookatme/
https://github.com/chunqiuyiyu/ervy/
Honorable Mention goes to wtf-util and it's TUI configurator: https://wtfutil.com/
https://github.com/ggerganov/wtf-tui
Thanks for coming to my ted talk!Would you mind explaining what you mean by this? I take it you mean it ubiquitous, which of course it is, but as a phenomenon I'd much rather see things that look like they come from the real world, with color, depth, texture, and I'd much rather see a future where interactions with computers are moving in that direction.
Runs in the browser, editor for animated ASCII art, exports as embeddable javascript and animated GIFs.
Some simple visualization using ASCII is fine. Something you can create from scratch and otherwise modify in as much time as it would take to document code. But, if you need a sequence diagram, or flow chart, what not. The tradeoff for maintenance and lack of readability makes it look silly. The "why was this developer wasting time doing things with the wrong tools"-kind of silly.
If you need complex diagrams. Create them using draw.io or plantuml, and add them to the source control. Generate images which you instead reference in the documentation in code. Tools such as Doxygen and other such tools would be able to pull in the images and actually look good. This is both maintainable, and scalable.
PlantUML/mermaidjs do hit a sweet spot IMO, of having the chart defined as plaintext but rendering a pretty picture. The only way these could be improved IMO is if the ascii "code" for the diagram was also an actual diagram you could understand without running it through the parser.
For ASCII art, this is far from linear, in most of the examples shown.
Consider some of the more complex ones shown in the linked article. The minor added complexity of adding a field, suddenly might mean you need to remake parts, or even entire visual art for it to stay congruent. You'll have software engineers hitting spacebar a few hundred times just to align things right. With proper tools, you'd just add the field, and that's it.
The table of "The layout of a data structure in the Jikes RVM" for example. Imagine, if suddenly there was a new attribute in one of the tables, which has a longer name than any of the previously existing ones. Great fun to manually widen the whole thing. With multiple cursors easily possible, but even then it sucks and there are other scenarios, where it gets much worse.
In Org mode I could imagine managing such a table and then copying it back into the code comment. And maybe Emacs' ASCII art drawing mode (forgot its name) would help me with other shapes, but drawing something like an ERM or so is still tedious.
Maybe those ASCII art diagrams could be created, when the design is already finished.
Not having integrated built-in tools to properly maintain this type of representation is a missed opportunity.
IDEs went the copy/paste and word replace route, and the few diagram and table drawing tools in ASCII are often in separate applications, reducing their usefulness.
Then the system text renderer can be responsible for drawing these diagrams, and they can be embedded anywhere in text.
It would also have the side benefit of letting people draw their own emojis, rather than waiting some time from months to never to have their suggestions included in the next Unicode release.
Leave plaintext to be as plain as possible. Emoji were already a bad compromise made to get Japanese encodings to sort-of work. Leave markup to general markup languages. Don't make unicode even more convoluted.
So you'd use a mouse to "draw" a line (if it's horizontal or vertical), and it'd take only 4 "draw line" to make a box, and turn on 'insert' mode to type in the text inside the box.
Drawing diagonal lines is a bit more involved, but not too hard either. Adding a cell to an ascii table is also pretty easy using this same method.
However, it is preferable to have the diagram in svg tho. The svg file could even be separate from the comments, but just referenced.
I cannot find any information about an IDE which does this.
https://dot-to-ascii.ggerganov.com
I generate the ASCII graph and then paste it in the comments together with a link to the service. This way I can go back later and update it if needed:
/*
Link: https://dot-to-ascii.ggerganov.com/?src_hash=476410d3
0.6
┌─────────────────────────┐
▼ │
┌───┐ 0.8 ┌───┐ 0.1 ┌───┐ 0.7 ┌───┐ 0.2 ┌───┐
│ d │ ─────▶ │ │ ◀───── │ e │ ─────▶ │ a │ ─────▶ │ b │
└───┘ │ c │ └───┘ └───┘ └───┘
│ │ 0.4 │
│ │ ◀──────────────────────────────────┘
└───┘
*/I'm using Noto Sans Mono as monospace font. Broken with Iosevka as well, works with Dejavu Sans Mono.
That said, it's pretty cool, bookmarked.
EDIT: weird now I'm looking at my comment from an iPhone and the arrow is rendered with the arrow emoji. Have I found an exploit to embed emojis in HN comments?!
Apple emoji font, in addition to emojis, also includes other characters like numbers, arrows, and "trademark" (tm), "registered" (r), and "copyright" (c) symbols, so that's why.
Also I think that modeling languages like Mermaid are a nice alternative for small to medium diagrams. But these wont work in code comments. But they can be fitted into a Markdown file.
M-x picture-mode
https://www.gnu.org/software/emacs/manual/html_node/emacs/Pi...
Further enhanced by M-x artist-mode (also included with Emacs):
display: block;
overflow-x: auto;
That would allow the <pre> to overflow to the right and let the user scroll over.Love this stuff.
I love ASCII ART. Its elegance is in its simplicity. To be able a draw anything from simple boxes[0] to Mona Lisa[1] to Porn[2] using nothing but bunch of plain ascii characters just blows my mind. To craft is to hand place each character, at its right place without disturbing anything around, which feels nothing less than crafting a glass-piece.
Links :
[0] : https://www.asciiart.eu/art-and-design/borders
That's not what the word means in normal use.
The GPL license describes source code as "the preferred form of the work for making modifications to it". Sometimes the preferred form that conveys the most information is a 2D visual representation, and it would be sleek if we had more parsers capable of extracting case specifications directly from that format.
Doing it in plain text with `white-space: pre` (the default for the <pre> element) would work better.
If I would have to document a table into the code, I would try to use as little ASCII characters as needed, in order to not confuse the screen reader.
https://archive.org/details/Comanche55J2k60/page/n1027/mode/...
This reminds me of a code comment I wrote about some web crawling code that is intended to maintain a continuous web address "flow graph", matching any origin URL(s) (the 'water table' of a web page) down to the current location of that page on the web (the 'river delta').
This can be complicated because old URLs may be redirected (HTTP 301, 302) to different locations over time, often for SEO reasons or due to change of domain ownership.
Does the code comment linked below make sense? I'd really appreciate any feedback and improvements:
https://github.com/openculinary/backend/blob/5116c4f5d39dae1...
(and yes, I realize the ASCII art here pales in comparison to some of the visually appealing and clear diagrams shared in the article. I'm doing my best :))
I also find that usually the pictures capture a fairly high level structural concept - the sort of thing that changes a bit less. Sometimes I do a message sequence chart and editing to add an extra message is usually pretty easy.
Not too long ago I had a project that was implemented as a complex state machine where the requirements kept changing, and keeping the documentation as an ASCII diagram in the source code had a couple of benefits: * It meant that the documentation could be updated when the code had to be changed * I didn't have to hunt for the diagrams on the project wiki when I made these changes. * The diagram was kept in version control with the rest of the code. Each commit/branch had a diagram that accurately reflected its state.
I could then use Ditaa to convert the diagram to a more appropriate format when updating the project's wiki or emailing the customer
[1] https://web.archive.org/web/20130813045206/http://www.asciif... [2] https://github.com/stathissideris/ditaa
- https://fatiherikli.github.io/archetype/
- https://textik.com/#a4ec12a68785f25f
- https://monodraw.helftone.com/
- text to diagramming tools [list](https://smusamashah.github.io/text-to-diagram)
more: https://github.com/sw-yx/spark-joy/blob/master/README.md#asc...
I have a whole section of my notes dedicated to ASCII Art in the purely creative/crack/BBS scene.
Unicode/Cyrillic fonts used by loud girls on instagram:
https://coolfonts.text-generator.org/
https://www.messletters.com/en/
https://github.com/sepandhaghighi/art
Some creative ASCII tools: https://github.com/maaslalani/draw
https://blocktronics.github.io/moebius/
http://picoe.ca/products/pablodraw/
https://ivanceras.github.io/svgbob-editor/
http://www.torchsoft.com/en/aas_information.html
https://github.com/hpjansson/chafa/
Here's some ANSI and BBS scene stuff: https://www.asciiarena.se/
https://16colo.rs/
https://www.ansilove.org/
https://www.trueschool.se/
https://www.teletextart.com/
https://www.pouet.net/
https://github.com/NuSkooler/enigma-bbs
Like most of us - I grew up with mostly Async communication online.I'm still out here dishing out emoticons like it's 1998 and every kilobyte counts.
(•_•)
( •_•)>⌐■-■
(⌐■_■)we can be friends
creators of 8bit games didn't have the technology to create 64bit games, yet today we create 8bit games for 64bit machines
[1]: https://timvisee.com/blog/solving-aoc-2020-in-under-a-second...