From dcaf4a44c67cafdd1bdb8c2630cfdf211a8c6b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Fri, 24 Feb 2023 13:07:25 +0100 Subject: mkdb: Escape <> characters in annotations Allows to use nested element-type like GLib.HashTable which is allowed by the introspection. --- gtkdoc/mkdb.py | 3 +++ tests/annotations/docs/tester-sections.txt | 1 + tests/annotations/src/tester.c | 15 +++++++++++++++ tests/annotations/src/tester.h | 1 + 4 files changed, 20 insertions(+) diff --git a/gtkdoc/mkdb.py b/gtkdoc/mkdb.py index 98fd5eb..1e16f4a 100644 --- a/gtkdoc/mkdb.py +++ b/gtkdoc/mkdb.py @@ -2686,6 +2686,9 @@ def ExpandAnnotation(symbol, param_desc): annotations = re.split(r'\)\s*\(', m.group(1)) logging.info("annotations for %s: '%s'\n", symbol, m.group(1)) for annotation in annotations: + # The element-type annotation for instance allows to use GHashTable as annotation + annotation = re.sub(r'<', r'<', annotation) + annotation = re.sub(r'>', r'>', annotation) # need to search for the longest key-match in %AnnotationDefinition match_length = 0 match_annotation = '' diff --git a/tests/annotations/docs/tester-sections.txt b/tests/annotations/docs/tester-sections.txt index 3b33f0b..7dc0d44 100644 --- a/tests/annotations/docs/tester-sections.txt +++ b/tests/annotations/docs/tester-sections.txt @@ -7,6 +7,7 @@ annotation_allow_none annotation_nullable annotation_not_nullable annotation_elementtype +annotation_complex_elementtype annotation_elementtype_transfer annotation_elementtype_returns annotation_outparams diff --git a/tests/annotations/src/tester.c b/tests/annotations/src/tester.c index ae38512..c8e3a83 100644 --- a/tests/annotations/src/tester.c +++ b/tests/annotations/src/tester.c @@ -95,6 +95,21 @@ annotation_elementtype (const GList *list) return TRUE; } +/** + * annotation_complex_elementtype: + * @table: (element-type utf8 GHashTable): table that matches strings + * to a #GHashTable of key and value strings. + * + * Document optional parameters. + * + * Returns: %TRUE for success + */ +gboolean +annotation_complex_elementtype (const GHashTable *table) +{ + return TRUE; +} + /** * annotation_elementtype_transfer: * @list: (element-type utf8) (transfer full): list of #GObject instances to search diff --git a/tests/annotations/src/tester.h b/tests/annotations/src/tester.h index 002de4a..e253505 100644 --- a/tests/annotations/src/tester.h +++ b/tests/annotations/src/tester.h @@ -21,6 +21,7 @@ gchar * annotation_nullable (const gchar *uri, const gchar *label); gchar * annotation_not_nullable (const gchar *uri, const gchar *label); gboolean annotation_elementtype (const GList *list); +gboolean annotation_complex_elementtype (const GHashTable *table); gboolean annotation_elementtype_transfer (const GList *list); GList *annotation_elementtype_returns (void); -- cgit v1.2.1