diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2023-01-08 14:31:41 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2023-01-08 14:36:47 +0000 |
commit | 8c6dc5fa17874a9b6fefee07a8b69e4430975101 (patch) | |
tree | ed25107c79733390f297f8b4ed7d94a84b71d4a4 /giscanner | |
parent | 790bd8a474c2820564afc57a60f20f3deb4e0d42 (diff) | |
download | gobject-introspection-8c6dc5fa17874a9b6fefee07a8b69e4430975101.tar.gz |
Add `default-value` annotation
An escape hatch to specify a freeform string for the default value of a
property.
Fixes: #4
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/annotationparser.py | 16 | ||||
-rw-r--r-- | giscanner/maintransformer.py | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index bce99804..3952b24b 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -193,6 +193,7 @@ ANN_ARRAY = 'array' ANN_ATTRIBUTES = 'attributes' ANN_CLOSURE = 'closure' ANN_CONSTRUCTOR = 'constructor' +ANN_DEFAULT_VALUE = 'default-value' ANN_DESTROY = 'destroy' ANN_ELEMENT_TYPE = 'element-type' ANN_EMITTER = 'emitter' @@ -228,6 +229,7 @@ GI_ANNS = [ANN_ALLOW_NONE, ANN_ATTRIBUTES, ANN_CLOSURE, ANN_CONSTRUCTOR, + ANN_DEFAULT_VALUE, ANN_DESTROY, ANN_ELEMENT_TYPE, ANN_EMITTER, @@ -788,6 +790,19 @@ class GtkDocAnnotatable(object): self._validate_annotation(position, ann_name, options, exact_n_options=0) + def _do_validate_default_value(self, position, ann_name, options): + ''' + Validate the ``(default-value)`` annotation. + + :param position: :class:`giscanner.message.Position` of the line in the source file + containing the annotation to be validated + :param ann_name: name of the annotation holding the options to validate + :param options: annotation options to validate + ''' + + # The 'default-value' annotation allows free form annotations. + pass + def _do_validate_destroy(self, position, ann_name, options): ''' Validate the ``(destroy)`` annotation. @@ -1167,6 +1182,7 @@ class GtkDocCommentBlock(GtkDocAnnotatable): valid_annotations = ( ANN_ATTRIBUTES, ANN_CONSTRUCTOR, + ANN_DEFAULT_VALUE, ANN_EMITTER, ANN_FOREIGN, ANN_GET_PROPERTY, diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 2004d254..285712c7 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -28,6 +28,7 @@ from .annotationparser import ( ANN_ATTRIBUTES, ANN_CLOSURE, ANN_CONSTRUCTOR, + ANN_DEFAULT_VALUE, ANN_DESTROY, ANN_ELEMENT_TYPE, ANN_EMITTER, @@ -963,6 +964,9 @@ class MainTransformer(object): getter = block.annotations.get(ANN_GETTER) if getter: prop.getter = getter[0] + default_value = block.annotations.get(ANN_DEFAULT_VALUE) + if default_value: + prop.default_value = default_value[0] def _apply_annotations_signal(self, parent, signal): names = [] |