[gtk-doc] gtkdoc-scan: recognise attribute-based deprecations



commit b856f3d05e3931c5d29ad0799f2b2417a2f83821
Author: Ryan Lortie <desrt desrt ca>
Date:   Tue Jun 26 11:14:25 2012 -0400

    gtkdoc-scan: recognise attribute-based deprecations
    
    If we see something that looks like a macro for an attribute-based
    deprecation (ie: some string matching /_DEPRECATED/) then mark the next
    single declaration as <DEPRECATED/> in the -decl.txt. This avoids the
    warning for missing deprecation guards.
    Add Deprecated: tags to the doc-blobs of the existing tests to verify
    that we don't get the warnings.
    
    Fixes: #624001

 gtkdoc-mkdb.in          |    4 +---
 gtkdoc-scan.in          |   12 ++++++++++++
 tests/bugs/src/tester.c |   10 ++++++++++
 3 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/gtkdoc-mkdb.in b/gtkdoc-mkdb.in
index fed2f72..67e8c37 100755
--- a/gtkdoc-mkdb.in
+++ b/gtkdoc-mkdb.in
@@ -3891,9 +3891,7 @@ sub ScanSourceFile {
                 }
 
                 if ($deprecated_desc) {
-                    if (exists $Deprecated{$symbol}) {
-                    }
-                    else {
+                    if (!exists $Deprecated{$symbol}) {
                          # don't warn for signals and properties
                          #if ($symbol !~ m/::?(.*)/) {
                          if (defined $DeclarationTypes{$symbol}) {
diff --git a/gtkdoc-scan.in b/gtkdoc-scan.in
index cf72293..6493199 100755
--- a/gtkdoc-scan.in
+++ b/gtkdoc-scan.in
@@ -370,6 +370,13 @@ sub ScanHeader {
             }
         }
 
+        # If we find a line containing _DEPRECATED, we hope that this is
+        # attribute based deprecation and also treat this as a deprecation
+        # guard.
+        if ($deprecated_conditional_nest == 0 and m/_DEPRECATED/) {
+            $deprecated_conditional_nest += 0.1;
+        }
+
         # set global that is used later when we do AddSymbolToList
         if ($deprecated_conditional_nest > 0) {
             $deprecated = "<DEPRECATED/>\n";
@@ -751,6 +758,7 @@ sub ScanHeader {
                 } else {
                      $internal = 0;
                 }
+                $deprecated_conditional_nest = int($deprecated_conditional_nest);
                 $in_declaration = "";
                 $skip_block = 0;
             }
@@ -761,6 +769,7 @@ sub ScanHeader {
                 if (&AddSymbolToList (\$list, $symbol)) {
                     print DECL 
"<USER_FUNCTION>\n<NAME>$symbol</NAME>\n$deprecated<RETURNS>$ret_type</RETURNS>\n$decl</USER_FUNCTION>\n";
                 }
+                $deprecated_conditional_nest = int($deprecated_conditional_nest);
                 $in_declaration = "";
             }
         }
@@ -774,6 +783,7 @@ sub ScanHeader {
                 } else {
                     $internal = 0;
                 }
+                $deprecated_conditional_nest = int($deprecated_conditional_nest);
                 $in_declaration = "";
             }
         }
@@ -786,6 +796,7 @@ sub ScanHeader {
                 if (&AddSymbolToList (\$list, $symbol)) {
                     print DECL "<ENUM>\n<NAME>$symbol</NAME>\n$deprecated$decl</ENUM>\n";
                 }
+                $deprecated_conditional_nest = int($deprecated_conditional_nest);
                 $in_declaration = "";
             }
         }
@@ -812,6 +823,7 @@ sub ScanHeader {
                         undef($forward_decls{$symbol});
                     }
                 }
+                $deprecated_conditional_nest = int($deprecated_conditional_nest);
                 $in_declaration = "";
             } else {
                 # We use tr to count the brackets in the line, and adjust
diff --git a/tests/bugs/src/tester.c b/tests/bugs/src/tester.c
index 7cd861c..47dc4f7 100644
--- a/tests/bugs/src/tester.c
+++ b/tests/bugs/src/tester.c
@@ -355,6 +355,8 @@ void bug_000000_va1 (gchar name, ...)
  * bug_624001a:
  *
  * http://bugzilla.gnome.org/show_bug.cgi?id=624001
+ *
+ * Deprecated: Use main() instead.
  */
 void bug_624001a(void)
 {
@@ -364,6 +366,8 @@ void bug_624001a(void)
  * bug_624001b:
  *
  * http://bugzilla.gnome.org/show_bug.cgi?id=624001
+ *
+ * Deprecated: Use main() instead.
  */
 void bug_624001b(void)
 {
@@ -373,6 +377,8 @@ void bug_624001b(void)
  * bug_624001c:
  *
  * http://bugzilla.gnome.org/show_bug.cgi?id=624001
+ *
+ * Deprecated: Use main() instead.
  */
 void bug_624001c(void)
 {
@@ -382,6 +388,8 @@ void bug_624001c(void)
  * bug_624001d:
  *
  * http://bugzilla.gnome.org/show_bug.cgi?id=624001
+ *
+ * Deprecated: Use main() instead.
  */
 void bug_624001d(void)
 {
@@ -391,6 +399,8 @@ void bug_624001d(void)
  * bug_624001e:
  *
  * http://bugzilla.gnome.org/show_bug.cgi?id=624001
+ *
+ * Deprecated: Use main() instead.
  */
 void bug_624001e(void)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]