[valadoc] doclets/gtkdoclet: Support error-domains annotation



commit 0082010c337a3d16f112441c4ade7fd7c74017c9
Author: Luca Bruno <lethalman88 gmail com>
Date:   Tue May 4 22:05:29 2010 +0200

    doclets/gtkdoclet: Support error-domains annotation

 src/doclets/gtkdoc/gcomment.vala  |   14 ++++----------
 src/doclets/gtkdoc/generator.vala |   28 +++++++++++++++++++---------
 2 files changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/src/doclets/gtkdoc/gcomment.vala b/src/doclets/gtkdoc/gcomment.vala
index 3238abe..c1af819 100644
--- a/src/doclets/gtkdoc/gcomment.vala
+++ b/src/doclets/gtkdoc/gcomment.vala
@@ -45,11 +45,8 @@ public class Gtkdoc.GComment {
 		var builder = new StringBuilder ();
 
 		builder.append_printf ("/**\n * %s", symbol);
-		if (symbol_annotations != null) {
-			if (symbol_annotations.length > 0) {
-				builder.append_c (':');
-			}
-
+		if (symbol_annotations != null && symbol_annotations.length > 0) {
+			builder.append_c (':');
 			foreach (var annotation in symbol_annotations) {
 				builder.append_printf (" (%s)", annotation);
 			}
@@ -57,14 +54,11 @@ public class Gtkdoc.GComment {
 
 		foreach (var header in headers) {
 			builder.append_printf ("\n * %s:", header.name);
-			if (header.annotations != null) {
+			if (header.annotations != null && header.annotations.length > 0) {
 				foreach (var annotation in header.annotations) {
 					builder.append_printf (" (%s)", annotation);
 				}
-
-				if (header.annotations.length > 0) {
-					builder.append_c (':');
-				}
+				builder.append_c (':');
 			}
 
 			if (header.value != null) {
diff --git a/src/doclets/gtkdoc/generator.vala b/src/doclets/gtkdoc/generator.vala
index 4152ea7..c0766e5 100644
--- a/src/doclets/gtkdoc/generator.vala
+++ b/src/doclets/gtkdoc/generator.vala
@@ -179,20 +179,21 @@ public class Gtkdoc.Generator : Api.Visitor {
 		}
 	}
 
-	private void add_manual_header (string name, string? comment, string[]? annotations = null) {
+	private Header? add_manual_header (string name, string? comment, string[]? annotations = null) {
 		if (comment == null && annotations == null) {
-			return;
+			return null;
 		}
 
 		var header = new Header ("@"+name);
 		header.annotations = annotations;
 		header.value = comment;
 		current_headers.add (header);
+		return header;
 	}
 
-	private void add_header (string name, Comment? comment, string[]? annotations = null) {
+	private Header? add_header (string name, Comment? comment, string[]? annotations = null) {
 		if (comment == null) {
-			return;
+			return null;
 		}
 
 		var converter = new Gtkdoc.CommentConverter ();
@@ -209,6 +210,7 @@ public class Gtkdoc.Generator : Api.Visitor {
 
 		header.annotations = annotations;
 		current_headers.add (header);
+		return header;
 	}
 
 	public override void visit_tree (Api.Tree tree) {
@@ -290,13 +292,21 @@ public class Gtkdoc.Generator : Api.Visitor {
 	public override void visit_error_domain (Api.ErrorDomain edomain) {
 		if (current_method != null || current_delegate != null) {
 			// method throws error
+			Header? param_header = null;
 			foreach (var header in current_headers) {
 				if (header.name == "error") {
-					// we already commented the error parameter
-					return;
+					param_header = header;
+					break;
 				}
 			}
-			add_manual_header ("error", "location to store the error occuring, or %NULL to ignore", {"out"});
+			if (param_header == null) {
+				add_manual_header ("error", "location to store the error occuring, or %NULL to ignore", {"error-domains %s".printf (edomain.get_cname ())});
+			} else {
+				// assume the only annotation is error-domains
+				var annotation = param_header.annotations[0];
+				annotation += " %s".printf (edomain.get_cname ());
+				param_header.annotations[0] = annotation;
+			}
 		} else {
 			// error domain definition
 			var old_headers = current_headers;
@@ -387,7 +397,7 @@ public class Gtkdoc.Generator : Api.Visitor {
 		// gtkdoc maps parameters by their ordering, so let's manually add the first parameter
 		add_manual_header (to_lower_case (((Api.Node)sig.parent).name), "", null);
 		sig.accept_all_children (this);
-		var name = sig.get_cname ().replace ("_", "-");
+		var name = sig.get_cname().replace ("_", "-");
 		add_comment (sig.get_filename(), "%s::%s".printf (current_cname, name), sig.documentation);
 
 		current_headers = old_headers;
@@ -457,7 +467,7 @@ public class Gtkdoc.Generator : Api.Visitor {
 
 		if (param.parameter_type.data_type is Api.Array) {
 			annotations += "array length=%s".printf (param.name+"_length1");
-		} 
+		}
 
 		if (param.documentation != null) {
 			add_header (param.name, param.documentation, annotations);



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