summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@hora-obscura.de>2020-01-27 20:40:42 +0000
committerStefan Sauer <ensonic@hora-obscura.de>2020-01-27 20:40:42 +0000
commit1c8fcb31c6ec504095c94c417d7723872b29e4fb (patch)
treebfec45126fd5327acf18dff0041bc4b2c043bf4f
parentc9abea94fee058790780b406398600ad6310409e (diff)
parentb866a90b385d5eed12e123cfac0cf587f716c168 (diff)
downloadgtk-doc-1c8fcb31c6ec504095c94c417d7723872b29e4fb.tar.gz
Merge branch 'DeprecatedStructMember' into 'master'
scan: support deprecated struct members See merge request GNOME/gtk-doc!43
-rw-r--r--gtkdoc/scan.py12
-rwxr-xr-xtests/scan.py17
2 files changed, 27 insertions, 2 deletions
diff --git a/gtkdoc/scan.py b/gtkdoc/scan.py
index 5a5da92..6c6534a 100644
--- a/gtkdoc/scan.py
+++ b/gtkdoc/scan.py
@@ -538,7 +538,7 @@ def ScanHeaderContent(input_lines, decl_list, get_types, options):
# section (#endif /* XXX_DEPRECATED */
if deprecated_conditional_nest == 0 and '_DEPRECATED' in line:
m = re.search(r'^\s*#\s*(if*|define|endif)', line)
- if not (m or in_declaration == 'enum'):
+ if not (m or in_declaration == 'enum' or in_declaration == 'struct'):
logging.info('Found deprecation annotation (decl: "%s"): "%s"',
in_declaration, line.strip())
deprecated_conditional_nest += 0.1
@@ -953,9 +953,17 @@ def ScanHeaderContent(input_lines, decl_list, get_types, options):
title = '<TITLE>%s</TITLE>' % objectname
logging.info('Store struct: "%s"', symbol)
+ # Structs could contain deprecated members and that doesn't
+ # mean the whole struct is deprecated, so they are ignored when
+ # setting deprecated_conditional_nest above. Here we can check
+ # if the _DEPRECATED is between '}' and ';' which would mean
+ # the struct as a whole is deprecated.
+ if re.search(r'\n\s*\}.*_DEPRECATED.*;\s*$', decl):
+ deprecated = '<DEPRECATED/>\n'
if AddSymbolToList(slist, symbol):
structsym = in_declaration.upper()
- stripped_decl = re.sub('(%s)' % optional_decorators_regex, '', decl)
+ regex = r'(?:\s+(?:G_GNUC_\w+(?:\(\w*\))?%s))' % ignore_decorators
+ stripped_decl = re.sub(regex, '', decl)
decl_list.append('<%s>\n<NAME>%s</NAME>\n%s%s</%s>\n' %
(structsym, symbol, deprecated, stripped_decl, structsym))
if symbol in forward_decls:
diff --git a/tests/scan.py b/tests/scan.py
index ad63541..6d608b6 100755
--- a/tests/scan.py
+++ b/tests/scan.py
@@ -552,6 +552,23 @@ class ScanHeaderContentStructs(ScanHeaderContentTestCase):
slist, doc_comments = self.scanHeaderContent([header])
self.assertDecl('data', expected, slist)
+ def test_HandleDeprecatedMemberDecorator(self):
+ """Struct with deprecated members."""
+ header = textwrap.dedent("""\
+ struct data {
+ int x1 G_GNUC_DEPRECATED;
+ int x2 G_GNUC_DEPRECATED_FOR(replacement);
+ };""")
+ expected = textwrap.dedent("""\
+ struct data {
+ int x1;
+ int x2;
+ };""")
+ scan.InitScanner(self.options)
+ slist, doc_comments = self.scanHeaderContent(
+ header.splitlines(keepends=True))
+ self.assertDecl('data', expected, slist)
+
class ScanHeaderContentUnions(ScanHeaderContentTestCase):
"""Test parsing of union declarations."""