ObeoNetwork / M2Doc

The M2Doc technology enables the generation of Office Open XML documents from models.
http://obeonetwork.github.io/M2Doc/
Eclipse Public License 2.0
38 stars 22 forks source link

Add support for conditional link / bookmark reference #433

Closed flatombe closed 2 weeks ago

flatombe commented 3 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please have a look to the support pages of our website : http://m2doc.org/support/

Current behavior

When specifying a link / bookmark reference in a template, we rely on the fact that somewhere else in the template, a bookmark with the specified ID will have been created. In order to only link / reference a bookmark only if it exists, the condition that constrains the existence of the bookmark must be duplicated (if it is even possible), making the template more complex and difficult to maintain.

Expected behavior

There should be at least one way to specify a safe bookmark reference that defaults to rendering the bookmark reference text.

Minimal reproduction of the problem with instructions

{m: 'Foo'.asBookmarkRef('Bar')} {m:if(condition)} {m:'Bar'.asBookmark()} {m:endif}

What is the motivation / use case for changing the behavior?

In Capella, most elements have a property visibleInDoc which may be used to determine whether a model element should have its own section in the generated documentation. In that case, referencing these sections (which may or may not exist depending on the value of visibleInDoc) safely requires duplicating the condition (checking the value of the visibleInDoc property).