[valadoc] libvaladoc: add helpers for valadoc.org



commit 737a1463232535f487850f80fe0fb49b4978f77e
Author: Florian Brosch <flo brosch gmail com>
Date:   Mon Jan 23 16:26:52 2012 +0100

    libvaladoc: add helpers for valadoc.org

 src/libvaladoc/api/node.vala              |   69 ++++++++++++++++++++++++++++-
 src/libvaladoc/charts/chart.vala          |   11 +++++
 src/libvaladoc/html/htmlmarkupwriter.vala |   15 +++++--
 3 files changed, 90 insertions(+), 5 deletions(-)
---
diff --git a/src/libvaladoc/api/node.vala b/src/libvaladoc/api/node.vala
index 48cb600..ab440ba 100755
--- a/src/libvaladoc/api/node.vala
+++ b/src/libvaladoc/api/node.vala
@@ -47,7 +47,74 @@ public enum Valadoc.Api.NodeType {
 	SIGNAL,
 	STATIC_METHOD,
 	STRUCT,
-	TYPE_PARAMETER
+	TYPE_PARAMETER;
+
+	public string to_string () {
+		switch (this) {
+		case CLASS:
+			return "CLASS";
+
+		case CONSTANT:
+			return "CONSTANT";
+
+		case CREATION_METHOD:
+			return "CREATION_METHOD";
+
+		case DELEGATE:
+			return "DELEGATE";
+
+		case ENUM:
+			return "ENUM";
+
+		case ENUM_VALUE:
+			return "ENUM_VALUE";
+
+		case ERROR_CODE:
+			return "ERROR_CODE";
+
+		case ERROR_DOMAIN:
+			return "ERROR_DOMAIN";
+
+		case FIELD:
+			return "FIELD";
+
+		case FORMAL_PARAMETER:
+			return "FORMAL_PARAMETER";
+
+		case INTERFACE:
+			return "INTERFACE";
+
+		case METHOD:
+			return "METHOD";
+
+		case NAMESPACE:
+			return "NAMESPACE";
+
+		case PACKAGE:
+			return "PACKAGE";
+
+		case PROPERTY:
+			return "PROPERTY";
+
+		case PROPERTY_ACCESSOR:
+			return "PROPERTY_ACCESSOR";
+
+		case SIGNAL:
+			return "SIGNAL";
+
+		case STATIC_METHOD:
+			return "STATIC_METHOD";
+
+		case STRUCT:
+			return "STRUCT";
+
+		case TYPE_PARAMETER:
+			return "TYPE_PARAMETER";
+
+		default:
+			assert_not_reached ();
+		}
+	}
 }
 
 /**
diff --git a/src/libvaladoc/charts/chart.vala b/src/libvaladoc/charts/chart.vala
index caedfd3..f4b9908 100755
--- a/src/libvaladoc/charts/chart.vala
+++ b/src/libvaladoc/charts/chart.vala
@@ -50,6 +50,17 @@ public class Valadoc.Charts.Chart : Api.Visitor {
 		context.render (graph, file_type, file);
 	}
 
+	public uint8[] write_buffer (string file_type) {
+		if (context == null) {
+			context = factory.create_context (graph);
+		}
+
+		uint8[] data;
+
+		context.render_data (graph, file_type, out data);
+		return data;
+	}
+
 	~Chart () {
 		if (context != null) {
 			context.free_layout (graph);
diff --git a/src/libvaladoc/html/htmlmarkupwriter.vala b/src/libvaladoc/html/htmlmarkupwriter.vala
index 13e6cd0..435d833 100755
--- a/src/libvaladoc/html/htmlmarkupwriter.vala
+++ b/src/libvaladoc/html/htmlmarkupwriter.vala
@@ -24,19 +24,26 @@ using GLib;
 using Valadoc.Content;
 
 public class Valadoc.Html.MarkupWriter : Valadoc.MarkupWriter {
-	private unowned FileStream stream;
 
 	public MarkupWriter (FileStream stream, bool xml_declaration = true) {
 		// avoid broken implicit copy
 		unowned FileStream _stream = stream;
 
 		base ((str) => { _stream.printf (str); }, xml_declaration);
-		this.stream = stream;
+	}
+
+	public MarkupWriter.builder (StringBuilder builder, bool xml_declaration = true) {
+		// avoid broken implicit copy
+		unowned StringBuilder _builder = builder;
+
+		base ((str) => { _builder.append (str); }, xml_declaration);
 	}
 
 	public MarkupWriter add_usemap (Charts.Chart chart) {
-		stream.putc ('\n');
-		chart.write (stream, "cmapx");
+		string buf = (string) chart.write_buffer ("cmapx");
+		raw_text ("\n");
+		raw_text (buf);
+
 		return this;
 	}
 



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