[valadoc] Html: Enhance pretty print
- From: Florian Brosch <flobrosch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [valadoc] Html: Enhance pretty print
- Date: Wed, 21 Oct 2009 10:46:04 +0000 (UTC)
commit f2c860acfbc460c88b11322a0d08fc739f3fc109
Author: Didier "Ptitjes <ptitjes free fr>
Date: Tue Oct 20 01:59:29 2009 +0200
Html: Enhance pretty print
src/doclets/htmlhelpers/doclet/markupwriter.vala | 26 +++++++++++----------
1 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/src/doclets/htmlhelpers/doclet/markupwriter.vala b/src/doclets/htmlhelpers/doclet/markupwriter.vala
index 30ce0d6..60681e9 100644
--- a/src/doclets/htmlhelpers/doclet/markupwriter.vala
+++ b/src/doclets/htmlhelpers/doclet/markupwriter.vala
@@ -86,21 +86,23 @@ public class Valadoc.Html.MarkupWriter {
return this;
}
- public MarkupWriter link (string css_class, string url, string label) {
+ public MarkupWriter link (string url, string label, string? css_class = null) {
indent++;
check_column ("a");
- do_write ("<a class=\"%s\" href=\"%s\">%s</a>".printf (
- css_class, url, label));
+ do_write ("<a%s href=\"%s\">%s</a>".printf (
+ css_class != null ? " class=\"%s\"".printf (css_class) : "",
+ url, label));
indent--;
last_was_tag = true;
return this;
}
- public MarkupWriter image (string css_class, string src, string? caption = null) {
+ public MarkupWriter image (string src, string? caption = null, string? css_class = null) {
indent++;
check_column ("img");
- do_write ("<img class=\"%s\" src=\"%s\"%s/>".printf (
- css_class, src,
+ do_write ("<img%s src=\"%s\"%s/>".printf (
+ css_class != null ? " class=\"%s\"".printf (css_class) : "",
+ src,
caption != null ? " alt=\"%s\"".printf (caption) : ""));
indent--;
last_was_tag = true;
@@ -157,11 +159,15 @@ public class Valadoc.Html.MarkupWriter {
}
public void break_line () {
- current_column = 0;
- do_write ("\n%s".printf (get_indent_string ()));
+ stream.printf ("\n");
+ stream.printf (string.nfill (indent * 2, ' '));
+ current_column = indent * 2;
}
public void do_write (string text) {
+ if (current_column + text.length > MAX_COLUMN) {
+ break_line ();
+ }
stream.printf (text);
current_column += text.length;
}
@@ -214,9 +220,5 @@ public class Valadoc.Html.MarkupWriter {
|| name == "u"
|| name == "stoke";
}
-
- private string get_indent_string () {
- return current_column == 0 ? string.nfill (indent * 2, ' ') : "";
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]