Closed daemontus closed 1 year ago
Base: 76.90% // Head: 77.27% // Increases project coverage by +0.37%
:tada:
Coverage data is based on head (
025050c
) compared to base (e0d0377
). Patch coverage: 88.09% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
In this pull request, we add "structured model annotations". These are comments that can be added to any
.aeon
file and parsed into a well-defined data structure. As such, they are useful when implementing machine-readable metadata or providing other model-related information that isn't an immediate part of the model (see examples below).Annotation syntax:
For example, here is a simple list of annotations which describe the model and its variables:
Overall, the annotations are parsed into a tree. The levels of the tree are the path segments. If a specific "tree node" appears multiple times, the contents of the annotation are concatenated as multiple lines. In this case, the root has two children:
name
anddescription
. Nodename
has only a text value ("My fancy model"
), whiledescription
has both a two-line value, and a childvariable
which contains the remaining sub-tree.We can access annotations using path selectors. For example, after parsing this input into a variable
annotations
, we can runannotations.get_value(&["description", "variable", "var_x"])
to obtain the value"First variable"
. More about the API is available in the tutorial page which is part of the pull request.Escaping
Normally, path segments should only contain alphanumeric characters and underscores. However, they can be escaped using a back-tick (
`
). Consequently, a back-tick cannot appear in any path segment. Similarly, colons cannot appear in annotation values. However, an annotation valueVAL
can be escaped with` #
VAL#
`. Such escaping can be also used to preserve surrounding white-space, as the parser normally removes it.Other examples
A simple "model layout" can be easily included in this way:
A list of properties of a BN sketch can be given using annotations: