aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lesana/collection.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/lesana/collection.py b/lesana/collection.py
index e428ae1..f877d31 100644
--- a/lesana/collection.py
+++ b/lesana/collection.py
@@ -71,6 +71,23 @@ class Entry(object):
"Not adding comments because they are not"
"supported by the yaml loader."
)
+ valid_values = field.field.get('values', [])
+ if valid_values:
+ comment = "# {name} ({type}): {valid_values}".format(
+ valid_values="|".join(valid_values),
+ **field.field
+ )
+ try:
+ data.yaml_set_comment_before_after_key(
+ key=name,
+ before=comment,
+ indent=0
+ )
+ except AttributeError:
+ logger.warning(
+ "Not adding comments because they are not"
+ "supported by the yaml loader."
+ )
return data
@property