Skip to content

Latest commit

 

History

History

script

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

mscgen_js' innards

Here's some notes to ease the job of maintaining mscgen_js. It attempts to describe how it does what it does and it tries to explain some of the choices.

The main steps mscgen_js takes to get from a textual description to a picture:

Lexical analysis and parsing

📃 code in parse/peg

We wrote the parsers for mscgen, msgenny and with PEG.js. This is a parser generator that smashes the tasks of lexical analysis and parsing together. In the parser folder we describe

Rendering

Rendering graphics

📃 code in render/graphics/

mscgen_js by default renders its graphics to scalable vector graphics (SVG). In the render folder we

  • motivate this choice,
  • describe how our SVG is structured and
  • how the rendering programs fill it.

Rendering text

📃 code in render/text/

To translate between the three sequence chart languages it supports and to generate and manipulate other languages.

Raster graphics?

📃 code in ui/interpreter/raster-exporter.js

You might have noticed the interpreter also renders to jpeg and png. It uses the canvas methods drawImage() (to render it on the canvas) and toDataURL to extract the raster.

The controllers

Embedding

📃 code in mscgen-inpage.js

The controller for embedding is actually very simple. Details on how it works and what design choices we made you can find here.

Interactive interpreter

📃 code in ui/interpreter

The controller for the interpreter UI is less trivial.

Testing

📃 code in test/

About 300 automated tests (and counting) make sure we can refactor most of the back end code (parsing and rendering) safely.

The ui controller tests are inherently harder to test automated. This is why we did testing with a pair of eyeballs until now. We plan to change that.