Difference between revisions of "Diagrams"

From BITPlan Wiki
Jump to: navigation, search
(What is it ?)
(MediaWiki Diagrams extension)
(19 intermediate revisions by the same user not shown)
Line 9: Line 9:
 
= What is it ? =
 
= What is it ? =
 
This is a Python based webservice to render diagrams for
 
This is a Python based webservice to render diagrams for
# [[File:GraphVizLogo.png|link=https://www.graphviz.org/|graphviz]][https://www.graphviz.org graphviz]
+
* [[File:GraphVizLogo.png|link=https://www.graphviz.org/|graphviz]][https://www.graphviz.org graphviz]
# [[File:Msc-sig.png|link=http://www.mcternan.me.uk/mscgen/|mscgen]][http://www.mcternan.me.uk/mscgen mscgen]
+
* [[File:Msc-sig.png|link=http://www.mcternan.me.uk/mscgen/|mscgen]][http://www.mcternan.me.uk/mscgen mscgen]
# plantuml
+
* [[File:Plantuml logo.png|link=https://plantuml.com/|plantuml]][https://plantuml.com/ plantuml]
  
 
= Demo =
 
= Demo =
 
https://diagrams.bitplan.com
 
https://diagrams.bitplan.com
 
= Examples =
 
= Examples =
== dot ==
+
{| class="wikitable sortable"
<graphviz>
+
|-
 +
! tool !! source !! image
 +
|-
 +
| dot  
 +
| <pre><graphviz>
 
graph development {  
 
graph development {  
 
   Stakeholder -- Requirements;  
 
   Stakeholder -- Requirements;  
Line 25: Line 29:
 
}
 
}
 
</graphviz>
 
</graphviz>
 +
</pre>
 +
| <graphviz>
 +
graph development {
 +
  Stakeholder -- Requirements;
 +
  Requirements -- Samplecases;
 +
  Requirements -- Model;
 +
  Model -- Code;
 +
}
 +
</graphviz>
 +
|-
 +
| neato
 +
|<pre><graphviz renderer='neato'>
 +
graph G {
 +
  run -- intr;
 +
  intr -- runbl;
 +
  runbl -- run;
 +
  run -- kernel;
 +
  kernel -- zombie;
 +
  kernel -- sleep;
 +
  kernel -- runmem;
 +
  sleep -- swap;
 +
  swap -- runswap;
 +
  runswap -- new;
 +
  runswap -- runmem;n
 +
  new -- runmem;
 +
  sleep -- runmem;
 +
}
 +
</graphviz>
 +
</pre>
 +
|<graphviz renderer='neato'>
 +
graph G {
 +
  run -- intr;
 +
  intr -- runbl;
 +
  runbl -- run;
 +
  run -- kernel;
 +
  kernel -- zombie;
 +
  kernel -- sleep;
 +
  kernel -- runmem;
 +
  sleep -- swap;
 +
  swap -- runswap;
 +
  runswap -- new;
 +
  runswap -- runmem;n
 +
  new -- runmem;
 +
  sleep -- runmem;
 +
}
 +
</graphviz>
 +
 +
|}
 +
 +
= Installation =
 +
If you'd like to run your own service you need a python 3 environment includin pip3. The software has been tested on Ubuntu 18.04 and Mac OS 13.6 using macports.
 +
<source lang='bash'>
 +
git clone https://github.com/BITPlan/diagrams
 +
cd diagrams
 +
./install
 +
</source>
 +
= Running =
 +
== Usage ==
 +
<source lang='bash'>
 +
python3 dgs/webserver.py -h
 +
usage: webserver.py [-h] [--debug] [--port PORT] [--host HOST]
 +
 +
Diagrams rendering webservice
 +
 +
optional arguments:
 +
  -h, --help  show this help message and exit
 +
  --debug      run in debug mode
 +
  --port PORT  the port to use
 +
  --host HOST  the host to serve for
 +
</source>
 +
== starting webservice ==
 +
<source lang='bash'>
 +
export PYTHONPATH="."
 +
python3 dgs/webserver.py
 +
</source>
 +
By default the webservice will be available on port 5003.
 +
= MediaWiki Diagrams extension =
 +
The webservice can be used as endpoint for the [https://www.mediawiki.org/wiki/Extension:Diagrams the MediaWiki diagrams extension]
 +
 +
== Install the extension ==
 +
<source lang='bash'>
 +
cd extensions
 +
git clone https://github.com/samwilson/diagrams-extension.git Diagrams
 +
Cloning into 'Diagrams'...
 +
</source>
 +
== Loading extension ==
 +
in LocalSettings.php add
 +
<source lang='php'>
 +
$wgDiagramsServiceUrl ='http://diagrams.bitplan.com';
 +
wfLoadExtension( 'Diagrams' );
 +
</source>
 +
replacing the $wgDiagramsServiceUrl with your own webservice to improve performance
  
= Json API =
+
= MediaWiki Diagrams Extension Json API =
 +
The communication between [https://www.mediawiki.org/wiki/Extension:Diagrams the MediaWiki diagrams extension] and this webservice
 +
is done with POST requests that expect Json responses.
 
== Diagrams ==
 
== Diagrams ==
 
Example
 
Example

Revision as of 08:22, 15 February 2020

OsProject
id  diagrams
owner  BITPlan
title  Diagrams rendering service for graphviz, mscgen and plantuml
url  https://github.com/BITPlan/diagrams
version  0.0.1
date  2020-02-14

Click here to comment see Diagrams

What is it ?

This is a Python based webservice to render diagrams for

Demo

https://diagrams.bitplan.com

Examples

tool source image
dot
<graphviz>
graph development { 
  Stakeholder -- Requirements; 
  Requirements -- Samplecases;
  Requirements -- Model;
  Model -- Code;
}
</graphviz>
This is a graph with borders and nodes that may contain hyperlinks.
neato
<graphviz renderer='neato'>
graph G {
  run -- intr;
  intr -- runbl;
  runbl -- run;
  run -- kernel;
  kernel -- zombie;
  kernel -- sleep;
  kernel -- runmem;
  sleep -- swap;
  swap -- runswap;
  runswap -- new;
  runswap -- runmem;n
  new -- runmem;
  sleep -- runmem;
}
</graphviz>
This is a graph with borders and nodes that may contain hyperlinks.

Installation

If you'd like to run your own service you need a python 3 environment includin pip3. The software has been tested on Ubuntu 18.04 and Mac OS 13.6 using macports.

git clone https://github.com/BITPlan/diagrams
cd diagrams
./install

Running

Usage

python3 dgs/webserver.py -h
usage: webserver.py [-h] [--debug] [--port PORT] [--host HOST]

Diagrams rendering webservice

optional arguments:
  -h, --help   show this help message and exit
  --debug      run in debug mode
  --port PORT  the port to use
  --host HOST  the host to serve for

starting webservice

export PYTHONPATH="."
python3 dgs/webserver.py

By default the webservice will be available on port 5003.

MediaWiki Diagrams extension

The webservice can be used as endpoint for the the MediaWiki diagrams extension

Install the extension

cd extensions
git clone https://github.com/samwilson/diagrams-extension.git Diagrams
Cloning into 'Diagrams'...

Loading extension

in LocalSettings.php add

$wgDiagramsServiceUrl ='http://diagrams.bitplan.com';
wfLoadExtension( 'Diagrams' );

replacing the $wgDiagramsServiceUrl with your own webservice to improve performance

MediaWiki Diagrams Extension Json API

The communication between the MediaWiki diagrams extension and this webservice is done with POST requests that expect Json responses.

Diagrams

Example

{ 
       "diagrams": {
          "png": {
             "url": "http://diagrams.bitplan.com/render/png/0xb00d69ad"
          }
       }
    }

0xb00d69ad.png

Errors

Example

{ 
  "error": "service not ready",
  "message": "not implemented yet"
}

Links