summaryrefslogtreecommitdiff
path: root/giscanner/maintransformer.py
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2020-06-06 02:13:38 +0200
committerMathieu Duponchelle <mathieu@centricular.com>2020-07-12 04:10:40 +0200
commitb8c92fddbfbadc910ef0c0c6c65bd5648b8e86ca (patch)
tree24fb56f6eed5696ef96473d2debce108b422fb5f /giscanner/maintransformer.py
parente7c17469ef3eb1c3a1c4c717800c277ee231405c (diff)
downloadgobject-introspection-b8c92fddbfbadc910ef0c0c6c65bd5648b8e86ca.tar.gz
Add the notion of standalone doc sections.
Up to now, section annotations had to match a class or interface name in order to be serialized in the gir. With this commit, they now get serialized as docsection nodes, for potential use by documentation tools.
Diffstat (limited to 'giscanner/maintransformer.py')
-rw-r--r--giscanner/maintransformer.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 9468751d..c04620de 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -69,6 +69,10 @@ class MainTransformer(object):
# Read in most annotations now.
self._namespace.walk(self._pass_read_annotations)
+ # Now that we have associated doc SECTIONs to classes,
+ # add the unused section blocks as standalone nodes.
+ self._add_standalone_doc_sections()
+
# Now that we've possibly seen more types from annotations,
# do another type resolution pass.
self._namespace.walk(self._pass_type_resolution)
@@ -101,6 +105,14 @@ class MainTransformer(object):
# Private
+ def _add_standalone_doc_sections(self):
+ for block_name, block in self._blocks.items():
+ if block_name.startswith("SECTION:") and block.description:
+ node = ast.DocSection(block_name[8:])
+ node.doc = block.description
+ node.doc_position = block.position
+ self._namespace.append(node)
+
def _pass_fixup_hidden_fields(self, node, chain):
"""Hide all callbacks starting with _; the typical
usage is void (*_gtk_reserved1)(void);"""
@@ -240,7 +252,9 @@ class MainTransformer(object):
self._apply_annotations_field(node, block, field)
name = self._get_annotation_name(node)
section_name = 'SECTION:%s' % (name.lower(), )
- block = self._blocks.get(section_name)
+ # We pop it from our blocks so that we can serialize leftover
+ # SECTIONs as standalone nodes
+ block = self._blocks.pop(section_name, None)
self._apply_annotations_annotated(node, block)
if isinstance(node, (ast.Class, ast.Interface)):
for prop in node.properties: