Geeking out with diagrams in ASCII

November 5th, 2009 by Strawp

Last week I discovered ditaa and I can’t quite leave it alone. If you don’t understand why creating flow charts in plain ASCII is awesome, stop reading now.

Basically, you can take something like the Hey Jude flow chart, marked up in ASCII and convert it into a proper version. If your face is doing this: O_o, seriously stop reading now.

I marked that last one up in JavE, which is fine for ASCII art but a bit laborious if you want to build a diagram. On the ditaa home page there’s a link to a screencast of the perl app, Asciio (App::Asciio on CPAN) which is almost perfect. With a couple of tweaks to the /setup/stencils/asciio file, changing all the corners to the ‘+’ character and then another tweak to setup/actions/ to automatically create flat txt and native asciio versions of the diagram, then calling ditaa in the background on the txt file to build a neat PNG version.

I now have a Visio-lite system that can create data flow diagrams suitable for both source code headers and also pasting into more formal documents. So… yeah. How was your week.

If anyone else is this nuts, let me know in the comments.

13 Responses to “Geeking out with diagrams in ASCII”

  1. Nick Black Says:

    AWESOME! I’ve been looking for something like this for weeks! Now I can finally knock out bug 32 :). A bit unfortunate that it’s in java, but this asciio business might just work (argh, where’s a C library?). Thanks!

  2. Strawp Says:

    Should just be a matter of installing it using PECL under Ubuntu. I’ll have a go and let you know how I get on.

  3. Thomas Says:

    I recently ran across ditaa too. Installed it as a Dokuwiki plugin and it works pretty well. Also took a look at the Asciio screencast, and it looks perfect for easily making diagrams. However, I can’t get Asciio to work. Not a perl coder, and can’t get any of the dependencies installed. Does anyone know of a nice package (preferably Ubuntu) that has been created for Asciio?

  4. Thomas Says:

    I managed to find some one on the Debian team that was in the process of packaging this for sid. He gave me a sneak-peak at the .debs, and with a bit of work (I’m running Ubuntu 9.10 and not Debian Sid), I got it installed.

    I want to write a more expansive how-to on installing this on both Debian and Ubuntu, and also how to make modifications to pipe the output right into Ditaa. I’ve made the changes as you outlined in your post to the stencils, but not quite sure (without a lot of trial and error) how to do the dual output and the automatic pipping through ditaa. Would you mind staring that piece of code in with me?

  5. Strawp Says:

    I foolishly didn’t put that under any source control, so it’s on a specific machine which isn’t plugged in currently.

    Basically the change I made was in the save function. At the actual point where it writes out a file based on the extension it just does 3 saves instead. One for .txt, one for the native format and then one which is an exec call to the ditaa binary on the .txt file it wrote out.

    I’ll see if I can fish it out…

  6. Strawp Says:

    I’ve stuck online in here:

    Look around line 66 and note the ditaa path is designed to run under windows, so change that bit for Debian, Ubuntu, anything else really.

  7. Thomas Says:

    Thanks for that!

    I had the text figured out, but the conversion isn’t working for me. Simply because I don’t have the perl module installed Proc::Background. I’ve commented that out for now, and will look at installing that later and including it in my directions. Anything special you would like written in the credits section of my How-To?

  8. Strawp Says:

    Cool, well if you’re going to be just piping stdout into ditaa then you don’t really need it to run ditaa in the background.

    Link back to this blog post if you like 🙂

  9. Lewis Says:

    If anyone is interested drawing simple ASCII flow diagrams on the web: works for me 😉
    Chrome or Firefox recommended…

  10. nadim khemir Says:

    If you have a need for help or want things to work differently in Asciio, the best thing is to mail the author (that would be me). I got a few requests for an Asciio-Ditaa cooperation out of the box and it may make it in a new release.

  11. Strawp Says:

    Cool site Lewis!

    Hi Nadim,

    We had a slightly disjointed mail conversation in Nov 09 (I went off on holiday in the middle of it I think) but I basically just said what this post and subsequent comments have written in them.

    Ping me if you add ditaa output to asciio – that would be v cool.

  12. nadim khemir Says:

    Hi, I just came back to the land of the living too.

    kick my ass now and then and you’ll get what you want. Color attributes are already in asciio so that would allow one to look more like the output. I don’t know yet about the other attribue in ditaa. I have to decided f I support ditaa users, which would be the intelligent thing to do, or simply bypass it, possibly using it to render things but not allow any interaction.

    There is a new, a year old, asciio that is not released yet. the GTK part has been separated from the rest, which will be re-written when I re-incarnate next, but I am pondering about a curses interface so one could create asciio diagrams directly in a terminal. What do you think about that idea?

    Drop me a mail, that usually get things done.

  13. Strawp Says:

    I’m a sucker for stuff built in with ncurses 😀