Use PowerShell and yUML to Create Diagrams

by Doug Finke on May 6, 2009

in PowerShell,yUML

A colleague, Charlie Robbins, sent an email about a web site which can create online UML diagrams in seconds from inside blog posts, articles and documents.

Let’s do it with PowerShell

yUML has a straightforward syntax.

This Html tag

<img src="http://yuml.me/diagram/class/[Customer]1-0..*[Address]"/>

produces this diagram

The PowerShell function Get-yUMLDiagram

image
 

Produces the same, here is how you use it

Get-yUMLDiagram "[Customer]1-0..*[Address]" -show

Class with Details

The function ConvertTo-yUML takes an object and generates the yUML for the Properties and/or Methods.

image
 

ConvertTo-yUML


image

Download the Script

{ 2 trackbacks }

Creating and Displaying Trigrams with PowerShell
05.20.09 at 7:48 pm
PowerShell + yUML + Sql Server
05.23.09 at 4:26 pm

{ 7 comments… read them below or add one }

Jason Archer 05.07.09 at 11:22 am

Awesome! I think I will use this a lot.

Enhancement ideas:

Optionally display inheritance for ConvertTo-yUML.
Optionally display implemented interfaces for ConvertTo-yUML (only for the object you are examining).

Tobin Harris 05.07.09 at 12:02 pm

That’s pretty neat! I really like the idea of that, nice use of yUML. Have you seen RailRoad for Rails? It’s a similar idea for reflecting on classes and generating diagrams.

Tobin Harris 05.23.09 at 4:40 am

Hey, I just realised you’ve got a broken image linke. The http:// part is displayed twice in the image URL.

I guess yUML accidently accommodated this error before, but now it doesn’t :)

Chad Miller 05.23.09 at 3:49 pm

Cool stuff! I used your example to create a class digram of SQL Server tables with associations.

Doug Finke 05.23.09 at 3:55 pm

@Tobin thanks
@Chad great, post it

foofi 02.18.10 at 4:26 pm

Using on Win7:

dirty way to run
(powershell in administrator mode): set-executionpolicy unrestricted
and replace the c:\ path in the yuml.ps1 to writable directory.

Doug Finke 02.18.10 at 5:01 pm

Unrestricted is my approach on my personal dev box. Not recommended in many scenarios.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>