ArchiMate based documentation generation

Started by rheward, October 08, 2019, 21:32:28 PM

Previous topic - Next topic

rheward

I've created a jArchi script some might find useful. The idea was to use an ArchiMate view in Archi to define the structure of an architecture deliverable document, then use jArchi to use that to generate a document, in this case to Markdown (thanks to Steven Mileham's markdown scripts - I did borrow a function from there). It uses the View References that Archi supports.

The documentation.ajs script in GitHub is here (in the usual shared area): https://gist.github.com/rich-biker/9a3c86c5a576ce0d8639856f3ee81651

If you want more info, pop over to my blog area (shameless!): https://www.tamebluelion.co.uk/archimate-documentation

What I'd really like to do next is generate Open Document Format (MS Word) instead of Markdown. Any suggestions on how to call a word library would be welcome.

Phil Beauvoir

Thanks for sharing!

> What I'd really like to do next is generate Open Document Format (MS Word) instead of Markdown. Any suggestions on how to call a word library would be welcome.

I only know of Apache POI - https://poi.apache.org/ - maybe it could be called as part of a batch process rather than from JS.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rheward

Quote from: Phil Beauvoir on October 08, 2019, 21:36:08 PM
Thanks for sharing!

I tried using the docx module now I've realised that I can use it in node.js. It doesn't like that because it uses convensions that are not standard javascript; the ES6 use of classes, for example. I'm out of my depth  ::), but read here http://mail.openjdk.java.net/pipermail/nashorn-dev/2017-May/006936.html that it is possible to enable the ES6 features using a command line option.

Quote
you have to enable ES6 features using the —language=es6 option. The official Script API does not support engine options, but you can use the Nashorn API:
>
> import javax.script.ScriptEngine;
> import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
>
> NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
> ScriptEngine engine = factory.getScriptEngine("--language=es6");

Is that something that I can do with the jArchi setup?

Phil Beauvoir

> Is that something that I can do with the jArchi setup?


No, but it's something I can do in the code. Now I need a simple example of ES6 JS that currently doesn't work with jArchi to try it...
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

#4
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
ScriptEngine engine = factory.getScriptEngine("--language=es6");


Yes, this works. I tried two simple ES6 constructs (let and const) and they worked.

And we can use the foreach with an arrow:

$("concept").forEach(c => {
    console.log(c.type + ": " + c.name);
});


I'm not sure if this affects Nashorn in any other ways. I'll put this in as an experimental option and make a new build of jArchi next week.

Good find - I did not know about this.  :)
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.