Discussions
Categories
Groups
Documentation
Knowledge base
Developer portal
App catalog
The Hub
GitHub
Home
Newly Imported
Restricted
Veoneer
M2Doc Word reporting trial
medini_1059007410
Hi Mattias, as discussed during our 2022-03-16 meeting, this is the starting point for trialing M2Doc (currently in alpha phase, will become beta around 2022R2 release date). I do not yet have a complete user guide, but I'll share here the current version (with some installation instruction). Guide version: 2022-03-16 The add-on file I'll send to you via SecureTransfer, as it is too large for attachment. So far the guidance is very limited, so please feel free to fire any questions here and I'll answer plus add to the guideline for the future. Updated versions will be made available at this first post later on. Regards, Nils Discussion topics overview: Fixed number of digits for BigInteger: Workaround available with multiple concatenated OCL functions. Feature to ease that would be good. Wikitext (Markdown files): Usage possible with rather small workaround. No real Word headings generated (currently as-is in M2Doc)
Find more posts tagged with
medini
medini legacy
Accepted answers
All comments
medini_1073221077
Thanks! I managed to install it, but I'm wondering if it would be possible to share the Word template that you used? Or at least a stripped down version of it with some of your examples? It doesn't have to be perfect, just something to play around with. Regards, Mattias
medini_1073221077
Hi again! I was somehow able to piece together a simple M2DOC template using some bits and pieces from the M2DOC website, your attached document and some pieces from my own memory. :-) Was able to generate lists using for loops and show some diagrams. Regards, Mattias
medini_1059007410
Hi Mattias, very good. I directly sent you the (not very clean) template I used today, maybe it serves as additional inspiration. :-) Regards, Nils
medini_1073221077
Thanks for the files. I'm trying to see if I can create a template file that can display bigger tables. I realized that it is possible to have pages with bigger sizes and different rotation in Word, so it might be possible to create something that looks nice. I have a question regarding M2DOC that you might be able to answer. Is it possible to truncate numbers to a fixed precision? If I write {m.fmeda.totalFailureRate} it will will display all decimals.
medini_1024169437
Mattias, I think
https://medini.freshdesk.com/support/discussions/topics/1000094380
should help. You may also search for BigDecimal in the scripting forum. Regards Jan
medini_1073221077
Hmmm... I've used BigDecimal in ordinary JavaScript, but I don't know how to access that from a M2DOC template. :-( Is that possible? The only way I can think of is to add custom variables to the DC Worksheet and pre-format the numbers using a small script.
medini_1059007410
Mattias, I've also looked at the entry Jan linked, the script contains helpful examples. One addition to that script: console.log(" decimal places with setScale(5)={0}", bd.setScale(5, java.math.RoundingMode.HALF_UP).toPlainString()); // rounds to 5 decimal places (still within BigDecimal), and then converts to string This is for fixed decimal places in Javascript. For M2Doc OCL the setScale(...) should be right for you (if you don't want scientific). Cheers, Nils
medini_1024169437
Ah, sorry Mattias, I forgot that in M2Doc its not JS but OCL. But Nils will find a way :-) Jan
medini_1073221077
I tried setScale, but for that I have to access java.math.RoundingMode.HALF_UP and M2DOC complains that java is an undefined variable.
medini_1024169437
@Nils
: maybe we have to offer some "Number" service for that. Extending the OCL engine is more tricky. Would that help? Jan
medini_1059007410
That opens up a more general topic of how to access methods of Java objects (or we need dedicated services). Mattias, I'll investigate, might take some days. Cheers Nils
medini_1073221077
Hah, I found a way to round the numbers to a fixed number of decimals in M2DOC. {m:( fmeda.lmpfMetric.toString()
.toReal()*1000.0).floor().toString().toReal()/1000.0} Looking forward to a more elegant way! :-) Regards, Mattias
medini_1073221077
I also found this really good summary of the AQL/OCL commands:
https://wiki.eclipse.org/Acceleo/OCL_Operations_Reference
Regards, Mattias
medini_1059007410
Ah, interesting workaround :-) The OCL reference is nice, and it contains working functions/services, which are not part of the official AQL reference. Good to know. Regards, Nils
medini_1073221077
I realized that the Wikitext service is working.
https://www.m2doc.org/ref-doc/nightly/m2doc_service_m2docwikitextservices.html
{m: item.description.fromMarkdownString()} worked. Now I need to figure out if it is possible to use a .md file directly.
medini_1073221077
I found a way. From an .md file you have to go up two levels: {m:'../../'.concat(markdown.uri).fromMarkdownURI()}
medini_1024169437
Nice! How doe sit look like if yo do not use an external file? You embed md text into the docx? Jan
medini_1073221077
I was able to do it like this: {m:'Some text.\n **Some bold
text**\n # A heading\n ' .fromMarkdownString()} Without \n everything ends up on the same line. //Mattias
medini_1073221077
Unfortunately a #heading does not blend directly with the Word headings, but I found that if you for example write ###1.2.3 Heading you will get something that looks similar to a heading AND if you go to the end of the line and press return it will be converted to a real heading. It is a manual step though, I wish it was automatic. //Mattias
medini_1024169437
Ah, I as well thought that the service converts it into a real heading but I guess that's beyond m2doc Without that it is of limited help, isn't it? Jan
medini_1073221077
Yes, unless you have a template that you split into several subsections with their own .md files. The headers that you then use will not show up in the Word table of contents, but in some cases it might be okay, I guess. I had some hope that the M2DOC Markdown engine would support tables, but it doesn't seem to do that. It might be some fundamental limitation of the WikiText service.
medini_1059007410
Hi Mattias, you are quick and found the solution I would have proposed for accessing the .md file. That the headings are no real Word headings are current status for M2Doc (see here). It's still marked as experimental, maybe that will be improved by M2Doc in the future (we could raise that as a question). I would have thought that .md files would be less often used compared to BIRT, as one can also write in the .docx file, but I guess it will still be used for some per-project information easy enough to put into a Markdown file. Regards, Nils
medini_1073221077
Hi Nils, We're trying to figure out the capabilities of M2DOC at the moment. :-) I agree with you that in the end it might be best if each project modifies its own template and put the text directly inside it, instead of collecting it from several .md files. However, one use case that I'm thinking of is that the Description-field of for example an Architecture could contain Markdown tags to make it look nicer if it is displayed below a diagram. //Mattias
medini_1073221077
By the way, I found a way to display all the diagrams from one Architecture item_arch, might be useful for other users. {m:for diagram | projectmodel::PJDiagram.allInstances()}
{m:if item_arch ==diagram.canvasElement}
{m:diagram.asImage().fit(400,400)}
{m:endif}
{m:endfor}
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Help
Best Of