-
Notifications
You must be signed in to change notification settings - Fork 85
generalize ODXLINK reference writing #420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
writing ODXLINK references should now always work regardless of in which document fragments the reference and the target objects are located. this works by providing three new "magical" global functions to the jinja macros for output: - `set_category_docfrag()`: Specify the document fragment for the ODX category which is applicable for all subsequent macro invocations. - `set_layer_docfrag()`: Specify the document fragment for the diagnostic layer which is applicable for all subsequent macro invocations (for DIAG-LAYER-CONTAINER). - `make_ref_attribs(ref: OdxLinkRef)`: produces all necessary XML attributes required for an ODX link reference XML tag. (i.e., ID-REF, DOCREF and DOCTYPE) internally, these functions require a dictionary parameter for storing "magic" global variables. On the jinja side, this is not necessary because lambda functions are used as wrappers. Signed-off-by: Andreas Lauser <[email protected]> Approved-by: Alexander Walz <[email protected]>
|
||
jinja_env.globals["set_category_docfrag"] = lambda cname, ctype: set_category_docfrag( | ||
jinja_vars, cname, ctype) | ||
jinja_env.globals["set_layer_docfrag"] = lambda lname: set_layer_docfrag(jinja_vars, lname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from functools import partial
jinja_env.globals["set_layer_docfrag"] = lambda lname: set_layer_docfrag(jinja_vars, lname) | |
jinja_env.globals["set_layer_docfrag"] = partial(set_layer_docfrag, jinja_vars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should stay with the lambda
s because partial
is much less known (I didn't know it) and it is IMO also less explicit...
thanks to [at]kayoub5 Signed-off-by: Andreas Lauser <[email protected]>
now, there should not be any global variables in this code and it should thus be threadsafe... Signed-off-by: Andreas Lauser <[email protected]>
writing ODXLINK references should now always work regardless of in which document fragments the reference and the target objects are located.
this works by providing three new "magical" global functions to the jinja macros for output:
set_category_docfrag()
: Specify the document fragment for the ODX category which is applicable for all subsequent macro invocations.set_layer_docfrag()
: Specify the document fragment for the diagnostic layer which is applicable for all subsequent macro invocations (for DIAG-LAYER-CONTAINER).make_ref_attribs(ref: OdxLinkRef)
: produces all necessary XML attributes required for an ODX link reference XML tag. (i.e., ID-REF, DOCREF and DOCTYPE)internally, these functions require a dictionary parameter for storing "magic" global variables. On the jinja side, this is not necessary because lambda functions are used as wrappers.
Andreas Lauser <[email protected]>, on behalf of MBition GmbH.
Provider Information