summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2020-04-08 14:00:51 +0100
committerEmmanuele Bassi <ebassi@gmail.com>2020-04-24 14:18:08 +0000
commit9cb1ac54f5cda256230e76d4d78e960f98c9d2c3 (patch)
treed0c468b0e19ba086471e7bb11592d3fa45e522d0 /giscanner
parentec08670d80d12668e3e6be4b6eb395e5ad207034 (diff)
downloadgobject-introspection-9cb1ac54f5cda256230e76d4d78e960f98c9d2c3.tar.gz
Support the gtk-doc action syntax
GTK4 allows adding widget-related actions to the documentation with the newly defined syntax: <class_name> '|' <action_name> ':' This means g-ir-scanner needs to detect this new format, to avoid emitting unnecessary warnings. Currently, we don't do anything with the actions; in the future we might want to add them to the documentation in the GIR, but for that we'd need a new element. See also: GNOME/gtk-doc!30
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/annotationparser.py42
1 files changed, 36 insertions, 6 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 9ab629b3..16a66f33 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -440,6 +440,27 @@ SIGNAL_RE = re.compile(
''',
re.UNICODE | re.VERBOSE)
+# Pattern matching action identifiers.
+ACTION_RE = re.compile(
+ r'''
+ ^ # start
+ \s* # 0 or more whitespace characters
+ (?P<class_name>[\w]+) # class name
+ \s* # 0 or more whitespace characters
+ \|{1} # 1 required vertical bar
+ \s* # 0 or more whitespace characters
+ (?P<action_name>[\w-]+\.[\w-]+) # action name
+ \s* # 0 or more whitespace characters
+ (?P<delimiter>:?) # delimiter
+ \s* # 0 or more whitespace characters
+ (?P<fields>.*?) # annotations + description
+ \s* # 0 or more whitespace characters
+ :? # invalid delimiter
+ \s* # 0 or more whitespace characters
+ $ # end
+ ''',
+ re.UNICODE | re.VERBOSE)
+
# Pattern matching parameters.
PARAMETER_RE = re.compile(
r'''
@@ -1338,13 +1359,22 @@ class GtkDocCommentBlockParser(object):
identifier_fields = result.group('fields')
identifier_fields_start = result.start('fields')
else:
- result = SYMBOL_RE.match(line)
+ result = ACTION_RE.match(line)
if result:
- identifier_name = '%s' % (result.group('symbol_name'), )
- identifier_delimiter = result.group('delimiter')
- identifier_fields = result.group('fields')
- identifier_fields_start = result.start('fields')
+ identifier_name = 'ACTION:%s:%s' % (result.group('class_name'),
+ result.group('action_name'))
+ identifier_delimiter = None
+ identifier_fields = None
+ identifier_fields_start = None
+ else:
+ result = SYMBOL_RE.match(line)
+
+ if result:
+ identifier_name = '%s' % (result.group('symbol_name'), )
+ identifier_delimiter = result.group('delimiter')
+ identifier_fields = result.group('fields')
+ identifier_fields_start = result.start('fields')
if result:
in_part = PART_IDENTIFIER
@@ -2117,7 +2147,7 @@ class GtkDocCommentBlockWriter(object):
lines = []
# Identifier part
- if block.name.startswith('SECTION'):
+ if block.name.startswith('SECTION') or block.name.startswith('ACTION'):
lines.append(block.name)
else:
if block.annotations: