From 9cb1ac54f5cda256230e76d4d78e960f98c9d2c3 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 8 Apr 2020 14:00:51 +0100 Subject: Support the gtk-doc action syntax GTK4 allows adding widget-related actions to the documentation with the newly defined syntax: '|' ':' 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 --- giscanner/annotationparser.py | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'giscanner') 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[\w]+) # class name + \s* # 0 or more whitespace characters + \|{1} # 1 required vertical bar + \s* # 0 or more whitespace characters + (?P[\w-]+\.[\w-]+) # action name + \s* # 0 or more whitespace characters + (?P:?) # delimiter + \s* # 0 or more whitespace characters + (?P.*?) # 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: -- cgit v1.2.1