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 to an abstract syntax tree.
- rendering that abstract syntax tree into a picture.
- Besides these two steps it is useful to have some sort of
controler program that handles interaction with the user.
We have four of them:
- for embedding textual descriptions in html
- for the interactive interpreter
- for the command line interface
- for the atom editor package
Dependeny graph (generated with dependency-cruiser):
📃 code in ../parse/peg
We wrote the parsers for MscGen
, MsGenny
and Xù
with
PEG.js. This is a parser generator that smashes the tasks of lexical
analysis and parsing together. In the parser folder we describe
- how to generate the parsers from peggy
- the structure of and principles behind the abstract syntax trees
📃 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.
📃 code in ../render/text/
To translate between the three sequence chart languages it supports and to generate and manipulate other languages.
📃 code in sverweij/mscgen_js/.../interpreter/raster-exporter.js
You might have noticed the interpreter also renders to jpeg and png. It uses the HTML5 canvas for it (and it's really trivial code).
These are not in the 'core' package and serve as a reference of how you can use mscgenjs.
📃 code in samples
Implements an (on line) interpreter and renderer in a few lines of code.
📃 code in sverweij/mscgen_js/.../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
📃 code in sverweij/mscgen_js/.../interpreter
The controller for the interpreter UI is less trivial.
📃 code in sverweij/mscgenjs-cli
📃 code in sverweij/atom-mscgen-preview
📃 code in ../test/
About 400 automated tests (and counting) make sure we can refactor the mscgen_js core modules safely.