summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--giscanner/maintransformer.py4
-rw-r--r--tests/scanner/Makefile.am3
-rw-r--r--tests/scanner/meson.build1
-rw-r--r--tests/scanner/test_maintransformer.py72
4 files changed, 76 insertions, 4 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index b67dcb7f..a448d9d5 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -229,9 +229,7 @@ class MainTransformer(object):
name = self._get_annotation_name(node)
section_name = 'SECTION:%s' % (name.lower(), )
block = self._blocks.get(section_name)
- if block and block.description:
- node.doc = block.description
- node.doc_position = block.position
+ self._apply_annotations_annotated(node, block)
if isinstance(node, (ast.Class, ast.Interface)):
for prop in node.properties:
self._apply_annotations_property(node, prop)
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am
index 734f30e8..89bfed90 100644
--- a/tests/scanner/Makefile.am
+++ b/tests/scanner/Makefile.am
@@ -236,7 +236,8 @@ PYTESTS = \
test_transformer.py \
test_xmlwriter.py \
test_docwriter.py \
- test_scanner.py
+ test_scanner.py \
+ test_maintransformer.py
TESTS = $(CHECKGIRS) $(CHECKDOCS) $(TYPELIBS) $(PYTESTS)
TESTS_ENVIRONMENT = env srcdir=$(srcdir) top_srcdir=$(top_srcdir) builddir=$(builddir) top_builddir=$(top_builddir) \
diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build
index 95a9dacc..42104886 100644
--- a/tests/scanner/meson.build
+++ b/tests/scanner/meson.build
@@ -13,6 +13,7 @@ scanner_test_files = [
'test_pkgconfig.py',
'test_docwriter.py',
'test_scanner.py',
+ 'test_maintransformer.py',
]
foreach f : scanner_test_files
diff --git a/tests/scanner/test_maintransformer.py b/tests/scanner/test_maintransformer.py
new file mode 100644
index 00000000..abf3ee73
--- /dev/null
+++ b/tests/scanner/test_maintransformer.py
@@ -0,0 +1,72 @@
+import unittest
+import tempfile
+import os
+
+os.environ['GI_SCANNER_DISABLE_CACHE'] = '1'
+
+from giscanner import ast
+from giscanner.sourcescanner import SourceScanner
+from giscanner.transformer import Transformer
+from giscanner.annotationparser import GtkDocCommentBlockParser
+from giscanner.maintransformer import MainTransformer
+
+
+def create_scanner_from_source_string(source):
+ ss = SourceScanner()
+ tmp_fd, tmp_name = tempfile.mkstemp(suffix='.h', text=True)
+
+ try:
+ with os.fdopen(tmp_fd, 'wt') as file:
+ file.write(source)
+ ss.parse_files([tmp_name])
+ finally:
+ os.unlink(tmp_name)
+
+ return ss
+
+
+def load_namespace_from_source_string(namespace, source):
+ ss = create_scanner_from_source_string(source)
+ transformer = Transformer(namespace)
+ transformer.parse(ss.get_symbols())
+ cbp = GtkDocCommentBlockParser()
+ blocks = cbp.parse_comment_blocks(ss.get_comments())
+ main = MainTransformer(transformer, blocks)
+ main.transform()
+
+
+class TestDeprecations(unittest.TestCase):
+
+ def test_record_deprecated(self):
+ namespace = ast.Namespace('Test', '1.0')
+ load_namespace_from_source_string(namespace, """
+ /** TestStruct:
+ * foo
+ * Deprecated: 1.2: something
+ */
+ typedef struct _TestStruct TestStruct;
+ """)
+
+ node = namespace.get('Struct')
+ self.assertEqual(node.doc, "foo")
+ self.assertEqual(node.deprecated, "1.2")
+ self.assertEqual(node.deprecated_doc, "something")
+
+ def test_record_deprecated_from_section(self):
+ namespace = ast.Namespace('Test', '1.0')
+ load_namespace_from_source_string(namespace, """
+ /** SECTION:teststruct
+ * foo
+ * Deprecated: 1.2: something
+ */
+ typedef struct _TestStruct TestStruct;
+ """)
+
+ node = namespace.get('Struct')
+ self.assertEqual(node.doc, "foo")
+ self.assertEqual(node.deprecated, "1.2")
+ self.assertEqual(node.deprecated_doc, "something")
+
+
+if __name__ == '__main__':
+ unittest.main()