
ASCII Art in .NET Code - boyter
https://mattwarren.org/2019/04/25/ASCII-Art-in-.NET-Code/
======
WorldMaker
An interesting thing about the Timelines example is that the Reactive
Extensions world uses a lot of similar ASCII drawing and often refers to them
as "Marble Diagrams". There are tools to generate nice graphic versions of
ASCII Marble Diagrams. Some unit tests frameworks for RX libraries even
support writing tests directly as ASCII Marble Diagrams:

[https://github.com/ReactiveX/rxjs/blob/master/docs_app/conte...](https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/testing/marble-
testing.md)

------
selectnull
Of course, whole another level of using ASCII art is to make it executable, as
done by a good friend of mine: Stack Trace Art
([https://github.com/ironcev/stack-trace-
art](https://github.com/ironcev/stack-trace-art)).

I've loved it so much that when I saw it for the first time (some 5 years ago)
I had to port it to JavaScript (original is C#) and you can see it here:
[https://github.com/selectnull/stacktraceart](https://github.com/selectnull/stacktraceart)

If you're interested in story of how the idea was born, read about it in these
blog posts:

* [http://thehumbleprogrammer.com/stack-trace-art/](http://thehumbleprogrammer.com/stack-trace-art/)

* [http://thehumbleprogrammer.com/his-majesty-hangul-the-filler...](http://thehumbleprogrammer.com/his-majesty-hangul-the-filler/)

~~~
matthewwarren
Wow, 'Stack Trace Art' is very cool, thanks for the links!

------
32bitkid
I have no connection or affiliation with this product, but I enjoy a good
ASCII/Unicode chart in code—a picture is worth a 1k words—and I've been
leaning on [https://monodraw.helftone.com/](https://monodraw.helftone.com/)
lately for my text drawing needs.

~~~
cheerlessbog
Pretty funny that a format intended to allow you to draw without a mouse now
has a visual designer.

Are there serious interactive image editors that don't require a mouse? For
symmetry's sake.

~~~
Crinus
I remember ASCII and ANSI art editors that were meant to be used with mouse
ever since the DOS times (often distributed through and for BBS) in the late
80s/early 90s.

------
userbinator
Comments like this are often discouraged because they're difficult to modify
when the code is changed, but in these cases it seems their purpose besides
explanation is to imply that there is a good reason the code is the way it is,
and that you had better have a _very_ good reason to change the code (and the
accompanying comment). In other words, they serve to also guard against
change, in parts of the code which should not change often.

~~~
ken
Most of these diagrams don't look that difficult to modify -- but then, I've
got Emacs (with picture-mode, artist-mode, table-mode, etc). The presence of a
diagram would not discourage me from changing a function, if I thought it
needed changing. I wish most functions were so well documented!

It's true I haven't seen any IDEs with similar capabilities, so I imagine it
is harder for other people. At what point does it become permissible to say
"It's not my problem you choose to use a text editor that isn't capable of
editing this style of text"? We're certainly well beyond that point in most
other areas, e.g., indentation, capitalization, or renaming.

------
Exuma
How does the regex work?

~~~
McGlockenshire

      "/\*" - literal forward slash followed by literal asterisk
      "(.*?)" - followed by zero or more of any character, captured non-greedy
      "\*" - and another literal asterisk
    
      "|" - all of the above, or the following
    
      "//(.*?)" - literal two forward slashes and another non-greedy anything
      "\r?\n" - a possible carriage return followed by a newline
    
      "|" - or
    
      the following pattern in double quotes:
    
      "(\\[^\n]|[^"\n])*" - a backslash followed by one character that is not a newline, OR anything that is not a double quote or a newline.  this sequence can occur zero or more times, and both the matching sequence and all of the matching sequence are captured
    
      "|" - or
    
      "@("[^"]\*")+" - a literal at sign, followed by one or more of anything that is not double quotes, enclosed by double quotes.
    

All it's doing is sniffing segments that look like they might be comment
blocks, sections in double quotes, and... I'm not actually sure what the last
segment would be, it seems to capture @"whatever"? Regardless, this doesn't
actually sniff for ASCII art as much as comments themselves.

~~~
matthewwarren
> Regardless, this doesn't actually sniff for ASCII art as much as comments
> themselves.

Yeah you're right. The regex just finds comments. I then wrote some very
simple code that analysed the text inside the comments to find _potentially
interesting_ ASCII Art. I then looked through these manually to get the ones
for the post.

