10

Question: I'm editing and using an open source javascript library that has JSDoc tags in its code. I was wondering if anyone knew of a JSDoc plugin that would allow me to generate a class diagram from the JSDoc tags.

Edit I decided to try out js/uml and found the following. The JS/UML eclipse extension requires an older version of Eclipse (Indigo) and a non-supported dependency library UML2tools. I found the dependencies needed and according to the Eclipse software manager installed correctly. When I tried to enable the uml functionality (having configured the js root), the process would hang. The examples that the group supplies points at single file Javascript. Seems to have trouble with multiple files being referenced.

theCrux
  • 101
  • 1
  • 6
  • 1
    Google give me [JS/UML](http://jsuml.gaertner-network.de/). This being said, I'm certain that there is no solution that can produce a **complete** UML diagram *only* from the jsdoc tags because jsdoc does not record everything that UML aims to represent. The jsdoc tags could tell you that a Foo has a Bar but it won't tell you how many Foo objects can have a Bar, or precisely how many Bar objects a Foo can have, whether this relation is immutable, whether it is aggregation, composition, etc. – Louis Dec 19 '13 at 12:21
  • @Louis I guess I really would just like to see the class hierarchy if the `@extends` tag is used. – theCrux Dec 19 '13 at 17:32
  • JS/UML looks like it supports this much. – Louis Dec 19 '13 at 17:33
  • Unfortunately, it has been a hastle to install this extension because it can only run on Indigo EE Dev and must have an older version of uml2tools. – theCrux Dec 19 '13 at 19:47
  • 1
    The JS/UML eclipse extension requires an older version of Eclipse (Indigo) and a non-supported dependency library UML2tools. I found the dependencies needed and according to the Eclipse software manager installed correctly. When I tried to enable the uml functionality (having configured the js root), the process would hang. The examples that the group supplies points at single file Javascript. Seems to have trouble with multiple files being referenced. – theCrux Dec 20 '13 at 15:14
  • I would suggest incorporating your experience with JS/UML in your question so that it is quite visible to people who might want to suggest it (and who don't read comments) or people who'd like to try it. – Louis Dec 20 '13 at 15:18

2 Answers2

4

you can use doxygen tools , it provides metadata to generate uml class diagram

http://plantuml.sourceforge.net/doxygen.html

Rotka
  • 430
  • 2
  • 11
3

Not sure what past versions of JSDoc were capable of but JSDoc now supports Javascript classes and the extends keyword. If code is marked up correctly JSDoc can understand class inheritance.

Could make a JSDoc plugin which subscribes to the processingComplete event: "The processingComplete event is fired after JSDoc updates the parse results to reflect inherited and borrowed symbols." http://usejsdoc.org/about-plugins.html

Then you can iterate over the Doclets (objects representing code elements) and serialize your own JSON out. Then you can write a simple HTML renderer for the JSON description of your original code.

Geordie
  • 1,132
  • 14
  • 24